A high-performance general-purpose compute library

Create complex arrays. More...

Functions

AFAPI af_err af_cplx (af_array *out, const af_array in)
 C Interface to create a complex array from a single real array. More...
 
AFAPI af_err af_cplx2 (af_array *out, const af_array real, const af_array imag, const bool batch)
 C Interface to create a complex array from two real arrays. More...
 
AFAPI array complex (const array &in)
 C++ Interface to create a complex array from a single real array. More...
 
AFAPI array complex (const array &real_, const array &imag_)
 C++ Interface to create a complex array from two real arrays. More...
 
AFAPI array complex (const array &real_, const double imag_)
 C++ Interface to create a complex array from a single real array for the real component and a single scalar for each imaginary component. More...
 
AFAPI array complex (const double real_, const array &imag_)
 C++ Interface to create a complex array from a single scalar for each real component and a single real array for the imaginary component. More...
 

Detailed Description

Create complex arrays.

Complex arrays are created from any of the following four inputs:

  1. a single real array, returning zeros for the imaginary component. See array b in the example.
  2. two real arrays, one for the real component and one for the imaginary component. See array c in the example.
  3. a single real array for the real component and a single scalar for each imaginary component. See array d in the example.
  4. a single scalar for each real component and a single real array for the imaginary component. See array e in the example.

Examples:

// Create a, a 2x3 array
array a = iota(dim4(2, 3)); // a = [0, 2, 4,
// 1, 3, 5]
// Create b from a single real array, returning zeros for the imaginary
// component
array b = complex(a); // b = [(0, 0), (2, 0), (4, 0),
// (1, 0), (3, 0), (5, 0)]
// Create c from two real arrays, one for the real component and one for the
// imaginary component
array c = complex(a, a); // c = [(0, 0), (2, 2), (4, 4),
// (1, 1), (3, 3), (5, 5)]
// Create d from a single real array for the real component and a single
// scalar for each imaginary component
array d = complex(a, 2); // d = [(0, 2), (2, 2), (4, 2),
// (1, 2), (3, 2), (5, 2)]
// Create e from a single scalar for each real component and a single real
// array for the imaginary component
array e = complex(2, a); // e = [(2, 0), (2, 2), (2, 4),
// (2, 1), (2, 3), (2, 5)]

Function Documentation

◆ af_cplx()

AFAPI af_err af_cplx ( af_array out,
const af_array  in 
)

C Interface to create a complex array from a single real array.

Parameters
[out]outcomplex array
[in]inreal array
Returns
AF_SUCCESS, if function returns successfully, else an af_err code is given

◆ af_cplx2()

AFAPI af_err af_cplx2 ( af_array out,
const af_array  real,
const af_array  imag,
const bool  batch 
)

C Interface to create a complex array from two real arrays.

Parameters
[out]outcomplex array
[in]realreal array to be assigned as the real component of the returned complex array
[in]imagreal array to be assigned as the imaginary component of the returned complex array
[in]batchbatch mode
Returns
AF_SUCCESS, if function returns successfully, else an af_err code is given

◆ complex() [1/4]

AFAPI array complex ( const array in)

C++ Interface to create a complex array from a single real array.

Parameters
[in]ininput array
Returns
complex array

◆ complex() [2/4]

AFAPI array complex ( const array real_,
const array imag_ 
)

C++ Interface to create a complex array from two real arrays.

Parameters
[in]real_input array to be assigned as the real component of the returned complex array
[in]imag_input array to be assigned as the imaginary component of the returned complex array
Returns
complex array

◆ complex() [3/4]

AFAPI array complex ( const array real_,
const double  imag_ 
)

C++ Interface to create a complex array from a single real array for the real component and a single scalar for each imaginary component.

Parameters
[in]real_input array to be assigned as the real component of the returned complex array
[in]imag_single scalar to be assigned as the imaginary component of each value of the returned complex array
Returns
complex array

◆ complex() [4/4]

AFAPI array complex ( const double  real_,
const array imag_ 
)

C++ Interface to create a complex array from a single scalar for each real component and a single real array for the imaginary component.

Parameters
[in]real_single scalar to be assigned as the real component of each value of the returned complex array
[in]imag_input array to be assigned as the imaginary component of the returned complex array
Returns
complex array