# Preparations#

class Vacuum#

Prepare the system in a vacuum state.

Example usage:

with pq.Program() as program:
pq.Q() | pq.Vacuum()
...

Note

This operation can only be used for all modes and is only practical to be used at the beginning of a program declaration.

class Mean(mean: numpy.ndarray)#

Set the first canonical moment of the state.

Example usage:

with pq.Program() as program:
pq.Q() | pq.Mean(
mean=np.array(...)
)
...

Can only be applied to the following states: GaussianState.

Note

The mean vector is dependent on $$\hbar$$, but the value of $$\hbar$$ is specified later when executed by a simulator. The parameter mean should be specified keeping in mind that it will automatically be scaled with $$\hbar$$ during execution.

Parameters

mean (numpy.ndarray) – The vector of the first canonical moments in xpxp-ordering.

class Covariance(cov: numpy.ndarray)#

Sets the covariance matrix of the state.

Example usage:

with pq.Program() as program:
pq.Q() | pq.Covariance(
cov=np.array(...)
)
...

Can only be applied to the following states: GaussianState.

Note

The covariance matrix is dependent on $$\hbar$$, but the value of $$\hbar$$ is specified later when executed by a simulator. The parameter cov should be specified keeping in mind that it will automatically be scaled with $$\hbar$$ during execution.

Parameters

cov (numpy.ndarray) – The covariance matrix in xpxp-ordering.

class Thermal(mean_photon_numbers: )#

Prepares a thermal state.

Example usage:

with pq.Program() as program:
pq.Q(0, 1) | pq.Thermal([0.5, 1.5])
...

The thermal state is defined by

$\rho = \sum_{\vec{n} = 0}^\infty \frac{\overline{n}^{\vec{n}}}{(1 + \overline{n})^{\vec{n} + 1}} | \vec{n} \rangle \langle \vec{n} |,$

where $$\overline{n} \in \mathbb{R}^d$$ is the vector of mean photon numbers. The power on vectors is defined as

$\vec{a}^{\vec{b}} = \prod_{i=1}^d a_i^{b_i}$

In terms of Gaussian states, the mean vector and covariance matrix is

$\begin{split}\mu &= 0_{2d} \\ \sigma &= \hbar ( 2 \operatorname{\textit{diag}}(\operatorname{\textit{repeat}} (\overline{n}, 2)) + I_{2d \times 2d} )\end{split}$

Can only be applied to the following states: GaussianState.

Parameters

mean_photon_numbers (Iterable[float]) – The sequence of mean photon numbers.

Raises

InvalidParameter – If the mean photon numbers are not positive real numbers.

class StateVector(occupation_numbers: , coefficient: complex = 1.0)#

State preparation with Fock basis vectors.

Example usage:

with pq.Program() as program:
pq.Q() | (
0.3 * pq.StateVector([2, 1, 0, 3])
+ 0.2 * pq.StateVector([1, 1, 2, 3])
...
)
...

Can only be applied to the following states: PureFockState.

Parameters
• occupation_numbers (Iterable[int]) – The occupation numbers.

• coefficient (complex, optional) – The coefficient of the occupation number. Defaults to $$1.0$$.

Raises

InvalidState – If the specified occupation numbers are not all natural numbers.

class DensityMatrix(ket: , bra: , coefficient: complex = 1.0)#

State preparation with density matrix elements.

Example usage:

with pq.Program() as program:
pq.Q() | (
0.2 * pq.DensityMatrix(ket=(1, 0, 1), bra=(2, 1, 0))
+ 0.3 * pq.DensityMatrix(ket=(2, 0, 1), bra=(0, 1, 1))
...
)
...

Note

This only creates one matrix element.

Can only be applied to the following states: FockState.

Parameters
• bra (Iterable[int]) – The bra vector.

• ket (Iterable[int]) – The ket vector.

• coefficient (complex, optional) – The coefficient of the operator defined by the “bra” and “ket” vectors. Defaults to $$1.0$$.

Raises

InvalidState – If the specified “bra” or “ket” vectors are not all natural numbers.

class Create#

Create a particle on a mode.

This instruction essentially applies a creation operator on the specified mode, then normalizes the state.

Example usage:

with pq.Program() as program:
pq.Q(1) | pq.Create()
pq.Q(2) | pq.Create()
...

Can only be applied to the following states: FockState, PureFockState.

class Annihilate#

Annihilate a particle on a mode.

This instruction essentially applies an annihilation operator on the specified mode, then normalizes the state.

Example usage:

with pq.Program() as program:
...
pq.Q(0) | pq.Annihilate()
...

Can only be applied to the following states: FockState, PureFockState.