CVObservable

Module: pennylane

class CVObservable(*args, wires=None, do_queue=True)[source]

Base class for continuous-variable observables.

The class attribute ev_order can be defined to indicate to PennyLane whether the corresponding CV observable is a polynomial in the quadrature operators. If so,

  • ev_order = 1 indicates a first order polynomial in quadrature operators \((\x, \p)\).
  • ev_order = 2 indicates a second order polynomial in quadrature operators \((\x, \p)\).

If ev_order is not None, then the Heisenberg representation of the observable should be defined in the static method _heisenberg_rep(), returning an array of the correct dimension.

ev_order = None

if not None, the observable is a polynomial of the given order in (x, p).

Type:None, int
heisenberg_obs(num_wires)[source]

Representation of the observable in the position/momentum operator basis.

Returns the expansion \(q\) of the observable, \(Q\), in the basis \(\mathbf{r} = (\I, \x_0, \p_0, \x_1, \p_1, \ldots)\).

  • For first-order observables returns a real vector such that \(Q = \sum_i q_i \mathbf{r}_i\).
  • For second-order observables returns a real symmetric matrix such that \(Q = \sum_{ij} q_{ij} \mathbf{r}_i \mathbf{r}_j\).
Parameters:num_wires (int) – total number of wires in the quantum circuit
Returns:\(q\)
Return type:array[float]