COMPLEX Function
The COMPLEX function does the following:
Converts an expression to complex data type.
Extracts data from an expression and places it in a complex scalar or array.
enabled.
Usage
This form is used to convert data.
result = COMPLEX(real[, imaginary])
This form is used to extract data.
result = COMPLEX(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 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
COMPLEX 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 single-precision floating-point.
note | If three or more parameters are supplied, COMPLEX extracts fields of data from expr, rather than performing conversion. |
Example
real = INDGEN(5)
b = COMPLEX(real)
INFO, b
; PV-WAVE prints: B COMPLEX = Array(5)
PM, b
; PV-WAVE prints the following:
; ( 0.00000, 0.00000)
; ( 1.00000, 0.00000)
; ( 2.00000, 0.00000)
; ( 3.00000, 0.00000)
; ( 4.00000, 0.00000)
img = INTARR(5) + 6
c = COMPLEX(real, img)
INFO, c
; PV-WAVE prints: C COMPLEX = Array(5)
PM, c
; PV-WAVE prints the following:
; ( 0.00000, 6.00000)
; ( 1.00000, 6.00000)
; ( 2.00000, 6.00000)
; ( 3.00000, 6.00000)
; ( 4.00000, 6.00000)
d = COMPLEX(real, 7)
INFO, d
; PV-WAVE prints: D COMPLEX = Array(5)
PM, d
; PV-WAVE prints the following:
; ( 0.00000, 7.00000)
; ( 1.00000, 7.00000)
; ( 2.00000, 7.00000)
; ( 3.00000, 7.00000)
; ( 4.00000, 7.00000)
e = COMPLEX(7, img)
INFO, e
; PV-WAVE prints: E COMPLEX = Array(5)
PM, e
; PV-WAVE prints the following:
; ( 7.00000, 6.00000)
; ( 7.00000, 6.00000)
; ( 7.00000, 6.00000)
; ( 7.00000, 6.00000)
; ( 7.00000, 6.00000)
See Also
For more information on using this function to extract data, see the PV‑WAVE Programmer’s Guide.
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.