dpnp.matrix_transpose

dpnp.matrix_transpose(x, /)[source]

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

For full documentation refer to numpy.matrix_transpose.

Parameters:

x ((..., M, N) {dpnp.ndarray, usm_ndarray}) -- Input array with x.ndim >= 2 and whose two innermost dimensions form MxN matrices.

Returns:

out -- An array containing the transpose for each matrix and having shape (..., N, M).

Return type:

dpnp.ndarray

See also

dpnp.transpose

Returns an array with axes transposed.

dpnp.linalg.matrix_transpose

Equivalent function.

dpnp.ndarray.mT

Equivalent method.

Examples

>>> import dpnp as np
>>> a = np.array([[1, 2], [3, 4]])
>>> np.matrix_transpose(a)
array([[1, 3],
       [2, 4]])
>>> b = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
>>> np.matrix_transpose(b)
array([[[1, 3],
        [2, 4]],
       [[5, 7],
        [6, 8]]])