Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 9/08/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

AIMAG

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.

Results

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.

Example

AIMAG ((4.0, 5.0)) has the value 5.0.

If C is complex, C%IM is the same as AIMAG (C).

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

See Also