Intel® Fortran Compiler 16.0 User and Reference Guide
Elemental Intrinsic Function (Generic): Returns the imaginary part of a complex number. This function can also be specified as IMAG.
result = AIMAG (z)
z |
(Input) Must be of type complex. |
The result type is real with the same kind parameter as z. If z has the value (x, y), the result has the value y.
Specific Name |
Argument Type |
Result Type |
---|---|---|
AIMAG 1 |
COMPLEX(4) |
REAL(4) |
DIMAG |
COMPLEX(8) |
REAL(8) |
QIMAG |
COMPLEX(16) |
REAL(16) |
1The setting of compiler options specifying real size can affect AIMAG. |
To return the real part of complex numbers, use REAL.
AIMAG ((4.0, 5.0)) has the value 5.0.
The program AIMAG.F90 applies the quadratic formula to a polynomial and allows for complex results:
REAL a, b, c COMPLEX ans1, ans2, d WRITE ( *, 100) 100 FORMAT (' Enter A, b, and c of the ', & 'polynomial ax**2 + bx + c: '\) READ (*, *) a, b, c d = CSQRT (CMPLX (b**2 - 4.0*a*c)) ! d is either: ! 0.0 + i root, or ! root + i 0.0 ans1 = (-b + d) / (2.0 * a) ans2 = (-b + d) / (2.0 * a) WRITE (*, 200) 200 FORMAT (/ ' The roots are:' /) WRITE (*, 300) REAL(ans1), AIMAG(ans1), & REAL(ans2), AIMAG(ans2) 300 FORMAT (' X = ', F10.5, ' + i', F10.5) END