nlcpy.transpose
- nlcpy.transpose(a, axes=None)[source]
Permutes the dimensions of an array.
- Parameters
- aarray_like
Input array.
- axeslist of ints, optional
By default, reverse the dimensions, otherwise permute the axes according to the values given.
- Returns
- pndarray
a with its axes permuted. A view is returned whenever possible.
See also
Note
Use transpose(a, argsort(axes)) to invert the transposition of tensors when using the axes keyword argument. Transposing a 1-D array returns an unchanged view of the original array.
Examples
>>> import nlcpy as vp >>> x = vp.arange(4).reshape((2,2)) >>> x array([[0, 1], [2, 3]]) >>> vp.transpose(x) array([[0, 2], [1, 3]]) >>> x = vp.ones((1, 2, 3)) >>> vp.transpose(x, (1, 0, 2)).shape (2, 1, 3)