state#

Quantum states

Classes

BosonicState([state, nmode, cutoff])

A Bosoncic state of n modes, representing by a linear combination of Gaussian states.

CatState([r, theta, p, cutoff])

Single-mode cat state.

DistributedFockState(state[, nmode, cutoff])

A Fock state of n modes distributed between w nodes.

FockState(state[, nmode, cutoff, basis, den_mat])

A Fock state of n modes, including Fock basis states and Fock state tensors.

FockStateBosonic(n[, r, cutoff])

Single-mode Fock state, representing by a linear combination of Gaussian states.

GKPState([theta, phi, amp_cutoff, epsilon, ...])

Finite-energy single-mode GKP state.

GaussianState([state, nmode, cutoff])

A Gaussian state of n modes, representing by covariance matrix and displacement vector.

Functions

combine_bosonic_states(states[, cutoff])

Combine multiple Bosonic states into a single state.

combine_tensors(tensors[, ndim_ds])

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: Module

A 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`` and weight are the covariance matrices, the displacement vectors and the weights of the Gaussian states, respectively. Use xxpp convention and \(\hbar=2\) by default. Default: 'vac'

  • nmode (int | None) – The number of modes in the state. Default: None

  • cutoff (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: True

  • k (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: True

  • k (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: BosonicState

Single-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: None

  • theta (Any) – Displacement angle \(\theta\). Default: None

  • p (int) – Parity, where \(\theta=p\pi\). p=0 corresponds to an even cat state, and p=1 an odd cat state. Default: 1

  • cutoff (int | None) – The Fock space truncation. Default: None

class DistributedFockState(state: Any, nmode: int | None = None, cutoff: int | None = None)[source]#

Bases: Module

A 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: None

  • cutoff (int | None) – The Fock space truncation. Default: None

reset()[source]#

Reset the state.

class FockState(state: Any, nmode: int | None = None, cutoff: int | None = None, basis: bool = True, den_mat: bool = False)[source]#

Bases: Module

A 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: None

  • cutoff (int | None) – The Fock space truncation. Default: None

  • basis (bool) – Whether the state is a Fock basis state or not. Default: True

  • den_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: True

  • k (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: BosonicState

Single-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: BosonicState

Finite-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: None

  • phi (Any) – angle \(\phi\) in Bloch sphere. Default: None

  • amp_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: Module

A 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]. cov and mean are the covariance matrix and the displacement vector of the Gaussian state, respectively. Use xxpp convention and \(\hbar=2\) by default. Default: 'vac'

  • nmode (int | None) – The number of modes in the state. Default: None

  • cutoff (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: True

  • k (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