mimiqcircuits.operations.operators.diagonals¶
Classes
|
One-qubit diagonal operator. |
- class DiagonalOp(a, b)[source]¶
Bases:
AbstractOperatorOne-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
ExpectationValueor 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
aorbis neither a real number nor a symbolic expression.
See also
Operator,Projector0,Projector1Examples
>>> 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.