|
|
1.1 ! root 1: .TI F77/COMPLEX "Sep. 4, 1985" ! 2: Complex and Double Complex Constants, Variables and Intrinsic Functions ! 3: ! 4: Declare single precision complex variables as type 'complex' or 'complex*8'; ! 5: declare double precision complex variables as 'double complex' or 'complex*16'. ! 6: ! 7: Here is an example illustrating the use of single precision complex ! 8: variables and constants: ! 9: ! 10: .nf ! 11: implicit complex (c) ! 12: data x1/8.5/, x2/9.2/ ! 13: ! 14: c create c1 from a complex constant ! 15: c1 = (1.1,2.1) ! 16: c create c2 from two real variables ! 17: c2 = cmplx( x1, x2 ) ! 18: ! 19: c take complex square root of c1 using ! 20: c the generic function name ! 21: c3 = sqrt(c1) ! 22: ! 23: c get the real part of c3 ! 24: xreal1 = c3 ! 25: xreal2 = real(c3) ! 26: c get imaginary part, aimag() would also work ! 27: ximag = imag( c3 ) ! 28: c find the conjugate of c3 ! 29: c4 = conjg(c3) ! 30: ! 31: print *, c1,c2,c3,c4,x1,x2,xreal1,xreal2,ximag ! 32: end ! 33: .fi ! 34: ! 35: The same example in double precision: ! 36: ! 37: .nf ! 38: implicit double complex (z) ! 39: implicit double precision (d) ! 40: data d1/8.5d0/, d2/9.2d0/ ! 41: ! 42: z1 = (1.1d0,2.1d0) ! 43: z2 = dcmplx( d1, d2 ) ! 44: z3 = sqrt(z1) ! 45: c get the real part, dreal() would also work ! 46: dxreal1 = z3 ! 47: dxreal2 = dble(z3) ! 48: c get the imaginary part, dimag() would also work ! 49: dximag = imag( z3 ) ! 50: c find the conjugate ! 51: z4 = conjg(z3) ! 52: ! 53: print *, z1,z2,z3,z4,d1,d2,dxreal1,dxreal2,dximag ! 54: end ! 55: .fi ! 56: ! 57: To create a complex value from real variables, use 'cmplx()'. To ! 58: create a double complex value from double precision variables, use 'dcmplx()'. ! 59: The generic function names, that work with both complex ! 60: and double complex, are: ! 61: ! 62: .nf ! 63: imag(), conjg(), sqrt(), abs(), exp(), log(), sin(), cos() ! 64: .fi ! 65: ! 66: If you declare the function to be external and pass the function name ! 67: to a procedure, you must use the specific function name. For single ! 68: precision, they are: ! 69: ! 70: .nf ! 71: aimag(), conjg(),csqrt(),cabs(),cexp(),clog(),csin(),ccos() ! 72: .fi ! 73: ! 74: and for double precision, they are: ! 75: ! 76: .nf ! 77: dimag(),dconjg(),zsqrt(),zabs(),zexp(),zlog(),zsin(),zcos() ! 78: .fi ! 79: ! 80: For compatibility with other vendors compilers, the last six ! 81: specific functions may also be referred to as: ! 82: ! 83: .nf ! 84: cdsqrt(),cdabs(),cdexp(),cdlog(),cdsin(),cdcos() ! 85: .fi
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.