AIMAG(3) - [TYPE:CONVERSION] Imaginary part of complex number
result = aimag(z)
elemental complex(kind=KIND) function aimag(z)complex(kind=KIND),intent(in) :: z
o The type of the argument Z shall be complex and any supported complex kind o The return value is of type real with the kind type parameter of the argument.
AIMAG(3) yields the imaginary part of the complex argument Z.
This is similar to the modern complex-part-designator %IM which also designates the imaginary part of a value, accept a designator can appear on the left-hand side of an assignment as well, as in VAL%IM=10.0.
o Z : The complex value to extract the imaginary component of.
The return value is a real value with the magnitude and sign of the imaginary component of the argument Z.
That is, If Z has the value (X,Y), the result has the value Y.
Sample program:
program demo_aimag use, intrinsic :: iso_fortran_env, only : real32, real64, real128 implicit none character(len=*),parameter :: g=(*(1x,g0)) integer :: i complex :: z4 complex :: arr(3) complex(kind=real64) :: z8Results:print g, basics: z4 = cmplx(1.e0, 2.e0) print *, value=,z4 print g, imaginary part=,aimag(z4),or, z4%im
print g, kinds other than the default may be supported z8 = cmplx(3.e0_real64, 4.e0_real64,kind=real64) print *, value=,z8 print g, imaginary part=,aimag(z8),or, z8%im
print g, an elemental function can be passed an array print g,given a complex array: arr=[z4,z4/2.0,z4+z4] print *, (arr(i),new_line(a),i=1,size(arr)) print g,the imaginary component is: print g, aimag( arr )
end program demo_aimag
> basics: > value= (1.00000000,2.00000000) > imaginary part= 2.00000000 or 2.00000000 > kinds other than the default may be supported > value= (3.0000000000000000,4.0000000000000000) > imaginary part= 4.0000000000000000 or 4.0000000000000000 > an elemental function can be passed an array > given a complex array: > (1.00000000,2.00000000) > (0.500000000,1.00000000) > (2.00000000,4.00000000) > > the imaginary component is: > 2.00000000 1.00000000 4.00000000
FORTRAN 77
Fortran has strong support for complex values, including many intrinsics that take or produce complex values in addition to algebraic and logical expressions:
o CMPLX(3) - Complex conversion function o CONJG(3) - Complex conjugate function o REAL(3) - Convert to real type ABS(3), ACOSH(3), ACOS(3), ASINH(3), ASIN(3), ATAN2(3), ATANH(3), ATAN(3), COSH(3), COS(3), CO_SUM(3), DBLE(3), DOT_PRODUCT(3), EXP(3), INT(3), IS_CONTIGUOUS(3), KIND(3), LOG(3), MATMUL(3), PRECISION(3), PRODUCT(3), RANGE(3), RANK(3), SINH(3), SIN(3), SQRT(3), STORAGE_SIZE(3), SUM(3), TANH(3), TAN(3), UNPACK(3),
Fortran intrinsic descriptions (license: MIT) @urbanjost
Nemo Release 3.1 | aimag (3fortran) | November 02, 2024 |