IDL

COMPLEX

COMPLEX

The COMPLEX function returns complex scalars or arrays given one or two scalars or arrays.

Examples


Create a complex array from two integer arrays by entering the following commands:

; Create the first integer array:
A = [1,2,3]
; Create the second integer array:
B = [4,5,6]
; Make A the real parts and B the imaginary parts of the new
; complex array:
C = COMPLEX(A, B)
; See how the two arrays were combined:
PRINT, C

IDL prints:

( 1.00000, 4.00000)( 2.00000, 5.00000)
( 3.00000, 6.00000)

The real and imaginary parts of the complex array can be extracted as follows:

; Print the real and imaginary parts of the complex array C:
PRINT, 'Real Part:     ', REAL_PART(C)
PRINT, 'Imaginary Part: ', IMAGINARY(C)

IDL prints:

Real Part:         1.00000   2.00000   3.00000
Imaginary Part:    4.00000   5.00000   6.00000

Syntax


Result = COMPLEX( Real[Imaginary] [, /DOUBLE])

or

Result = COMPLEX(Expression, Offset, D1[, ..., D8] [, /DOUBLE])

Return Value


Returns a single-precision complex value or array given one or two scalars or arrays. If only one parameter is supplied, the imaginary part of the result is zero, otherwise it is set to the value of the Imaginary parameter. If either or both of the parameters are arrays, the result is an array, following the same rules as standard IDL operators. If three or more parameters are supplied, COMPLEX extracts fields of data from Expression.

Arguments


Real

Scalar or array to be used as the real part of the complex result.

Imaginary

Scalar or array to be used as the imaginary part of the complex result.

Expression

The expression from which data is to be extracted.

Offset

Offset from beginning of the Expression data area. Specifying this argument allows fields of data extracted from Expression to be treated as complex data.

Di

When extracting fields of data, the Di arguments specify the dimensions of the result. If no dimension arguments are given, the result is taken to be scalar.

The Di arguments can be either an array or a series of scalar expressions specifying the dimensions of the result. If a single argument is specified, it can be either a scalar expression or an array of up to eight elements. If multiple arguments are specified, they must all be scalar expressions. Up to eight dimensions can be specified.

When converting from a string argument, it is possible that the string does not contain a valid floating-point value and no conversion is possible. The default action in such cases is to print a warning message and return 0. The ON_IOERROR procedure can be used to establish a statement to be jumped to in case of such errors.

Keywords


DOUBLE

Set this keyword to return a double-precision complex result. Setting this keyword is equivalent to using the DCOMPLEX function, and is provided as a programming convenience.

Thread Pool Keywords

This routine is written to make use of IDL’s thread pool, which can increase execution speed on systems with multiple CPUs. The values stored in the !CPU system variable control whether IDL uses the thread pool for a given computation. In addition, you can use the thread pool keywords TPOOL_MAX_ELTS, TPOOL_MIN_ELTS, and TPOOL_NOTHREAD to override the defaults established by !CPU for a single invocation of this routine. See Thread Pool Keywords for details.

Version History


Original

Introduced

See Also


BYTE, CONJ, DCOMPLEX, DOUBLE, FIX, FLOAT, IMAGINARY, LONG, LONG64, REAL_PART, STRING, UINT, ULONG, ULONG64



Notes


This page has no user notes yet. Be the first one!


This information is not subject to the controls of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However, it may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
© 2014 Exelis Visual Information Solutions