A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Functions
transpose
ArrayFire Functions | ArrayFire Functions by Category » Linear Algebra » BLAS operations | ArrayFire Functions by Category » Functions to create and modify Arrays » Move and Reorder array content

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

## 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] | out | transpose
  [in] | in | input array
  [in] | conjugate | if 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] | in | input array to be transposed in-place
  [in] | conjugate | if 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] | in | input array
  [in] | conjugate | if 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] | in | input array to be transposed in-place
  [in] | conjugate | if true, conjugate transposition is performed