state#
Quantum states
Classes
|
A Bosoncic state of n modes, representing by a linear combination of Gaussian states. |
|
Single-mode cat state. |
|
A Fock state of n modes distributed between w nodes. |
|
A Fock state of n modes, including Fock basis states and Fock state tensors. |
|
Single-mode Fock state, representing by a linear combination of Gaussian states. |
|
Finite-energy single-mode GKP state. |
|
A Gaussian state of n modes, representing by covariance matrix and displacement vector. |
Functions
|
Combine multiple Bosonic states into a single state. |
|
Combine a list of 3D tensors for Bosonic states according to the dimension of direct sum. |
- class BosonicState(state: str | list = 'vac', nmode: int | None = None, cutoff: int | None = None)[source]#
Bases:
ModuleA Bosoncic state of n modes, representing by a linear combination of Gaussian states.
- Parameters:
state (str | list) – The Bosoncic state. It can be a vacuum state with
'vac', or arbitrary linear combinations of Gaussian states with[cov, mean, weight].cov,``mean`` andweightare the covariance matrices, the displacement vectors and the weights of the Gaussian states, respectively. Usexxppconvention and \(\hbar=2\) by default. Default:'vac'nmode (int | None) – The number of modes in the state. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
None
- marginal(wire: int, phi: float = 0.0, xrange: int | list = 10, npoints: int = 100, plot: bool = True, k: int = 0)[source]#
Get the discretized marginal distribution of the specified mode along \(x\cos\phi + p\sin\phi\).
- Parameters:
wire (int) – The marginal function for given wire.
phi (float) – The angle used to compute the linear combination of quadratures. Default: 0
xrange (int | list) – The range of quadrature. Default: 10
npoints (int) – The number of discretization points for quadrature. Default: 100
plot (bool) – Whether to plot the marginal function. Default:
Truek (int) – The index of the marginal function within the batch to plot. Default: 0
- tensor_product(state: BosonicState) BosonicState[source]#
Get the tensor product of two Bosonic states.
- wigner(wire: int, xrange: int | list = 10, prange: int | list = 10, npoints: int | list = 100, plot: bool = True, k: int = 0, normalize: bool = True)[source]#
Get the discretized Wigner function of the specified mode.
- Parameters:
wire (int) – The Wigner function for the given wire.
xrange (int | list) – The range of quadrature x. Default: 10
prange (int | list) – The range of quadrature p. Default: 10
npoints (int | list) – The number of discretization points for quadratures. Default: 100
plot (bool) – Whether to plot the Wigner function. Default:
Truek (int) – The index of the Wigner function within the batch to plot. Default: 0
normalize (bool) – Whether to normalize the Wigner function. Default:
True
- class CatState(r: Any = None, theta: Any = None, p: int = 1, cutoff: int | None = None)[source]#
Bases:
BosonicStateSingle-mode cat state.
The cat state is a superposition of coherent states.
See https://arxiv.org/abs/2103.05530 Section IV B.
- Parameters:
r (Any) – Displacement magnitude \(|r|\). Default:
Nonetheta (Any) – Displacement angle \(\theta\). Default:
Nonep (int) – Parity, where \(\theta=p\pi\).
p=0corresponds to an even cat state, andp=1an odd cat state. Default: 1cutoff (int | None) – The Fock space truncation. Default:
None
- class DistributedFockState(state: Any, nmode: int | None = None, cutoff: int | None = None)[source]#
Bases:
ModuleA Fock state of n modes distributed between w nodes.
- Parameters:
state (Any) – The Fock state. It can be a vacuum state with
'vac'or'zeros'. It can be a Fock basis state, e.g.,[1,0,0], or a Fock state tensor, e.g.,[(1/2**0.5, [1,0]), (1/2**0.5, [0,1])].nmode (int | None) – The number of modes in the state. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
None
- class FockState(state: Any, nmode: int | None = None, cutoff: int | None = None, basis: bool = True, den_mat: bool = False)[source]#
Bases:
ModuleA Fock state of n modes, including Fock basis states and Fock state tensors.
- Parameters:
state (Any) – The Fock state. It can be a vacuum state with
'vac'or'zeros'. It can be a Fock basis state, e.g.,[1,0,0], or a Fock state tensor, e.g.,[(1/2**0.5, [1,0]), (1/2**0.5, [0,1])]. Alternatively, it can be a tensor representation.nmode (int | None) – The number of modes in the state. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Nonebasis (bool) – Whether the state is a Fock basis state or not. Default:
Trueden_mat (bool) – Whether to use density matrix representation. Only valid for Fock state tensor. Default:
False
- wigner(wire: int, xrange: int | list = 10, prange: int | list = 10, npoints: int | list = 100, plot: bool = True, k: int = 0)[source]#
Get the discretized Wigner function of the specified mode.
- Parameters:
wire (int) – The Wigner function for the given wire.
xrange (int | list) – The range of quadrature x. Default: 10
prange (int | list) – The range of quadrature p. Default: 10
npoints (int | list) – The number of discretization points for quadratures. Default: 100
plot (bool) – Whether to plot the Wigner function. Default:
Truek (int) – The index of the Wigner function within the batch to plot. Default: 0
- class FockStateBosonic(n: int, r: Any = 0.05, cutoff: int | None = None)[source]#
Bases:
BosonicStateSingle-mode Fock state, representing by a linear combination of Gaussian states.
See https://arxiv.org/abs/2103.05530 Section IV C.
- Parameters:
n (int) – Particle number.
r (Any) – The quality parameter for the approximation. Default: 0.05
cutoff (int | None) – The Fock space truncation. Default:
None
- class GKPState(theta: Any = None, phi: Any = None, amp_cutoff: float = 0.1, epsilon: float = 0.05, cutoff: int | None = None)[source]#
Bases:
BosonicStateFinite-energy single-mode GKP state.
Using GKP states to encode qubits, with the qubit state defined by: \(\ket{\psi}_{gkp} = \cos\frac{\theta}{2}\ket{0}_{gkp} + e^{-i\phi}\sin\frac{\theta}{2}\ket{1}_{gkp}\)
See https://arxiv.org/abs/2103.05530 Section IV A.
- Parameters:
theta (Any) – angle \(\theta\) in Bloch sphere. Default:
Nonephi (Any) – angle \(\phi\) in Bloch sphere. Default:
Noneamp_cutoff (float) – The amplitude threshold for keeping the terms. Default: 0.1
epsilon (float) – The finite energy damping parameter. Default: 0.05
cutoff (int | None) – The Fock space truncation. Default:
None
- class GaussianState(state: str | list = 'vac', nmode: int | None = None, cutoff: int | None = None)[source]#
Bases:
ModuleA Gaussian state of n modes, representing by covariance matrix and displacement vector.
- Parameters:
state (str | list) – The Gaussian state. It can be a vacuum state with
'vac', or arbitrary Gaussian state with[cov, mean].covandmeanare the covariance matrix and the displacement vector of the Gaussian state, respectively. Usexxppconvention and \(\hbar=2\) by default. Default:'vac'nmode (int | None) – The number of modes in the state. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
None
- check_purity(rtol=1e-05, atol=1e-08)[source]#
Check if the Gaussian state is pure state
See https://arxiv.org/pdf/quant-ph/0503237.pdf Eq.(2.5)
- wigner(wire: int, xrange: int | list = 10, prange: int | list = 10, npoints: int | list = 100, plot: bool = True, k: int = 0, normalize: bool = True)[source]#
Get the discretized Wigner function of the specified mode.
- Parameters:
wire (int) – The Wigner function for the given wire.
xrange (int | list) – The range of quadrature x. Default: 10
prange (int | list) – The range of quadrature p. Default: 10
npoints (int | list) – The number of discretization points for quadratures. Default: 100
plot (bool) – Whether to plot the Wigner function. Default:
Truek (int) – The index of the Wigner function within the batch to plot. Default: 0
normalize (bool) – Whether to normalize the Wigner function. Default:
True
- combine_bosonic_states(states: list[BosonicState], cutoff: int | None = None) BosonicState[source]#
Combine multiple Bosonic states into a single state.
- Parameters:
states (list[BosonicState]) – List of Bosonic states to combine.
cutoff (int | None) – The Fock space truncation. If
None, the cutoff of the first state is used. Default:None
- combine_tensors(tensors: list[Tensor], ndim_ds: int = 2) Tensor[source]#
Combine a list of 3D tensors for Bosonic states according to the dimension of direct sum.
- Parameters:
tensors (list[Tensor]) – The list of 3D tensors to combine.
ndim_ds (int) – The dimension of direct sum. Use 1 for direct sum along rows, or use 2 for direct sum along both rows and columns. Default: 2