mimiqcircuits.operations.gates.gate¶
Abstract Gate base class.
Classes
|
Base class for unitary gates. |
- class Gate[source]¶
Bases:
AbstractOperatorBase class for unitary gates.
A gate acts on qubits only, has a unitary matrix, and can be inverted, raised to a power, controlled, repeated and run in parallel. Subclasses provide the matrix and the number of qubits.
power(),control(),parallel()andrepeat()called without their count return aLazyExprthat takes it later.Examples
>>> from mimiqcircuits import * >>> GateX().control(2) C₂X >>> GateX().power(0.5) SX >>> GateH().parallel(3) ⨷ ³ H >>> # without the count, a lazy expression is returned >>> GateX().control() lazy control(?, X)
- inverse()[source]¶
Return the inverse of the gate.
Gates with a known inverse return it directly (for example
GateS().inverse()isGateSDG()); otherwise the gate is wrapped inInverse.
- power(*args)[source]¶
Return the gate raised to a power.
Gates with a known power return it directly (for example
GateZ().power(0.5)isGateS(), andGateRX(a).power(p)isGateRX(p * a)); otherwise the gate is wrapped inPower.- Parameters:
*args – The exponent. Without it, return a
LazyExprthat takes the exponent later.- Raises:
ValueError – If more than one argument is given.
TypeError – If the exponent is not a real number.
- control(*args)[source]¶
Return the gate controlled by
num_controlsqubits.Gates with a named controlled form return it directly (for example
GateX().control(1)isGateCX()); otherwise the gate is wrapped inControl. The controls are the first qubits.- Parameters:
*args – The number of controls. Without it, return a
LazyExprthat takes the number later.- Raises:
ValueError – If more than one argument is given.
- parallel(*args)[source]¶
Return a
Parallelapplying the gate to separate qubit groups.- Parameters:
*args – The number of repetitions. Without it, return a
LazyExprthat takes the number later.- Raises:
ValueError – If more than one argument is given.
- repeat(*args)[source]¶
Return a
Repeatapplying the gate several times in sequence on the same qubits.- Parameters:
*args – The number of repetitions. Without it, return a
LazyExprthat takes the number later.- Raises:
ValueError – If more than one argument is given.