DCOMPLEX Function
The DCOMPLEX function does the following:
*Convert an expression to double-precision complex data type.
*Extract data from an expression and place it in a complex scalar or array.
enabled.
Usage
This form is used to convert data.
result = DCOMPLEX(real [, imaginary])
This form is used to extract data.
result = DCOMPLEX(expr, offset,[dim1, dim2, ... , dimn ])
Input Parameters
To convert data:
real — Scalar or array to be used as the real part of the complex result.
imaginary — (optional) Scalar or array to be used as the imaginary part of the complex result. If not present, the imaginary part of the result is zero.
To extract data:
expr — The expression to be converted, or from which to extract data.
offset — The offset, in bytes, from the beginning of expr to where the extraction is to begin.
dimi — (optional) The dimensions of the result. This parameter may be any scalar expression, and up to eight dimensions may be specified.
Returned Value
If converting:
result — The result is a double-precision complex data type with the size and structure determined by the size and structure of real and imaginary input parameters. If either or both of the parameters are arrays, result will be an array, following the same rules as standard PV-WAVE operators.
If extracting:
result — The result is a complex data type with the size and structure determined by the size and structure of the dimi parameters. If no dimensions are specified, the result is scalar.
Keywords
None.
Discussion
DCOMPLEX is used primarily to convert data to complex data type. If real is of type string and if the string does not contain a valid floating-point value (thereby making it impossible to convert), then PV-WAVE returns 0 and displays a notice. Otherwise, expr is converted to complex data type. The ON_IOERROR procedure can be used to establish a statement to jump to in the case of such errors.
If only one parameter is supplied, the imaginary part of the result is 0; otherwise, it is set by the imaginary parameter. Parameters are first converted to double-precision floating-point.
 
note
If three or more parameters are supplied, DCOMPLEX extracts fields of data from expr, rather than performing conversion.
Example
real = DINDGEN(5)
b = DCOMPLEX(real)
INFO, b
; PV-WAVE prints: B DOUBLE COMPLEX = Array(5)
PM, b ; PV-WAVE prints the following:
; (      0.0000000,      0.0000000)
; (      1.0000000,      0.0000000)
; (      2.0000000,      0.0000000)
; (      3.0000000,      0.0000000)
; (      4.0000000,      0.0000000)
img = INTARR(5) + 6
c = DCOMPLEX(real, img)
INFO, c
; PV-WAVE prints: C DOUBLE COMPLEX = Array(5)
PM, c ; PV-WAVE prints the following:
; (      0.0000000,      6.0000000)
; (      1.0000000,      6.0000000)
; (      2.0000000,      6.0000000)
; (      3.0000000,      6.0000000)
; (      4.0000000,      6.0000000)
d = DCOMPLEX(real, 7)
INFO, d
; PV-WAVE prints: D DOUBLE COMPLEX = Array(5)
PM, d ; PV-WAVE prints the following:
; (      0.0000000,      7.0000000)
; (      1.0000000,      7.0000000)
; (      2.0000000,      7.0000000)
; (      3.0000000,      7.0000000)
; (      4.0000000,      7.0000000)
e = DCOMPLEX(7, img)
INFO, e
; PV-WAVE prints: E DOUBLE COMPLEX = Array(4)
PM, e ; PV-WAVE prints the following:
; (      7.0000000,      6.0000000)
; (      7.0000000,      6.0000000)
; (      7.0000000,      6.0000000)
; (      7.0000000,      6.0000000)
See Also
For more information on using this function to extract data, see the PV‑WAVE Programmer’s Guide.