A high-performance general-purpose compute library

Transpose a matrix. More...

Functions

AFAPI array transpose (const array &in, const bool conjugate=false)
 C++ Interface to transpose a matrix. More...
 
AFAPI void transposeInPlace (array &in, const bool conjugate=false)
 C++ Interface to transpose a matrix in-place. More...
 
AFAPI af_err af_transpose (af_array *out, af_array in, const bool conjugate)
 C Interface to transpose a matrix. More...
 
AFAPI af_err af_transpose_inplace (af_array in, const bool conjugate)
 C Interface to transpose a matrix in-place. More...
 

Detailed Description

Transpose a matrix.

Reverse or permute the dimensions of an array; returns the modified array. For an array a with two dimensions, transpose(a) gives the matrix transpose. For an array with more than two dimensions, the first two dimensions are transposed across higher dimensions.

Set conjugate=true to perform the complex conjugate transpose of a matrix which interchanges the row and column index for each element, reflecting the elements across the main diagonal and negating the imaginary part of any complex numbers. For example, if b = transpose(a, true) and element a(2, 1) is (1, 2), then element b(1, 2) is (1, -2).

In-place versions perform matrix transposition by reordering the input, reducing memory footprint.

Examples:

// Create a, a 2x3 array
array a = iota(dim4(2, 3)); // a = [0, 2, 4
// 1, 3, 5]
// Create b, the transpose of a
array b = transpose(a); // b = [0, 1,
// 2, 3,
// 4, 5]

Function Documentation

◆ af_transpose()

AFAPI af_err af_transpose ( af_array out,
af_array  in,
const bool  conjugate 
)

C Interface to transpose a matrix.

Parameters
[out]outtranspose
[in]ininput array
[in]conjugateif true, conjugate transposition is performed
Returns
AF_SUCCESS, if function returns successfully, else an af_err code is given

◆ af_transpose_inplace()

AFAPI af_err af_transpose_inplace ( af_array  in,
const bool  conjugate 
)

C Interface to transpose a matrix in-place.

Parameters
[in,out]ininput array to be transposed in-place
[in]conjugateif true, conjugate transposition is performed
Returns
AF_SUCCESS, if function returns successfully, else an af_err code is given

◆ transpose()

AFAPI array transpose ( const array in,
const bool  conjugate = false 
)

C++ Interface to transpose a matrix.

Parameters
[in]ininput array
[in]conjugateif true, conjugate transposition is performed
Returns
transpose

◆ transposeInPlace()

AFAPI void transposeInPlace ( array in,
const bool  conjugate = false 
)

C++ Interface to transpose a matrix in-place.

Parameters
[in,out]ininput array to be transposed in-place
[in]conjugateif true, conjugate transposition is performed