Do more. Code less. Free software for GPU computing.
<scroll to top>
Functions

Array manipulation (transpose, join, tile, shift, ...)

Basics

Functions

array T () const
 Transpose matrix or vector.
array H () const
 Conjugate transpose (i.e.
array lower (const array &input, int diagonal=0)
 Extract lower triangular matrix.
array upper (const array &input, int diagonal=0)
 Extract upper triangular matrix.
array diagonal (const array &input, int diag=0)
 Extract or form diagonal matrix.
array join (const array &A, const array &B, int dim=0)
 Join two arrays along dimension dim.
array newdims (const array &input, const dim4 &newdims)
 Adjust the dimensions of an N-D array (fast).
array newdims (const array &input, int dim0, int dim1=1, int dim2=1, int dim3=1)
 Adjust the dimensions of an N-D array (fast).
array flipv (const array &in)
 Flip matrix vertically.
array fliph (const array &in)
 Flip matrix vertically.
array flipdim (const array &in, unsigned dim)
 Flip array along a given dimension.
array tile (const array &A, unsigned d0, unsigned d1=1, unsigned d2=1)
 tile (repeat) array along specified dimensions
array tile (const array &A, const dim4 &dims)
 tile (repeat) array along specified dimensions
array flat (const array &A)
 Flatten an array into column vector.
array shift (const array &in, int dim0=0, int dim1=0, int dim2=0, int dim3=0)
 Shift the values of an array around dimension (wrap around).
array shift (const array &in, const array &shift)
 Shift the values of an array around dimension (wrap around).
array reorder (const array &in, int dim0=-1, int dim1=-1, int dim2=-1, int dim3=-1)
 Reorder dimensions of array.

Function Documentation

array T ( ) const [inherited]

Transpose matrix or vector.

       array X = randn(2,3);
       print(X);
       print(X.T());
X =
        0.5434    -1.4913     0.1374
       -0.7168     1.4805    -1.2208
X.T() =
        0.5434    -0.7168
       -1.4913     1.4805
        0.1374    -1.2208
Examples:
examples/fdtd/fdtd.cpp, examples/image/image_demo.cpp, and examples/misc/integer.cpp.
array H ( ) const [inherited]

Conjugate transpose (i.e.

1+2i becomes 1-2i). Real arrays are simply transposed.

       array X = randn(2,3,c32);
       print(X);
       print(X.H());
X =
        0.2925 -    0.7184i    2.5470 -    0.0034i    0.1290 +    0.3728i
        0.1000 -    0.3932i    0.0083 -    0.2510i    1.0822 -    0.6650i

X.H() =
        0.2925 +    0.7184i    0.1000 +    0.3932i
        2.5470 +    0.0034i    0.0083 +    0.2510i
        0.1290 -    0.3728i    1.0822 +    0.6650i
array af::lower ( const array &  input,
int  diagonal = 0 
)

Extract lower triangular matrix.

Parameters:
[in]inputmatrix
[in]diagonalto include in extraction: diagonal==0 is the center diagonal (default), diagonal>0 is above, and diagonal<0 is below.
Returns:
lower triangular part of the matrix
array af::upper ( const array &  input,
int  diagonal = 0 
)

Extract upper triangular matrix.

Parameters:
[in]inputmatrix
[in]diagonalto include in extraction: diagonal==0 is the center diagonal (default), diagonal>0 is above, and diagonal<0 is below.
Returns:
lower triangular part of the matrix
array af::diagonal ( const array &  input,
int  diag = 0 
)

Extract or form diagonal matrix.

Parameters:
[in]inputif vector then produce diagonal matrix, if matrix then extract diagonal vector
[in]diagwhich diagonal to extract or form: diag==0 is the center diagonal (default), diag>0 is above, and diag<0 is below.
Returns:
diagonal matrix formed from vector, or vector extracted from diagonal of a matrix
array af::join ( const array &  A,
const array &  B,
int  dim = 0 
)

Join two arrays along dimension dim.

Parameters:
[in]A
[in]B
[in]dimalong which to join
Returns:
composite array
   array a = ones(2,3), b = zeros(2,3);
   print(join(a,b,0));
   print(join(a,b,1));
join(a,b,0) =
        1.0000     1.0000     1.0000
        1.0000     1.0000     1.0000
        0.0000     0.0000     0.0000
        0.0000     0.0000     0.0000

join(a,b,1) =
        1.0000     1.0000     1.0000     0.0000     0.0000     0.0000
        1.0000     1.0000     1.0000     0.0000     0.0000     0.0000
array af::newdims ( const array &  input,
const dim4 &  newdims 
)

Adjust the dimensions of an N-D array (fast).

Parameters:
[in]input
[in]newdimstotal number of elements must not change.
Returns:
same underlying array data with different dimensions
Examples:
examples/image/image_demo.cpp.
array af::newdims ( const array &  input,
int  dim0,
int  dim1 = 1,
int  dim2 = 1,
int  dim3 = 1 
)

Adjust the dimensions of an N-D array (fast).

Total number of elements must not change.

Parameters:
[in]input
[in]dim0first dimension
[in]dim1second dimension
[in]dim2third dimension
[in]dim3fourth dimension
Returns:
same underlying array data with different dimensions
array af::flipv ( const array &  in)

Flip matrix vertically.

Returns:
matrix with the elements of each column reversed.
Examples:
examples/misc/integer.cpp.
array af::fliph ( const array &  in)

Flip matrix vertically.

Returns:
matrix with the elements of each row reversed.
Examples:
examples/misc/integer.cpp.
array af::flipdim ( const array &  in,
unsigned  dim 
)

Flip array along a given dimension.

Parameters:
[in]in
[in]dimdimension along which to flip
Returns:
array with the elements along the specified dimension reversed
array af::tile ( const array &  A,
unsigned  d0,
unsigned  d1 = 1,
unsigned  d2 = 1 
)

tile (repeat) array along specified dimensions

Parameters:
[in]A
[in]d0repetitions along first dimension (1 indicates no repeat)
[in]d1repetitions along second dimension (default: 1, no repeat)
[in]d2repetitions along third dimension (default: 1, no repeat)
Returns:
A repeated according to specified repetitions
Examples:
examples/blackscholes/blackscholes.cpp, and examples/fdtd/fdtd.cpp.
array af::tile ( const array &  A,
const dim4 &  dims 
)

tile (repeat) array along specified dimensions

Parameters:
[in]A
[in]dimsspecifications of number of times to repeat
Returns:
A repeated acc
A repeated according to specified repetitions
array af::flat ( const array &  A)

Flatten an array into column vector.

No work is done (data is simply shared) so this is effectively a noop.

Parameters:
[in]A
Returns:
column vector with same elements as original
Examples:
examples/image/gfor_hist_demo.cpp.
array af::shift ( const array &  in,
int  dim0 = 0,
int  dim1 = 0,
int  dim2 = 0,
int  dim3 = 0 
)

Shift the values of an array around dimension (wrap around).

Parameters:
[in]in
[in]dim0Shift along first dimension
[in]dim1Shift along second dimension
[in]dim2Shift along third dimension
[in]dim3Shift along fourth dimension
Returns:
shifted version of array
array af::shift ( const array &  in,
const array &  shift 
)

Shift the values of an array around dimension (wrap around).

Parameters:
[in]in
[in]shiftinteger array (s32 prefered) indicating shifts
Returns:
shifted version of array
array af::reorder ( const array &  in,
int  dim0 = -1,
int  dim1 = -1,
int  dim2 = -1,
int  dim3 = -1 
)

Reorder dimensions of array.

Parameters:
[in]in
[in]dim0first reordering dimension (-1 indicates leave in place, default)
[in]dim1second reordering dimension (-1 indicates leave in place, default)
[in]dim2third reordering dimension (-1 indicates leave in place, default)
[in]dim3fourth reordering dimension (-1 indicates leave in place, default)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines