matrix_transpose — Python array API standard 2024.12 documentation (original) (raw)

matrix_transpose(x: array, /) → array

Transposes a matrix (or a stack of matrices) x.

Parameters:

x (array) – input array having shape (..., M, N) and whose innermost two dimensions form MxN matrices.

Returns:

out (array) – an array containing the transpose for each matrix and having shape (..., N, M). The returned array must have the same data type as x.