FockStateProjector

Module: pennylane

class FockStateProjector(n, wires)[source]

The number state observable \(\ket{n}\bra{n}\).

Represents the non-Gaussian number state observable

\[\ket{n}\bra{n} = \ket{n_0, n_1, \dots, n_P}\bra{n_0, n_1, \dots, n_P}\]

where \(n_i\) is the occupation number of the \(i\) th wire.

The expectation of this observable is

\[E[\ket{n}\bra{n}] = \text{Tr}(\ket{n}\bra{n}\rho) = \text{Tr}(\braketT{n}{\rho}{n}) = \braketT{n}{\rho}{n}\]

corresponding to the probability of measuring the quantum state in the state \(\ket{n}=\ket{n_0, n_1, \dots, n_P}\).

Note

If expval(FockStateProjector) is applied to a subset of wires, the unaffected wires are traced out prior to the expectation value calculation.

Details:

  • Number of wires: Any
  • Number of parameters: 1
  • Observable order: None (non-Gaussian)
Parameters:n (array) –

Array of non-negative integers representing the number state observable \(\ket{n}\bra{n}=\ket{n_0, n_1, \dots, n_P}\bra{n_0, n_1, \dots, n_P}\).

For example, to return the observable \(\ket{0,4,2}\bra{0,4,2}\) acting on wires 0, 1, and 3 of a QNode, you would call FockStateProjector(np.array([0, 4, 2], wires=[0, 1, 3])).

Note that len(n)==len(wires), and that len(n) cannot exceed the total number of wires in the QNode.