|
|
BSD 4.3tahoe
.TI F77/COMPLEX "Sep. 4, 1985"
Complex and Double Complex Constants, Variables and Intrinsic Functions
Declare single precision complex variables as type 'complex' or 'complex*8';
declare double precision complex variables as 'double complex' or 'complex*16'.
Here is an example illustrating the use of single precision complex
variables and constants:
.nf
implicit complex (c)
data x1/8.5/, x2/9.2/
c create c1 from a complex constant
c1 = (1.1,2.1)
c create c2 from two real variables
c2 = cmplx( x1, x2 )
c take complex square root of c1 using
c the generic function name
c3 = sqrt(c1)
c get the real part of c3
xreal1 = c3
xreal2 = real(c3)
c get imaginary part, aimag() would also work
ximag = imag( c3 )
c find the conjugate of c3
c4 = conjg(c3)
print *, c1,c2,c3,c4,x1,x2,xreal1,xreal2,ximag
end
.fi
The same example in double precision:
.nf
implicit double complex (z)
implicit double precision (d)
data d1/8.5d0/, d2/9.2d0/
z1 = (1.1d0,2.1d0)
z2 = dcmplx( d1, d2 )
z3 = sqrt(z1)
c get the real part, dreal() would also work
dxreal1 = z3
dxreal2 = dble(z3)
c get the imaginary part, dimag() would also work
dximag = imag( z3 )
c find the conjugate
z4 = conjg(z3)
print *, z1,z2,z3,z4,d1,d2,dxreal1,dxreal2,dximag
end
.fi
To create a complex value from real variables, use 'cmplx()'. To
create a double complex value from double precision variables, use 'dcmplx()'.
The generic function names, that work with both complex
and double complex, are:
.nf
imag(), conjg(), sqrt(), abs(), exp(), log(), sin(), cos()
.fi
If you declare the function to be external and pass the function name
to a procedure, you must use the specific function name. For single
precision, they are:
.nf
aimag(), conjg(),csqrt(),cabs(),cexp(),clog(),csin(),ccos()
.fi
and for double precision, they are:
.nf
dimag(),dconjg(),zsqrt(),zabs(),zexp(),zlog(),zsin(),zcos()
.fi
For compatibility with other vendors compilers, the last six
specific functions may also be referred to as:
.nf
cdsqrt(),cdabs(),cdexp(),cdlog(),cdsin(),cdcos()
.fi
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.