4 ! Check overloading of intrinsic binary operators for numeric operands
5 ! Reported by Adelson Oliveira
9 INTERFACE OPERATOR(.MULT
.)
10 MODULE PROCEDURE MULTr4
11 MODULE PROCEDURE MULTc4
14 MODULE PROCEDURE MULTr4
15 MODULE PROCEDURE MULTc4
17 INTERFACE OPERATOR(==)
18 MODULE PROCEDURE MULTr4
19 MODULE PROCEDURE MULTc4
20 MODULE PROCEDURE MULTr8
23 MODULE PROCEDURE MULTc4
24 MODULE PROCEDURE MULTi4
26 INTERFACE OPERATOR(**)
27 MODULE PROCEDURE MULTc4
28 MODULE PROCEDURE MULTi4
34 elemental
function copy (z
)
35 complex, intent(in
) :: z
40 REAL, INTENT(IN
) :: v(:)
41 REAL, INTENT(IN
) :: m(:,:)
42 REAL :: MULTr4(SIZE(m
,DIM
=1),SIZE(m
,DIM
=2))
44 FORALL(i
=1:SIZE(v
)) MULTr4(:,i
)=m(:,i
)*v(i
)
47 REAL, INTENT(IN
) :: v(:)
48 double precision, INTENT(IN
) :: m(:,:)
49 double precision :: MULTr8(SIZE(m
,DIM
=1),SIZE(m
,DIM
=2))
51 FORALL(i
=1:SIZE(v
)) MULTr8(:,i
)=m(:,i
)*v(i
)
54 REAL, INTENT(IN
) :: v(:)
55 COMPLEX, INTENT(IN
) :: m(:,:)
56 COMPLEX :: MULTc4(SIZE(m
,DIM
=1),SIZE(m
,DIM
=2))
58 FORALL(i
=1:SIZE(v
)) MULTc4(:,i
)=m(:,i
)*v(i
)
61 REAL, INTENT(IN
) :: v(:)
62 integer, INTENT(IN
) :: m(:,:)
63 REAL :: MULTi4(SIZE(m
,DIM
=1),SIZE(m
,DIM
=2))
65 FORALL(i
=1:SIZE(v
)) MULTi4(:,i
)=m(:,i
)*v(i
)
74 real, parameter :: vv(3) = 42.
75 complex, parameter :: zz(3,3) = (1.0,0.0)
76 integer, parameter :: kk(3,3) = 2
77 double precision :: dd(3,3) = 3.d0
78 COMPLEX, ALLOCATABLE
:: m(:,:),r(:,:), s(:,:)
79 REAL, ALLOCATABLE
:: v(:)
80 type(t
) :: z(1) = t(zz
)
81 ALLOCATE(v(3),m(3,3),r(3,3),s(3,3))
85 r
=v
.MULT
.m
! Reference
87 if (any (r
/= s
)) stop 1
88 if (.not
. all (r
== s
)) stop 2
89 ! Check other binary intrinsics
91 if (any (r
/= s
)) stop 3
93 if (any (r
/= s
)) stop 4
95 if (any (r
/= s
)) stop 5
97 if (any (r
/= s
)) stop 6
99 if (any (r
/= s
)) stop 7
101 if (any (r
/= s
)) stop 8
103 if (any (r
/= s
)) stop 9
105 if (any (r
/= s
)) stop 10
106 ! check if .eq. same operator as == etc.
108 if (any (r
/= s
)) stop 11
110 if (any (r
/= s
)) stop 12
112 if (any (r
/= s
)) stop 13
113 if (.not
. all ( 1. < (vv
**kk
))) stop 14
114 if (.not
. all ( 1. < (vv
< kk
))) stop 15
115 if (.not
. all ((42.,0.) == (v
< m
))) stop 16
116 if (.not
. all ((42.,0.) == (v
** m
))) stop 17
117 if (.not
. all ( 126.d0
== (vv
==dd
))) stop 18