CMPLX — Complex conversion function#
-
CMPLX(X, Y, KIND)#
CMPLX(X [, Y [, KIND]])
returns a complex number whereX
is converted to the real component. IfY
is present it is converted to the imaginary component. IfY
is not present then the imaginary component is set to 0.0. IfX
is complex thenY
must not be present.- Parameters
X – The type may be
INTEGER
,REAL
, orCOMPLEX
.Y – (Optional; only allowed if
X
is notCOMPLEX
.) May beINTEGER
orREAL
.KIND – (Optional) An
INTEGER
initialization expression indicating the kind parameter of the result.
- Returns
The return value is of
COMPLEX
type, with a kind equal toKIND
if it is specified. IfKIND
is not specified, the result is of the defaultCOMPLEX
kind, regardless of the kinds ofX
andY
.
- 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: