dq.swapaxes
swapaxes(x: QArrayLike, axis1: int, axis2: int) -> QArray
Interchange two batch axes of a qarray.
Warning
Only batch axes can be swapped. The final two axes are the matrix dimensions,
use x.mT to transpose those.
Parameters:
-
x(qarray-like of shape (..., n, m)) –Qarray-like object.
-
axis1–First axis.
-
axis2–Second axis.
Returns:
-
(qarray of shape (..., n, m))
–
Qarray with axes
axis1andaxis2interchanged.
See also
- dq.moveaxis(): move axes of a qarray to new positions.
Examples:
>>> psis = dq.stack([dq.fock(3, 0), dq.fock(3, 1), dq.fock(3, 2)])
>>> x = dq.stack([psis, psis])
>>> x.shape
(2, 3, 3, 1)
>>> dq.swapaxes(x, 0, 1).shape
(3, 2, 3, 1)