graphix.instruction module¶
Instruction classes.
- repr_angle(angle: Expression | float) str[source]¶
Return the representation string of an angle in radians.
This is used for pretty-printing instructions with
angleparameters. Delegates topretty_print.angle_to_str().
- class InstructionKind(*values)[source]¶
Bases:
EnumTag for instruction kind.
- CCX = 1¶
- RZZ = 2¶
- CNOT = 3¶
- SWAP = 4¶
- CZ = 5¶
- H = 6¶
- S = 7¶
- X = 8¶
- Y = 9¶
- Z = 10¶
- J = 11¶
- I = 12¶
- M = 13¶
- RX = 14¶
- RY = 15¶
- RZ = 16¶
- SDG = 17¶
- T = 18¶
- TDG = 19¶
- SX = 20¶
- SXDG = 21¶
- CY = 22¶
- P = 23¶
- U = 24¶
- CJ = 25¶
- CP = 26¶
- CRX = 27¶
- CRY = 28¶
- CRZ = 29¶
- CU = 30¶
- CSWAP = 31¶
- GPHASE = 32¶
- class InstructionVisitor[source]¶
Bases:
objectVisitor for instruction.
This base class can be subclassed to rewrite instructions by overriding some of the following functions:
visit_qubit: rewrite qubit indices.visit_angle: rewrite angles.visit_axis: rewrite axes.
- visit_angle(angle: Expression | float) Expression | float[source]¶
Rewrite an angle.
- class BaseInstruction[source]¶
Bases:
ABC,DataclassReprMixinBase class for circuit instructions.
- abstractmethod visit(visitor: InstructionVisitor, *, copy: bool = False) Self[source]¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class CCX(target: int, controls: tuple[int, int])[source]¶
Bases:
_KindChecker,BaseInstructionToffoli circuit instruction.
The CCX gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
controls[0],controls[1],target.- visit(visitor: InstructionVisitor, *, copy: bool = False) CCX[source]¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class RZZ(target: int, control: int, angle: Expression | float)[source]¶
Bases:
_KindChecker,BaseInstructionRZZ circuit instruction.
The \(\mathrm{RZZ}(\theta)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} \mathrm e^{-\mathrm i \frac \theta 2} & 0 & 0 & 0\\ 0 & \mathrm e^{\mathrm i \frac \theta 2} & 0 & 0\\ 0 & 0 & \mathrm e^{\mathrm i \frac \theta 2} & 0\\ 0 & 0 & 0 & \mathrm e^{-\mathrm i \frac \theta 2} \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.We have \(\mathrm{RZZ}(\theta) = \mathrm{CNOT} (I \otimes \mathrm{RZ}(\theta)) \mathrm{CNOT}\).
- angle¶
Rotation angle.
- Type:
ParameterizedAngle
- angle: Expression | float¶
- visit(visitor: InstructionVisitor, *, copy: bool = False) RZZ[source]¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class ControlledSingleTargetInstruction(target: int, control: int)[source]¶
Bases:
BaseInstructionBase class for controlled single-target circuit instructions.
- visit(visitor: InstructionVisitor, *, copy: bool = False) Self[source]¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class CY(target: int, control: int)[source]¶
Bases:
_KindChecker,ControlledSingleTargetInstructionCY circuit instruction.
The CY gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & -\mathrm i\\ 0 & 0 & \mathrm i & 0 \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.
- class CNOT(target: int, control: int)[source]¶
Bases:
_KindChecker,ControlledSingleTargetInstructionCNOT circuit instruction.
The CNOT gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & 1 & 0 \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.
- class CZ(targets: tuple[int, int])[source]¶
Bases:
_KindChecker,BaseInstructionCZ circuit instruction.
The CZ gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & -1 \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
targets[0],targets[1].- visit(visitor: InstructionVisitor, *, copy: bool = False) CZ[source]¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class SWAP(targets: tuple[int, int])[source]¶
Bases:
_KindChecker,BaseInstructionSWAP circuit instruction.
The SWAP gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1 \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
targets[0],targets[1].- visit(visitor: InstructionVisitor, *, copy: bool = False) SWAP[source]¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class CSWAP(control: int, targets: tuple[int, int])[source]¶
Bases:
_KindChecker,BaseInstructionCSWAP circuit instruction.
The CSWAP gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,targets[0],targets[1].- visit(visitor: InstructionVisitor, *, copy: bool = False) CSWAP[source]¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class SingleTargetInstruction(target: int)[source]¶
Bases:
BaseInstructionBase class for single-target circuit instructions.
- visit(visitor: InstructionVisitor, *, copy: bool = False) Self[source]¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class H(target: int)[source]¶
Bases:
_KindChecker,SingleTargetInstructionH circuit instruction.
The Hadamard gate applies the matrix \(\frac 1 {\sqrt 2}\left[\begin{matrix}1 & 1\\1 & -1\end{matrix}\right]\).
- class S(target: int)[source]¶
Bases:
_KindChecker,SingleTargetInstructionS circuit instruction.
The S gate applies the matrix \(\left[\begin{matrix}1 & 0\\0 & \mathrm i\end{matrix}\right]\).
- class SDG(target: int)[source]¶
Bases:
_KindChecker,SingleTargetInstructionSDG circuit instruction.
The \(S^\dagger\) gate applies the matrix \(\left[\begin{matrix}1 & 0\\0 & - \mathrm i\end{matrix}\right]\).
We have \(S^\dagger = \mathrm e^{\mathrm i \frac \pi 4} R_Z(-\frac \pi 2)\).
- class T(target: int)[source]¶
Bases:
_KindChecker,SingleTargetInstructionT circuit instruction.
The \(T\) gate applies the matrix \(\left[\begin{matrix}1 & 0\\0 & \mathrm e^{\mathrm i \frac \pi 4}\end{matrix}\right]\).
We have \(T = \mathrm e^{\mathrm i \frac \pi 8} R_Z(\frac \pi 4)\).
- class TDG(target: int)[source]¶
Bases:
_KindChecker,SingleTargetInstructionTDG circuit instruction.
The \(T^\dagger\) gate applies the matrix \(\left[\begin{matrix}1 & 0\\0 & \mathrm e^{- \mathrm i \frac \pi 4}\end{matrix}\right]\).
We have \(T^\dagger = \mathrm e^{\mathrm i \frac \pi 8} R_Z(- \frac \pi 4)\).
- class SX(target: int)[source]¶
Bases:
_KindChecker,SingleTargetInstructionSX circuit instruction.
The \(SX\) (\(\sqrt X\)) gate applies the matrix \(\frac 1 2 \left[\begin{matrix}1 + \mathrm i & 1 - \mathrm i\\1 - \mathrm i & 1 + \mathrm i\end{matrix}\right]\).
We have \(SX = \mathrm e^{\mathrm i \frac \pi 4} R_X(\frac \pi 2)\).
- class SXDG(target: int)[source]¶
Bases:
_KindChecker,SingleTargetInstructionSXDG circuit instruction.
The \(SX^\dagger\) (\({\sqrt X}^\dagger\)) gate applies the matrix \(\frac 1 2 \left[\begin{matrix}1 - \mathrm i & 1 + \mathrm i\\1 + \mathrm i & 1 - \mathrm i\end{matrix}\right]\).
We have \(SX^\dagger = \mathrm e^{\mathrm i \frac \pi 4} R_X(-\frac \pi 2)\).
- class X(target: int)[source]¶
Bases:
_KindChecker,SingleTargetInstructionX circuit instruction.
The X gate applies the matrix \(\left[\begin{matrix}0 & 1\\1 & 0\end{matrix}\right]\).
- class Y(target: int)[source]¶
Bases:
_KindChecker,SingleTargetInstructionY circuit instruction.
The Y gate applies the matrix \(\left[\begin{matrix}0 & -\mathrm i\\\mathrm i & 0\end{matrix}\right]\).
- class Z(target: int)[source]¶
Bases:
_KindChecker,SingleTargetInstructionZ circuit instruction.
The Z gate applies the matrix \(\left[\begin{matrix}1 & 0\\\mathrm 0 & -1\end{matrix}\right]\).
- class I(target: int)[source]¶
Bases:
_KindChecker,SingleTargetInstructionI circuit instruction.
The identity gate applies the matrix \(\left[\begin{matrix}1 & 0\\\mathrm 0 & 1\end{matrix}\right]\).
- class M(target: int, axis: Axis)[source]¶
Bases:
_KindChecker,BaseInstructionM circuit instruction.
- visit(visitor: InstructionVisitor, *, copy: bool = False) M[source]¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class RotationInstruction(target: int, angle: Expression | float)[source]¶
Bases:
BaseInstructionBase class for rotation instructions.
- angle: Expression | float¶
- visit(visitor: InstructionVisitor, *, copy: bool = False) Self[source]¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- __init__(target: int, angle: Expression | float) None¶
- class P(target: int, angle: Expression | float)[source]¶
Bases:
_KindChecker,RotationInstructionP rotation circuit instruction.
The \(P(\theta)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0\\ 0 & \mathrm e^{\mathrm i \theta} \end{matrix}\right]\end{split}\]We have \(P(\theta) = \mathrm e^{\theta/2} R_Z(\theta)\).
- __init__(target: int, angle: Expression | float) None¶
- class RX(target: int, angle: Expression | float)[source]¶
Bases:
_KindChecker,RotationInstructionX rotation circuit instruction.
The \(RX(\theta)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} \cos \frac \theta 2 & -\mathrm i \sin \frac \theta 2\\ -\mathrm i \sin \frac \theta 2 & \cos \frac \theta 2 \end{matrix}\right]\end{split}\]- __init__(target: int, angle: Expression | float) None¶
- class RY(target: int, angle: Expression | float)[source]¶
Bases:
_KindChecker,RotationInstructionY rotation circuit instruction.
The \(RY(\theta)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} \cos \frac \theta 2 & - \sin \frac \theta 2\\ \sin \frac \theta 2 & \cos \frac \theta 2 \end{matrix}\right]\end{split}\]- __init__(target: int, angle: Expression | float) None¶
- class RZ(target: int, angle: Expression | float)[source]¶
Bases:
_KindChecker,RotationInstructionZ rotation circuit instruction.
The \(RZ(\theta)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} \mathrm e^{-\mathrm i \frac \theta 2} & 0\\ 0 & \mathrm e^{\mathrm i \frac \theta 2} \end{matrix}\right]\end{split}\]- __init__(target: int, angle: Expression | float) None¶
- class J(target: int, angle: Expression | float)[source]¶
Bases:
_KindChecker,RotationInstructionJ circuit instruction.
The \(J(\theta)\) gate applies the matrix
\[\begin{split}\frac 1 {\sqrt 2} \left[\begin{matrix} 1 & \mathrm e^{\mathrm i \theta}\\ 1 & - \mathrm e^{\mathrm i \theta} \end{matrix}\right]\end{split}\]We have \(J(\theta) = \mathrm e^{\mathrm i \theta/2} H \mathrm{RZ}(\theta)\).
- __init__(target: int, angle: Expression | float) None¶
- class U(target: int, theta: Expression | float, phi: Expression | float, lambda_: Expression | float)[source]¶
Bases:
_KindChecker,BaseInstructionU circuit instruction.
The \(U(\theta, \phi, \lambda)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} \cos \frac \theta 2 & - \mathrm e^{\mathrm i\lambda} \sin \frac \theta 2 \\ \mathrm e^{\mathrm i \phi} \sin \frac \theta 2 & \mathrm e^{\mathrm i (\phi + \lambda)} \cos \frac \theta 2 \end{matrix}\right]\end{split}\]It can be decomposed as
\[U(\theta, \phi, \lambda) = \mathrm e^{\mathrm i\frac{\phi + \lambda}{2}} R_Z(\phi) R_Y(\theta) R_Z(\lambda) = \mathrm e^{\mathrm i\frac{\theta}{2}} H J\left(\phi + \frac{\pi}{2}\right) J(\theta) J\left(\lambda - \frac{\pi}{2}\right)\]- theta: Expression | float¶
- phi: Expression | float¶
- lambda_: Expression | float¶
- visit(visitor: InstructionVisitor, *, copy: bool = False) Self[source]¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- __init__(target: int, theta: Expression | float, phi: Expression | float, lambda_: Expression | float) None¶
- class CU(control: int, target: int, theta: Expression | float, phi: Expression | float, lambda_: Expression | float, gamma: Expression | float)[source]¶
Bases:
_KindChecker,BaseInstructionControlled-U circuit instruction.
The \(CU(\theta, \phi, \lambda, \gamma)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \mathrm e^{\mathrm i\gamma} \cos\left(\frac{\theta}{2}\right) & -\mathrm e^{\mathrm i(\gamma + \lambda)} \sin\left(\frac{\theta}{2}\right) \\ 0 & 0 & \mathrm e^{\mathrm i(\gamma + \phi)} \sin\left(\frac{\theta}{2}\right) & \mathrm e^{\mathrm i(\gamma + \phi + \lambda)} \cos\left(\frac{\theta}{2}\right) \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.It can be decomposed as
\[CU(\theta, \phi, \lambda, \gamma) = \left(P\left(\frac{\gamma - \theta} 2\right) \otimes I\right) CJ(0) CJ\left(\phi + \frac \pi 2\right) CJ(\theta) CJ\left(\lambda - \frac \pi 2\right)\]- theta¶
Rotation angle around the Y axis.
- Type:
ParameterizedAngle
- phi¶
Rotation angle around the Z axis after the Y rotation.
- Type:
ParameterizedAngle
- lambda_¶
Rotation angle around the Z axis before the Y rotation.
- Type:
ParameterizedAngle
- gamma¶
Global phase angle.
- Type:
ParameterizedAngle
- theta: Expression | float¶
- phi: Expression | float¶
- lambda_: Expression | float¶
- gamma: Expression | float¶
- visit(visitor: InstructionVisitor, *, copy: bool = False) Self[source]¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- __init__(control: int, target: int, theta: Expression | float, phi: Expression | float, lambda_: Expression | float, gamma: Expression | float) None¶
- class ControlledRotationInstruction(target: int, control: int, angle: Expression | float)[source]¶
Bases:
BaseInstructionBase class for rotation instructions.
- angle: Expression | float¶
- visit(visitor: InstructionVisitor, *, copy: bool = False) Self[source]¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class CP(target: int, control: int, angle: Expression | float)[source]¶
Bases:
_KindChecker,ControlledRotationInstructionControlled-P circuit instruction.
The \(CP(\theta)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & \mathrm e^{\mathrm i \theta} \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.- angle¶
Phase angle.
- Type:
ParameterizedAngle
- class CRX(target: int, control: int, angle: Expression | float)[source]¶
Bases:
_KindChecker,ControlledRotationInstructionControlled-X rotation circuit instruction.
The \(CRX(\theta)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & \cos \frac \theta 2 & -\mathrm i \sin \frac \theta 2\\ 0 & 0 & -\mathrm i \sin \frac \theta 2 & \cos \frac \theta 2 \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.- angle¶
Rotation angle.
- Type:
ParameterizedAngle
- class CRY(target: int, control: int, angle: Expression | float)[source]¶
Bases:
_KindChecker,ControlledRotationInstructionControlled-Y rotation circuit instruction.
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & \cos \frac \theta 2 & - \sin \frac \theta 2\\ 0 & 0 & \sin \frac \theta 2 & \cos \frac \theta 2 \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.- angle¶
Rotation angle.
- Type:
ParameterizedAngle
- class CRZ(target: int, control: int, angle: Expression | float)[source]¶
Bases:
_KindChecker,ControlledRotationInstructionControlled-Z rotation circuit instruction.
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & \mathrm e^{-\mathrm i \frac \theta 2} & 0\\ 0 & 0 & 0 & \mathrm e^{\mathrm i \frac \theta 2} \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.- angle¶
Rotation angle.
- Type:
ParameterizedAngle
- class CJ(target: int, control: int, angle: Expression | float)[source]¶
Bases:
_KindChecker,ControlledRotationInstructionControlled-J circuit instruction.
The \(CJ(\alpha)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & \frac 1 {\sqrt 2} & \frac 1 {\sqrt 2} \mathrm e^{\mathrm i \alpha}\\ 0 & 0 & \frac 1 {\sqrt 2} & - \frac 1 {\sqrt 2} \mathrm e^{\mathrm i \alpha} \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.Following Lemmas 4.3 and 5.1 of Barenco et al. (1995), we define:
\[\begin{split}\begin{aligned} A &= R_Y\left(\frac \pi 4\right),\\ B &= R_Y\left(- \frac \pi 4\right) R_Z(- \delta),\\ C &= R_Z(\delta),\\ \delta &= \frac {\alpha + \pi} 2 \end{aligned}\end{split}\]These operators satisfy \(ABC = I\) and \(AXBXC = \mathrm e^{-\mathrm i \delta} J(\alpha)\).
Consequently, \(CJ(\alpha)\) can be decomposed as:
\[CJ(\alpha) = (P(\delta) \otimes I) \, (I \otimes A) \, CX \, (I \otimes B) \, CX \, (I \otimes C)\]- angle¶
Rotation angle.
- Type:
ParameterizedAngle
References
Barenco, A., Bennett, C. H., Cleve, R., DiVincenzo, D. P., Margolus, N., Shor, P., Sleator, T., Smolin, J. A., & Weinfurter, H. (1995). Elementary gates for quantum computation. Physical Review A, 52(5), 3457-3467. https://doi.org/10.1103/physreva.52.3457
- class GPHASE(angle: Expression | float)[source]¶
Bases:
_KindChecker,BaseInstructionGPHASE circuit instruction.
- angle¶
Phase angle.
- Type:
ParameterizedAngle
- angle: Expression | float¶
- visit(visitor: InstructionVisitor, *, copy: bool = False) GPHASE[source]¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- __init__(angle: Expression | float) None¶
- class Instruction[source]¶
Bases:
objectGrouping of all instructions for namespace exposure.
Notes
This class is not meant to be instantiated, but rather serves as a namespace for all instructions except RZZ. The type alias for “any command” is
InstructionKind.- class I(target: int)¶
Bases:
_KindChecker,SingleTargetInstructionI circuit instruction.
The identity gate applies the matrix \(\left[\begin{matrix}1 & 0\\\mathrm 0 & 1\end{matrix}\right]\).
- class X(target: int)¶
Bases:
_KindChecker,SingleTargetInstructionX circuit instruction.
The X gate applies the matrix \(\left[\begin{matrix}0 & 1\\1 & 0\end{matrix}\right]\).
- class Y(target: int)¶
Bases:
_KindChecker,SingleTargetInstructionY circuit instruction.
The Y gate applies the matrix \(\left[\begin{matrix}0 & -\mathrm i\\\mathrm i & 0\end{matrix}\right]\).
- class Z(target: int)¶
Bases:
_KindChecker,SingleTargetInstructionZ circuit instruction.
The Z gate applies the matrix \(\left[\begin{matrix}1 & 0\\\mathrm 0 & -1\end{matrix}\right]\).
- class H(target: int)¶
Bases:
_KindChecker,SingleTargetInstructionH circuit instruction.
The Hadamard gate applies the matrix \(\frac 1 {\sqrt 2}\left[\begin{matrix}1 & 1\\1 & -1\end{matrix}\right]\).
- class S(target: int)¶
Bases:
_KindChecker,SingleTargetInstructionS circuit instruction.
The S gate applies the matrix \(\left[\begin{matrix}1 & 0\\0 & \mathrm i\end{matrix}\right]\).
- class SDG(target: int)¶
Bases:
_KindChecker,SingleTargetInstructionSDG circuit instruction.
The \(S^\dagger\) gate applies the matrix \(\left[\begin{matrix}1 & 0\\0 & - \mathrm i\end{matrix}\right]\).
We have \(S^\dagger = \mathrm e^{\mathrm i \frac \pi 4} R_Z(-\frac \pi 2)\).
- class T(target: int)¶
Bases:
_KindChecker,SingleTargetInstructionT circuit instruction.
The \(T\) gate applies the matrix \(\left[\begin{matrix}1 & 0\\0 & \mathrm e^{\mathrm i \frac \pi 4}\end{matrix}\right]\).
We have \(T = \mathrm e^{\mathrm i \frac \pi 8} R_Z(\frac \pi 4)\).
- class TDG(target: int)¶
Bases:
_KindChecker,SingleTargetInstructionTDG circuit instruction.
The \(T^\dagger\) gate applies the matrix \(\left[\begin{matrix}1 & 0\\0 & \mathrm e^{- \mathrm i \frac \pi 4}\end{matrix}\right]\).
We have \(T^\dagger = \mathrm e^{\mathrm i \frac \pi 8} R_Z(- \frac \pi 4)\).
- class SX(target: int)¶
Bases:
_KindChecker,SingleTargetInstructionSX circuit instruction.
The \(SX\) (\(\sqrt X\)) gate applies the matrix \(\frac 1 2 \left[\begin{matrix}1 + \mathrm i & 1 - \mathrm i\\1 - \mathrm i & 1 + \mathrm i\end{matrix}\right]\).
We have \(SX = \mathrm e^{\mathrm i \frac \pi 4} R_X(\frac \pi 2)\).
- class SXDG(target: int)¶
Bases:
_KindChecker,SingleTargetInstructionSXDG circuit instruction.
The \(SX^\dagger\) (\({\sqrt X}^\dagger\)) gate applies the matrix \(\frac 1 2 \left[\begin{matrix}1 - \mathrm i & 1 + \mathrm i\\1 + \mathrm i & 1 - \mathrm i\end{matrix}\right]\).
We have \(SX^\dagger = \mathrm e^{\mathrm i \frac \pi 4} R_X(-\frac \pi 2)\).
- class J(target: int, angle: Expression | float)¶
Bases:
_KindChecker,RotationInstructionJ circuit instruction.
The \(J(\theta)\) gate applies the matrix
\[\begin{split}\frac 1 {\sqrt 2} \left[\begin{matrix} 1 & \mathrm e^{\mathrm i \theta}\\ 1 & - \mathrm e^{\mathrm i \theta} \end{matrix}\right]\end{split}\]We have \(J(\theta) = \mathrm e^{\mathrm i \theta/2} H \mathrm{RZ}(\theta)\).
- __init__(target: int, angle: Expression | float) None¶
- class P(target: int, angle: Expression | float)¶
Bases:
_KindChecker,RotationInstructionP rotation circuit instruction.
The \(P(\theta)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0\\ 0 & \mathrm e^{\mathrm i \theta} \end{matrix}\right]\end{split}\]We have \(P(\theta) = \mathrm e^{\theta/2} R_Z(\theta)\).
- __init__(target: int, angle: Expression | float) None¶
- class RX(target: int, angle: Expression | float)¶
Bases:
_KindChecker,RotationInstructionX rotation circuit instruction.
The \(RX(\theta)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} \cos \frac \theta 2 & -\mathrm i \sin \frac \theta 2\\ -\mathrm i \sin \frac \theta 2 & \cos \frac \theta 2 \end{matrix}\right]\end{split}\]- __init__(target: int, angle: Expression | float) None¶
- class RY(target: int, angle: Expression | float)¶
Bases:
_KindChecker,RotationInstructionY rotation circuit instruction.
The \(RY(\theta)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} \cos \frac \theta 2 & - \sin \frac \theta 2\\ \sin \frac \theta 2 & \cos \frac \theta 2 \end{matrix}\right]\end{split}\]- __init__(target: int, angle: Expression | float) None¶
- class RZ(target: int, angle: Expression | float)¶
Bases:
_KindChecker,RotationInstructionZ rotation circuit instruction.
The \(RZ(\theta)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} \mathrm e^{-\mathrm i \frac \theta 2} & 0\\ 0 & \mathrm e^{\mathrm i \frac \theta 2} \end{matrix}\right]\end{split}\]- __init__(target: int, angle: Expression | float) None¶
- class U(target: int, theta: Expression | float, phi: Expression | float, lambda_: Expression | float)¶
Bases:
_KindChecker,BaseInstructionU circuit instruction.
The \(U(\theta, \phi, \lambda)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} \cos \frac \theta 2 & - \mathrm e^{\mathrm i\lambda} \sin \frac \theta 2 \\ \mathrm e^{\mathrm i \phi} \sin \frac \theta 2 & \mathrm e^{\mathrm i (\phi + \lambda)} \cos \frac \theta 2 \end{matrix}\right]\end{split}\]It can be decomposed as
\[U(\theta, \phi, \lambda) = \mathrm e^{\mathrm i\frac{\phi + \lambda}{2}} R_Z(\phi) R_Y(\theta) R_Z(\lambda) = \mathrm e^{\mathrm i\frac{\theta}{2}} H J\left(\phi + \frac{\pi}{2}\right) J(\theta) J\left(\lambda - \frac{\pi}{2}\right)\]- __init__(target: int, theta: Expression | float, phi: Expression | float, lambda_: Expression | float) None¶
- visit(visitor: InstructionVisitor, *, copy: bool = False) Self¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- theta: Expression | float¶
- phi: Expression | float¶
- lambda_: Expression | float¶
- class CJ(target: int, control: int, angle: Expression | float)¶
Bases:
_KindChecker,ControlledRotationInstructionControlled-J circuit instruction.
The \(CJ(\alpha)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & \frac 1 {\sqrt 2} & \frac 1 {\sqrt 2} \mathrm e^{\mathrm i \alpha}\\ 0 & 0 & \frac 1 {\sqrt 2} & - \frac 1 {\sqrt 2} \mathrm e^{\mathrm i \alpha} \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.Following Lemmas 4.3 and 5.1 of Barenco et al. (1995), we define:
\[\begin{split}\begin{aligned} A &= R_Y\left(\frac \pi 4\right),\\ B &= R_Y\left(- \frac \pi 4\right) R_Z(- \delta),\\ C &= R_Z(\delta),\\ \delta &= \frac {\alpha + \pi} 2 \end{aligned}\end{split}\]These operators satisfy \(ABC = I\) and \(AXBXC = \mathrm e^{-\mathrm i \delta} J(\alpha)\).
Consequently, \(CJ(\alpha)\) can be decomposed as:
\[CJ(\alpha) = (P(\delta) \otimes I) \, (I \otimes A) \, CX \, (I \otimes B) \, CX \, (I \otimes C)\]- angle¶
Rotation angle.
- Type:
ParameterizedAngle
References
Barenco, A., Bennett, C. H., Cleve, R., DiVincenzo, D. P., Margolus, N., Shor, P., Sleator, T., Smolin, J. A., & Weinfurter, H. (1995). Elementary gates for quantum computation. Physical Review A, 52(5), 3457-3467. https://doi.org/10.1103/physreva.52.3457
- class CP(target: int, control: int, angle: Expression | float)¶
Bases:
_KindChecker,ControlledRotationInstructionControlled-P circuit instruction.
The \(CP(\theta)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & \mathrm e^{\mathrm i \theta} \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.- angle¶
Phase angle.
- Type:
ParameterizedAngle
- class CRX(target: int, control: int, angle: Expression | float)¶
Bases:
_KindChecker,ControlledRotationInstructionControlled-X rotation circuit instruction.
The \(CRX(\theta)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & \cos \frac \theta 2 & -\mathrm i \sin \frac \theta 2\\ 0 & 0 & -\mathrm i \sin \frac \theta 2 & \cos \frac \theta 2 \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.- angle¶
Rotation angle.
- Type:
ParameterizedAngle
- class CRY(target: int, control: int, angle: Expression | float)¶
Bases:
_KindChecker,ControlledRotationInstructionControlled-Y rotation circuit instruction.
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & \cos \frac \theta 2 & - \sin \frac \theta 2\\ 0 & 0 & \sin \frac \theta 2 & \cos \frac \theta 2 \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.- angle¶
Rotation angle.
- Type:
ParameterizedAngle
- class CRZ(target: int, control: int, angle: Expression | float)¶
Bases:
_KindChecker,ControlledRotationInstructionControlled-Z rotation circuit instruction.
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & \mathrm e^{-\mathrm i \frac \theta 2} & 0\\ 0 & 0 & 0 & \mathrm e^{\mathrm i \frac \theta 2} \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.- angle¶
Rotation angle.
- Type:
ParameterizedAngle
- class CU(control: int, target: int, theta: Expression | float, phi: Expression | float, lambda_: Expression | float, gamma: Expression | float)¶
Bases:
_KindChecker,BaseInstructionControlled-U circuit instruction.
The \(CU(\theta, \phi, \lambda, \gamma)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \mathrm e^{\mathrm i\gamma} \cos\left(\frac{\theta}{2}\right) & -\mathrm e^{\mathrm i(\gamma + \lambda)} \sin\left(\frac{\theta}{2}\right) \\ 0 & 0 & \mathrm e^{\mathrm i(\gamma + \phi)} \sin\left(\frac{\theta}{2}\right) & \mathrm e^{\mathrm i(\gamma + \phi + \lambda)} \cos\left(\frac{\theta}{2}\right) \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.It can be decomposed as
\[CU(\theta, \phi, \lambda, \gamma) = \left(P\left(\frac{\gamma - \theta} 2\right) \otimes I\right) CJ(0) CJ\left(\phi + \frac \pi 2\right) CJ(\theta) CJ\left(\lambda - \frac \pi 2\right)\]- theta¶
Rotation angle around the Y axis.
- Type:
ParameterizedAngle
- phi¶
Rotation angle around the Z axis after the Y rotation.
- Type:
ParameterizedAngle
- lambda_¶
Rotation angle around the Z axis before the Y rotation.
- Type:
ParameterizedAngle
- gamma¶
Global phase angle.
- Type:
ParameterizedAngle
- __init__(control: int, target: int, theta: Expression | float, phi: Expression | float, lambda_: Expression | float, gamma: Expression | float) None¶
- visit(visitor: InstructionVisitor, *, copy: bool = False) Self¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- theta: Expression | float¶
- phi: Expression | float¶
- lambda_: Expression | float¶
- gamma: Expression | float¶
- class CNOT(target: int, control: int)¶
Bases:
_KindChecker,ControlledSingleTargetInstructionCNOT circuit instruction.
The CNOT gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & 1 & 0 \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.
- class CY(target: int, control: int)¶
Bases:
_KindChecker,ControlledSingleTargetInstructionCY circuit instruction.
The CY gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & -\mathrm i\\ 0 & 0 & \mathrm i & 0 \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.
- class CZ(targets: tuple[int, int])¶
Bases:
_KindChecker,BaseInstructionCZ circuit instruction.
The CZ gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & -1 \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
targets[0],targets[1].- visit(visitor: InstructionVisitor, *, copy: bool = False) CZ¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class CCX(target: int, controls: tuple[int, int])¶
Bases:
_KindChecker,BaseInstructionToffoli circuit instruction.
The CCX gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
controls[0],controls[1],target.- visit(visitor: InstructionVisitor, *, copy: bool = False) CCX¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class RZZ(target: int, control: int, angle: Expression | float)¶
Bases:
_KindChecker,BaseInstructionRZZ circuit instruction.
The \(\mathrm{RZZ}(\theta)\) gate applies the matrix
\[\begin{split}\left[\begin{matrix} \mathrm e^{-\mathrm i \frac \theta 2} & 0 & 0 & 0\\ 0 & \mathrm e^{\mathrm i \frac \theta 2} & 0 & 0\\ 0 & 0 & \mathrm e^{\mathrm i \frac \theta 2} & 0\\ 0 & 0 & 0 & \mathrm e^{-\mathrm i \frac \theta 2} \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,target.We have \(\mathrm{RZZ}(\theta) = \mathrm{CNOT} (I \otimes \mathrm{RZ}(\theta)) \mathrm{CNOT}\).
- angle¶
Rotation angle.
- Type:
ParameterizedAngle
- visit(visitor: InstructionVisitor, *, copy: bool = False) RZZ¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- angle: Expression | float¶
- class SWAP(targets: tuple[int, int])¶
Bases:
_KindChecker,BaseInstructionSWAP circuit instruction.
The SWAP gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1 \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
targets[0],targets[1].- visit(visitor: InstructionVisitor, *, copy: bool = False) SWAP¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class CSWAP(control: int, targets: tuple[int, int])¶
Bases:
_KindChecker,BaseInstructionCSWAP circuit instruction.
The CSWAP gate applies the matrix
\[\begin{split}\left[\begin{matrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \end{matrix}\right]\end{split}\]in the computational basis. The basis states use big-endian ordering, with the most significant qubit first. The qubits are numbered in the order
control,targets[0],targets[1].- visit(visitor: InstructionVisitor, *, copy: bool = False) CSWAP¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class M(target: int, axis: Axis)¶
Bases:
_KindChecker,BaseInstructionM circuit instruction.
- visit(visitor: InstructionVisitor, *, copy: bool = False) M¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- class GPHASE(angle: Expression | float)¶
Bases:
_KindChecker,BaseInstructionGPHASE circuit instruction.
- angle¶
Phase angle.
- Type:
ParameterizedAngle
- __init__(angle: Expression | float) None¶
- visit(visitor: InstructionVisitor, *, copy: bool = False) GPHASE¶
Rewrite the instruction according to the given visitor.
- Parameters:
visitor (InstructionVisitor) – The visitor specifying the rewriting.
copy (bool, optional) – If
True, the current instruction remains unchanged, and a new instruction is returned. The default isFalse, meaning that changes are performed in place.
- Returns:
The rewritten instruction. Equal to
selfifcopyisFalse.- Return type:
Self
- angle: Expression | float¶