CMPLX intrinsic function

Standard: F77 F90 F95 F2003 F2008 F2018 Example program


CMPLX ( X [ , Y , KIND ] )
CMPLX ( X [ , KIND ] )

X : Integer, Real, Complex or a BOZ literal constant;
Y : Integer, Real or a BOZ literal constant, conformable with X;
KIND : scalar Integer constant expression;

Result : Complex, or Complex(Kind=KIND).

If X is of type Complex, Y must not appear. If X is of type Complex, the KIND argument may appear as the second positional argument.


When X is Complex this function produces a complex value approximating X in the kind of the result (i.e. it changes the kind of the complex value).

When X is not Complex it specifies the real part of the result, and Y specifies the imaginary part; if Y is not present, the imaginary part is zero. Note that X and Y are permitted to be of different types or kinds.

If X or Y is a BOZ literal constant it is interpreted as the internal representation (as a bitstring) of that part of the result. Note that this bitstring must not be longer that the number of bits in the real or imaginary part, unless the excess bits are all leading zeroes. If the bitstring is shorter than the number of bits in the real or imaginary part, it is padded on the left with leading zeroes.

Like many intrinsic functions, this is elemental; if either (or both) of X and Y is an array, the result will be an array with that shape, with the value being computed elementwise.


AIMAG intrinsic function, COMPLEX type, REAL intrinsic function