CMPLX — Complex conversion function#
-
CMPLX(X, Y, KIND)#
CMPLX(X [, Y [, KIND]])returns a complex number whereXis converted to the real component. IfYis present it is converted to the imaginary component. IfYis not present then the imaginary component is set to 0.0. IfXis complex thenYmust not be present.- Parameters:
X – The type may be
INTEGER,REAL, orCOMPLEX.Y – (Optional; only allowed if
Xis notCOMPLEX.) May beINTEGERorREAL.KIND – (Optional) An
INTEGERinitialization expression indicating the kind parameter of the result.
- Returns:
The return value is of
COMPLEXtype, with a kind equal toKINDif it is specified. IfKINDis not specified, the result is of the defaultCOMPLEXkind, regardless of the kinds ofXandY.
- Standard:
Fortran 77 and later
- Class:
Elemental function
- Syntax:
RESULT = CMPLX(X [, Y [, KIND]])
- Example:
program test_cmplx integer :: i = 42 real :: x = 3.14 complex :: z z = cmplx(i, x) print *, z, cmplx(x) end program test_cmplx
- See also: