Skip to content

dq.tensor

tensor(*args: QArrayLike) -> QArray

Returns the tensor product of multiple kets, bras, density matrices or operators.

The returned qarray shape is:

  • \((..., n, 1)\) with \(n=\prod_k n_k\) if all input qarrays are kets with shape \((..., n_k, 1)\),
  • \((..., 1, n)\) with \(n=\prod_k n_k\) if all input qarrays are bras with shape \((..., 1, n_k)\),
  • \((..., n, n)\) with \(n=\prod_k n_k\) if all input qarrays are density matrices or operators with shape \((..., n_k, n_k)\).

Parameters

  • *args (qarray-like of shape (..., n_k, 1) or (..., 1, n_k) or (..., n_k, n_k)) –

    Variable length argument list of kets, bras, density matrices or operators.

Returns

(qarray of shape (..., n, 1) or (..., 1, n) or (..., n, n)) Tensor product of the input qarrays.

Examples

>>> psi = dq.tensor(dq.fock(3, 0), dq.fock(4, 2), dq.fock(5, 1))
>>> psi.shape
(60, 1)