If A
is a 2x2 array, what is an equivalent expression in python for permute(A, [3 2 1])
in MATLAB?
Thank you
You are looking for numpy.transpose
np.transpose( np.expand_dims(A, axis=2), (2, 1, 0) )
Since numpy
does not have trailing Singleton dimensions by default, you need to explicitly add it using np.expand_dims
Or else a shorthand for np.expand_dims(A, axis=2)
is A[:, :, None]
so
np.transpose(A[:, :, None], (2,1,0))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With