hybridlane.ops.qumode.observables.FockStateProjector¶
- class hybridlane.ops.qumode.observables.FockStateProjector(n, wires, id=None)¶
Bases:
pennylane.FockStateProjector,hybridlane.ops.mixins.SpectralThe 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 thatlen(n)cannot exceed the total number of wires in the QNode.wires (Sequence[Any] or Any) – the wire the operation acts on
id (str or None) – String representing the operation (optional)
- natural_basis¶
- property num_wires¶
Number of wires the operator acts on.
- static compute_diagonalizing_gates(*parameters, wires, **hyperparameters)¶
Sequence of gates that diagonalize the operator in the computational basis (static method).
Given the eigendecomposition \(O = U \Sigma U^{\dagger}\) where \(\Sigma\) is a diagonal matrix containing the eigenvalues, the sequence of diagonalizing gates implements the unitary \(U^{\dagger}\).
The diagonalizing gates rotate the state into the eigenbasis of the operator.
See also
diagonalizing_gates().- Parameters:
params (list) – trainable parameters of the operator, as stored in the
parametersattributewires (Iterable[Any], Wires) – wires that the operator acts on
hyperparams (dict) – non-trainable hyperparameters of the operator, as stored in the
hyperparametersattributeparameters (pennylane.typing.TensorLike)
- Returns:
list of diagonalizing gates
- Return type:
list[.Operator]
- fock_spectrum(*basis_states)¶
Provides a diagonal decomposition of the operator in the Fock basis
An observable that implements this method guarantees it can be written as
\[O = \sum_n f(n) \ket{n}\bra{n}\]where \(n \in \mathbb{N}_0\).