dq.expand_dims
expand_dims(x: QArrayLike, axis: int | Sequence[int]) -> QArray
Expand the shape of a qarray by inserting new batch axes.
Warning
New axes can only be inserted among the batch axes, not among the final two matrix dimensions.
Parameters:
-
x(qarray-like of shape (..., n, m)) –Qarray-like object.
-
axis–Axis or axes where new dimensions are inserted.
Returns:
-
(qarray of shape (..., n, m))
–
Qarray with additional dimensions.
Examples:
>>> psis = dq.stack([dq.fock(3, 0), dq.fock(3, 1), dq.fock(3, 2)])
>>> psis.shape
(3, 3, 1)
>>> dq.expand_dims(psis, 0).shape
(1, 3, 3, 1)