bundles / scipy 1.18.0 / scipy / sparse / _construct / matrix_transpose
function
scipy.sparse._construct:matrix_transpose
source: /scipy/sparse/_construct.py:208
Signature
def matrix_transpose(A)Summary
Return the matrix transpose of A.
Parameters
A: sparse arrayInput array.
Returns
: sparse arrayThe matrix transpose of
A.
Notes
This is equivalent to A.T for 2-D arrays, and interprets greater dimensional A as a stack of 2-D arrays on which to perform the transpose.
Examples
import numpy as np from scipy.sparse import coo_array, matrix_transpose data = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]) array = coo_array(data) array.T.toarray() matrix_transpose(array).toarray()✓
array([[[1, 3],
[2, 4]],
[[5, 7],
[6, 8]]])
See also
- coo_array.T
full transposition reversing all dimensions
- coo_array.mT
equivalent attribute
- numpy.matrix_transpose
equivalent function in NumPy
Aliases
scipy.sparse.matrix_transpose