dq.moveaxis
moveaxis(
x: QArrayLike, source: int | Sequence[int], destination: int | Sequence[int]
) -> QArray
Move batch axes of a qarray to new positions.
Warning
Only batch axes can be moved. 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.
-
source–Original positions of the axes to move.
-
destination–Destination positions for each moved axis.
Returns:
-
(qarray of shape (..., n, m))
–
Qarray with moved axes.
See also
- dq.swapaxes(): interchange two axes of a qarray.
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.moveaxis(x, 0, 1).shape
(3, 2, 3, 1)