mimiqcircuits.operations.rescaledgates¶
Rescaled gate operation.
Functions
|
Return |
Classes
|
A gate multiplied by a scalar factor |
- class RescaledGate(gate, p)[source]¶
Bases:
AbstractOperator,Generic[T]A gate multiplied by a scalar factor
p.Represents the operator \(p\,U\), where \(U\) is the matrix of
gate. Forp < 1the result is not unitary, so aRescaledGateis an operator, not a gate: it cannot be pushed to a circuit directly or inverted. It is used where an operator is expected, for example inExpectationValue, or as a Kraus operator ofMixedUnitary, whereRescaledGate(U, s)stands for \(U\) applied with probability \(s^2\).- Parameters:
gate (Gate) – The gate to rescale.
p – The factor, a number in \([0, 1]\) or a symbolic expression. Symbolic factors are not range checked.
- Raises:
TypeError – If
gateis not aGate.ValueError – If a numeric
pis outside \([0, 1]\).
Examples
>>> from mimiqcircuits import * >>> rg = RescaledGate(GateH(), 0.5) >>> rg 0.5*H >>> rg.get_scale() 0.5 >>> rg.matrix() [0.353553390593274, 0.353553390593274] [0.353553390593274, -0.353553390593274] >>> # rescaling again multiplies the factors >>> rg.rescale(0.8) 0.4*H >>> # use it as the observable of an expectation value >>> Circuit().push(ExpectationValue(RescaledGate(GateZ(), 0.5)), 0, 0) 1-qubit, 1-zvar circuit with 1 instruction: └── ⟨0.5*Z⟩ @ q[0], z[0]
- get_param(name)[source]¶
Return the factor for
name == "p", otherwise looknameup on the wrapped gate.
- rescale_inplace(p)[source]¶
Multiply the factor by
pin place and returnself.The product is not range checked.