The DCOMPLEX function returns double-precision complex scalars or arrays 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. Parameters are first converted to double-precision floating-point. If either or both of the parameters are arrays, the result is an array, following the same rules as standard IDL operators. If three parameters are supplied, DCOMPLEX extracts fields of data from *Expression*.

## Examples

Create a complex array from two integer arrays

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 = DCOMPLEX(A, B)

; See how the two arrays were combined:

PRINT, C

IDL prints:

( 1.0000000, 4.0000000)( 2.0000000, 5.0000000)

( 3.0000000, 6.0000000)

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

; Print the real part of the complex array C:

PRINT, 'Real Part: ', REAL_PART(C)

; Print the imaginary part of the complex array C:

PRINT, 'Imaginary Part: ', IMAGINARY(C)

IDL prints:

Real Part: 1.0000000 2.0000000 3.0000000

Imaginary Part: 4.0000000 5.0000000 6.0000000

## Syntax

*Result* = DCOMPLEX( *Real* [, *Imaginary*] )

or

*Result* = DCOMPLEX( *Expression*, *Offset, D*_{1 }*[*, ..., *D*_{8}*]* )

## Return Value

Returns a double-precision complex value or an 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*.

Returns double-precision complex scalars or arrays given one or two scalars or arrays.

## 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.

### D_{i}

When extracting fields of data, the *D*_{i} arguments specify the dimensions of the result. If no dimension arguments are given, the result is taken to be scalar.

The *D _{i}* 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

### 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

4.0 |
Introduced |

## See Also

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

## Notes

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