mimiqcircuits.operations.operators.diagonals

Classes

DiagonalOp(a, b)

One-qubit diagonal operator.

class DiagonalOp(a, b)[source]

Bases: AbstractOperator

One-qubit diagonal operator.

Matrix Representation

\[\begin{split}\begin{pmatrix} a & 0 \\ 0 & b \end{pmatrix}\end{split}\]

The operator does not have to be unitary. Use it in an ExpectationValue or as a Kraus operator.

Parameters:
  • a – The top-left entry, a real number or a symbolic expression.

  • b – The bottom-right entry, a real number or a symbolic expression.

Raises:

ValueError – If a or b is neither a real number nor a symbolic expression.

See also

Operator, Projector0, Projector1

Examples

>>> from mimiqcircuits import *
>>> DiagonalOp(1, 0.5)
D(1, 0.5)
>>> # expectation value on qubit 1, stored in z-variable 2
>>> c = Circuit()
>>> c.push(ExpectationValue(DiagonalOp(1, 0.5)), 1, 2)
2-qubit, 3-zvar circuit with 1 instruction:
└── ⟨D(1, 0.5)⟩ @ q[1], z[2]
property parnames

Names of the operation’s parameters, as a tuple of strings.

Read-only: assigning to it raises ValueError.

opsquared()[source]

Return \(O^\dagger O\), the diagonal operator with entries \(|a|^2\) and \(|b|^2\).