dpnp.permute_dims
- dpnp.permute_dims(a, axes=None)
Returns an array with axes transposed.
Note that
dpnp.permute_dims
is an alias ofdpnp.transpose
.For full documentation refer to
numpy.transpose
.- Parameters:
a ({dpnp.ndarray, usm_ndarray}) -- Input array.
axes ({None, tuple or list of ints}, optional) -- If specified, it must be a tuple or list which contains a permutation of [0, 1, ..., N-1] where N is the number of axes of a. The i'th axis of the returned array will correspond to the axis numbered
axes[i]
of the input. If not specified orNone
, defaults torange(a.ndim)[::-1]
, which reverses the order of the axes. Default:None
.
- Returns:
out -- a with its axes permuted. A view is returned whenever possible.
- Return type:
dpnp.ndarray
See also
dpnp.ndarray.transpose
Equivalent method.
dpnp.moveaxis
Move array axes to new positions.
dpnp.argsort
Returns the indices that would sort an array.
Examples
>>> import dpnp as np >>> a = np.array([[1, 2], [3, 4]]) >>> a array([[1, 2], [3, 4]]) >>> np.transpose(a) array([[1, 3], [2, 4]])
>>> a = np.array([1, 2, 3, 4]) >>> a array([1, 2, 3, 4]) >>> np.transpose(a) array([1, 2, 3, 4])
>>> a = np.ones((1, 2, 3)) >>> np.transpose(a, (1, 0, 2)).shape (2, 1, 3)
>>> a = np.ones((2, 3, 4, 5)) >>> np.transpose(a).shape (5, 4, 3, 2)