Elemental Intrinsic Function (Generic): Converts the argument to complex type. This function must not be passed as an actual argument.
Syntax
Results:
The result is of type complex (COMPLEX(4) or COMPLEX*8). If kind is present, the kind parameter is that specified by kind; otherwise, the kind parameter is that of default real type.
If only one noncomplex argument appears, it is converted into the real part of the result value and zero is assigned to the imaginary part. If y is not specified and x is complex, the result value is CMPLX(REAL(x), AIMAG(x)).
If two noncomplex arguments appear, the complex value is produced by converting the first argument into the real part of the value, and converting the second argument into the imaginary part.
CMPLX(x, y, kind) has the complex value whose real part is REAL(x, kind) and whose imaginary part is REAL(y, kind).
The setting of compiler option /real_size can affect this function.
Compatibility
CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB
See Also: DCMPLX, FLOAT, INT, IFIX, REAL, SNGL
Examples
CMPLX (-3) has the value (-3.0, 0.0).
CMPLX (4.1, 2.3) has the value (4.1, 2.3).
The following shows another example:
COMPLEX z1, z2
COMPLEX(8) z3
z1 = CMPLX(3) ! returns the value 3.0 + i 0.0
z2 = CMPLX(3,4) ! returns the value 3.0 + i 4.0
z3 = CMPLX(3,4,8) ! returns a COMPLEX(8) value 3.0D0 + i 4.0D0