dq.fock
fock(dim: int | tuple[int, ...], number: ArrayLike) -> QArray
Returns the ket of a Fock state or a tensor product of Fock states.
Parameters
-
dim
–
Hilbert space dimension of each mode.
-
number
(array-like of shape (...) or (..., len(dim)))
–
Fock state number for each mode, of integer type. If
dim
is a tuple, the last dimension ofnumber
should match the length ofdim
.
Returns
(qarray of shape (..., n, 1)) Ket of the Fock state or tensor product of Fock states, with n = prod(dims).
Examples
Single-mode Fock state \(\ket{1}\):
>>> dq.fock(3, 1)
QArray: shape=(3, 1), dims=(3,), dtype=complex64, layout=dense
[[0.+0.j]
[1.+0.j]
[0.+0.j]]
Batched single-mode Fock states \(\{\ket{0}\!, \ket{1}\!, \ket{2}\}\):
>>> dq.fock(3, [0, 1, 2])
QArray: shape=(3, 3, 1), dims=(3,), dtype=complex64, layout=dense
[[[1.+0.j]
[0.+0.j]
[0.+0.j]]
[[0.+0.j]
[1.+0.j]
[0.+0.j]]
[[0.+0.j]
[0.+0.j]
[1.+0.j]]]
Multi-mode Fock state \(\ket{1,0}\):
>>> dq.fock((3, 2), (1, 0))
QArray: shape=(6, 1), dims=(3, 2), dtype=complex64, layout=dense
[[0.+0.j]
[0.+0.j]
[1.+0.j]
[0.+0.j]
[0.+0.j]
[0.+0.j]]
Batched multi-mode Fock states \(\{\ket{0,0}\!, \ket{0,1}\!, \ket{1,1}\!, \ket{2,0}\}\):
>>> number = [(0, 0), (0, 1), (1, 1), (2, 0)]
>>> dq.fock((3, 2), number).shape
(4, 6, 1)