clock[source]

clock(d)

The clock operator $\hat{Z}$ for dimension $d$.

$$Z = \begin{pmatrix} 1 & 0 & 0 & \cdots & 0\\ 0 & \omega & 0 & \cdots & 0\\ 0 & 0 & \omega^2 & \cdots & 0\\ \vdots & \vdots & \vdots & \ddots & \vdots\\ 0 & 0 & 0 & \cdots & \omega^{d-1} \end{pmatrix} $$

Where $\omega = e^{\frac{2\pi i}{d}}$.

shift[source]

shift(d)

The shift operator $\hat{X}$ for dimension $d$.

$$X = \begin{pmatrix} 0 & 0 & 0 & \cdots & 0 & 1\\ 1 & 0 & 0 & \cdots & 0 & 0\\ 0 & 1 & 0 & \cdots & 0 & 0\\ 0 & 0 & 1 & \cdots & 0 & 0\\ \vdots & \vdots & \vdots & \ddots &\vdots &\vdots\\ 0 & 0 & 0 & \cdots & 1 & 0\\ \end{pmatrix} $$

displace[source]

displace(d, a, b)

The displacement operator $\hat{D}_{a,b} = (-e^{\frac{i\pi}{d}})^{ab}\hat{X}^{b}\hat{Z}^{a}$ for dimension $d$.

weyl_heisenberg_indices[source]

weyl_heisenberg_indices(d)

Returns a list with entries $(a, b)$ for $a, b \in [0, d)$.

displacement_operators[source]

displacement_operators(d)

Returns a dictionary associating $(a, b)$ with $\hat{D}_{a,b}$ for $a, b \in [0, d)$.

weyl_heisenberg_states[source]

weyl_heisenberg_states(fiducial)

Applies the $d^2$ displacement operators to a fiducial state, which can be either a ket or a density matrix.

weyl_heisenberg_povm[source]

weyl_heisenberg_povm(fiducial)

Generates a Weyl-Heisenberg POVM by applying the $d^2$ displacement operators to a fiducial state and then, if the fiducial state is a ket $\mid \psi \rangle$, forming the projector $\mid \psi \rangle \langle \psi \mid$, and normalizing by $\frac{1}{d}$.

Note that if the fiducial state is a density matrix, it may be the case that it is invariant under some displacement operators, in which case you'll run into problems!

Let's check that we really get a POVM. Recall that a POVM (a positive operator valued measure) consists in a set of positive semidefinite operators that sum to the identity, i.e., a set $\{E_{i}\}$ such that $\sum_{i} E_{i} = I$.

We can form a POVM whose elements are all rank-1:

d = 3
povm_from_state = weyl_heisenberg_povm(qt.rand_ket(d))
assert np.allclose(sum(povm_from_state), qt.identity(d))

Or not!

povm_from_dm = weyl_heisenberg_povm(qt.rand_dm(d))
assert np.allclose(sum(povm_from_dm), qt.identity(d))

The $d^2$ POVM elements form a linearly independent basis for quantum states in a $d$ dimensional Hilbert space. This works because the Weyl-Heisenberg (unitary) displacement operators themselves form an operator basis!

to_weyl_heisenberg_basis[source]

to_weyl_heisenberg_basis(O, D=None)

Expands a $d \times d$ operator $O$ in the Weyl-Heisenberg basis with components:

$$ O_{a,b} = \frac{1}{d} tr ( \hat{D}_{a,b}^{\dagger} \hat{O} ) $$

Returns a dictionary associating $(a, b)$ with components.

from_weyl_heisenberg_basis[source]

from_weyl_heisenberg_basis(C, D=None)

Given a dictionary of Weyl-Heisenberg components, returns the operator $O$ in the standard basis:

$$\hat{O} = \sum_{a,b} O_{a,b}\hat{D}_{a,b}$$
d = 4
O = qt.rand_unitary(d)
assert np.allclose(O, from_weyl_heisenberg_basis(to_weyl_heisenberg_basis(O)))