インテル® Fortran コンパイラー 19.0 デベロッパー・ガイドおよびリファレンス

CMPLX

Elemental Intrinsic Function (Specific): Converts the argument to complex type. This function cannot be passed as an actual argument.

result = CMPLX (x[,y] [,kind])

x

(Input) Must be of type integer, real, or complex, or a binary, octal, or hexadecimal literal constant.

y

(Input; optional) Must be of type integer or real, or a binary, octal, or hexadecimal literal constant. It must not be present if x is of type complex.

kind

(Input; optional) Must be a scalar integer constant expression.

Results

The result type is complex. 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 options specifying real size can affect this function.

If the argument is a binary, octal, or hexadecimal literal constant, the result is affected by the assume old-boz option. The default option setting, noold-boz, treats the argument as a bit string that represents a value of the data type of the intrinsic, that is, the bits are not converted. If setting old-boz is specified, the argument is treated as a signed integer and the bits are converted.

NOTE

The result values of CMPLX are defined by references to the intrinsic function REAL with the same arguments. Therefore, the padding and truncation of binary, octal, and hexadecimal literal constant arguments to CMPLX is the same as for the intrinsic function REAL.

Example

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

See Also