!************************************************* !* Test elementary operations on complex numbers * !* --------------------------------------------- * !* Use: to link with module complex2. * !* * !* SAMPLE RUN: * !* * !* Z1=( 1.000000, -2.000000) * !* Z2=( 2.500000, 5.750000) * !* Z1+Z2=( 3.500000, 3.750000) * !* Z1+Z2 with modulus and phase: * !* ( 5.129571, 0.819867) * !* Z1 with modulus and phase: * !* ( 2.236068, -1.107149) * !* Z2 with modulus and phase: * !* ( 6.269968, 1.160669) * !* Z1*Z2=( 14.000000, 0.750000) * !* Z1*Z2 with modulus and phase: * !* ( 14.020075, 0.053520) * !* Z1/Z2 with modulus and phase: * !* ( 0.356631, -2.267818) * !* Exp(Z1)=( -1.131204, -2.471727) * !* Exp(Z1) with modulus and phase: * !* ( 2.718282, -2.000000) * !* ArgSh(Z2)=( 2.524586, 1.155957) * !* * !* F90 version by J-P Moreau, Paris. * !* (www.jpmoreau.fr) * !************************************************* PROGRAM TCOMPLEX USE COMPLEX2 type(ZCOMPLEX) Z1,Z2,Z3 real*8 x, y x=1.d0; y=-2.d0 call AssignXY(Z1,x,y) x=2.5d0; y=5.75d0 call AssignXY(Z2,x,y) call AddComplex(Z3,Z1,Z2) print *,' ' write(*,10,advance='no') call DisplayComplex(Z1) write(*,12,advance='no') call DisplayComplex(Z2) write(*,15,advance='no') call DisplayComplex(Z3) print *,' Z1+Z2 with modulus and phase:' write(*,50,advance='no') call DisplayComplexR(Z3) print *,' Z1 with modulus and phase:' write(*,50,advance='no') call DisplayComplexR(Z1) print *,' Z2 with modulus and phase:' write(*,50,advance='no') call DisplayComplexR(Z2) call MulComplex(Z3,Z1,Z2) write(*,20,advance='no') call DisplayComplex(Z3) print *,' Z1*Z2 with modulus and phase:' write(*,50,advance='no') call DisplayComplexR(Z3) call DivComplex(Z3,Z1,Z2) print *,' Z1/Z2 with modulus and phase:' write(*,50,advance='no') call DisplayComplexR(Z3) call ExpComplex(Z3,Z1) write(*,25,advance='no') call DisplayComplex(Z3) print *,' Exp(Z1) with modulus and Phase:' write(*,50,advance='no') call DisplayComplexR(Z3) call ArgShComplex(Z3,Z2) write(*,30,advance='no') call DisplayComplex(Z3) print *,' ' print *,' ' stop 10 format(' Z1=') 12 format(' Z2=') 15 format(' Z1+Z2=') 20 format(' Z1*Z2=') 25 format(' Exp(Z1)=') 30 format(' ArgSh(Z2)=') 50 format(' ') END ! end of file tcomplex.f90