braket.circuits.gate module¶
-
class
braket.circuits.gate.
Gate
(qubit_count: int, ascii_symbols: Sequence[str])[source]¶ Bases:
braket.circuits.quantum_operator.QuantumOperator
Class
Gate
represents a quantum gate that operates on N qubits. Gates are considered the building blocks of quantum circuits. This class is considered the gate definition containing the metadata that defines what a gate is and what it does.- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
to_ir
(target: braket.circuits.qubit_set.QubitSet) → Any[source]¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
classmethod
register_gate
(gate: braket.circuits.gate.Gate)[source]¶ Register a gate implementation by adding it into the Gate class.
- Parameters
gate (Gate) – Gate class to register.
-
class
CCNot
¶ Bases:
braket.circuits.gate.Gate
CCNOT gate or Toffoli gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
static
ccnot
(control1: Union[Qubit, int], control2: Union[Qubit, int], target: Union[Qubit, int]) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CCNot instruction.
Examples
>>> circ = Circuit().ccnot(0, 1, 2)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
CNot
¶ Bases:
braket.circuits.gate.Gate
Controlled NOT gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
static
cnot
(control: Union[Qubit, int], target: Union[Qubit, int]) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CNot instruction.
Examples
>>> circ = Circuit().cnot(0, 1)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
CPhaseShift
(angle: float)¶ Bases:
braket.circuits.angled_gate.AngledGate
Controlled phase shift gate.
- Parameters
angle (float) – angle in radians.
angle – The angle of the gate in radians.
qubit_count (int) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises
ValueError – If the
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle
is`None`
-
static
cphaseshift
(control: Union[Qubit, int], target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CPhaseShift instruction.
Examples
>>> circ = Circuit().cphaseshift(0, 1, 0.15)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
CPhaseShift00
(angle: float)¶ Bases:
braket.circuits.angled_gate.AngledGate
Controlled phase shift gate for phasing the |00> state.
- Parameters
angle (float) – angle in radians.
angle – The angle of the gate in radians.
qubit_count (int) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises
ValueError – If the
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle
is`None`
-
static
cphaseshift00
(control: Union[Qubit, int], target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CPhaseShift00 instruction.
Examples
>>> circ = Circuit().cphaseshift00(0, 1, 0.15)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
CPhaseShift01
(angle: float)¶ Bases:
braket.circuits.angled_gate.AngledGate
Controlled phase shift gate for phasing the |01> state.
- Parameters
angle (float) – angle in radians.
angle – The angle of the gate in radians.
qubit_count (int) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises
ValueError – If the
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle
is`None`
-
static
cphaseshift01
(control: Union[Qubit, int], target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CPhaseShift01 instruction.
Examples
>>> circ = Circuit().cphaseshift01(0, 1, 0.15)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
CPhaseShift10
(angle: float)¶ Bases:
braket.circuits.angled_gate.AngledGate
Controlled phase shift gate for phasing the |10> state.
- Parameters
angle (float) – angle in radians.
angle – The angle of the gate in radians.
qubit_count (int) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises
ValueError – If the
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle
is`None`
-
static
cphaseshift10
(control: Union[Qubit, int], target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CPhaseShift10 instruction.
Examples
>>> circ = Circuit().cphaseshift10(0, 1, 0.15)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
CSwap
¶ Bases:
braket.circuits.gate.Gate
Controlled Swap gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
static
cswap
(control: Union[Qubit, int], target1: Union[Qubit, int], target2: Union[Qubit, int]) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CSwap instruction.
Examples
>>> circ = Circuit().cswap(0, 1, 2)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
CY
¶ Bases:
braket.circuits.gate.Gate
Controlled Pauli-Y gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
static
cy
(control: Union[Qubit, int], target: Union[Qubit, int]) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CY instruction.
Examples
>>> circ = Circuit().cy(0, 1)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
CZ
¶ Bases:
braket.circuits.gate.Gate
Controlled Pauli-Z gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
static
cz
(control: Union[Qubit, int], target: Union[Qubit, int]) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CZ instruction.
Examples
>>> circ = Circuit().cz(0, 1)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
H
¶ Bases:
braket.circuits.gate.Gate
Hadamard gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
static
h
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction]¶ Registers this function into the circuit class.
- Parameters
target (Qubit, int, or iterable of Qubit / int) – Target qubit(s)
- Returns
Iterable[Instruction] –
Iterable
of H instructions.
Examples
>>> circ = Circuit().h(0) >>> circ = Circuit().h([0, 1, 2])
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
I
¶ Bases:
braket.circuits.gate.Gate
Identity gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
static
i
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction]¶ Registers this function into the circuit class.
- Parameters
target (Qubit, int, or iterable of Qubit / int) – Target qubit(s)
- Returns
Iterable[Instruction] –
Iterable
of I instructions.
Examples
>>> circ = Circuit().i(0) >>> circ = Circuit().i([0, 1, 2])
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
ISwap
¶ Bases:
braket.circuits.gate.Gate
ISwap gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
static
iswap
(target1: Union[Qubit, int], target2: Union[Qubit, int]) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – ISwap instruction.
Examples
>>> circ = Circuit().iswap(0, 1)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
PSwap
(angle: float)¶ Bases:
braket.circuits.angled_gate.AngledGate
PSwap gate.
- Parameters
angle (float) – angle in radians.
angle – The angle of the gate in radians.
qubit_count (int) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises
ValueError – If the
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle
is`None`
-
static
pswap
(target1: Union[Qubit, int], target2: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – PSwap instruction.
Examples
>>> circ = Circuit().pswap(0, 1, 0.15)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
PhaseShift
(angle: float)¶ Bases:
braket.circuits.angled_gate.AngledGate
Phase shift gate.
- Parameters
angle (float) – angle in radians.
angle – The angle of the gate in radians.
qubit_count (int) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises
ValueError – If the
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle
is`None`
-
static
phaseshift
(target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
target (Qubit or int) – Target qubit index.
angle (float) – Angle in radians.
- Returns
Instruction – PhaseShift instruction.
Examples
>>> circ = Circuit().phaseshift(0, 0.15)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
Rx
(angle: float)¶ Bases:
braket.circuits.angled_gate.AngledGate
X-axis rotation gate.
- Parameters
angle (float) – angle in radians.
angle – The angle of the gate in radians.
qubit_count (int) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises
ValueError – If the
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle
is`None`
-
static
rx
(target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
target (Qubit or int) – Target qubit index.
angle (float) – Angle in radians.
- Returns
Instruction – Rx instruction.
Examples
>>> circ = Circuit().rx(0, 0.15)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
Ry
(angle: float)¶ Bases:
braket.circuits.angled_gate.AngledGate
Y-axis rotation gate.
- Parameters
angle (float) – angle in radians.
angle – The angle of the gate in radians.
qubit_count (int) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises
ValueError – If the
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle
is`None`
-
static
ry
(target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
target (Qubit or int) – Target qubit index.
angle (float) – Angle in radians.
- Returns
Instruction – Ry instruction.
Examples
>>> circ = Circuit().ry(0, 0.15)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
Rz
(angle: float)¶ Bases:
braket.circuits.angled_gate.AngledGate
Z-axis rotation gate.
- Parameters
angle (float) – angle in radians.
angle – The angle of the gate in radians.
qubit_count (int) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises
ValueError – If the
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle
is`None`
-
static
rz
(target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
target (Qubit or int) – Target qubit index.
angle (float) – Angle in radians.
- Returns
Instruction – Rz instruction.
Examples
>>> circ = Circuit().rz(0, 0.15)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
S
¶ Bases:
braket.circuits.gate.Gate
S gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
static
s
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction]¶ Registers this function into the circuit class.
- Parameters
target (Qubit, int, or iterable of Qubit / int) – Target qubit(s)
- Returns
Iterable[Instruction] –
Iterable
of S instructions.
Examples
>>> circ = Circuit().s(0) >>> circ = Circuit().s([0, 1, 2])
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
Si
¶ Bases:
braket.circuits.gate.Gate
Conjugate transpose of S gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
static
si
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction]¶ Registers this function into the circuit class.
- Parameters
target (Qubit, int, or iterable of Qubit / int) – Target qubit(s)
- Returns
Iterable[Instruction] – Iterable of Si instructions.
Examples
>>> circ = Circuit().si(0) >>> circ = Circuit().si([0, 1, 2])
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
Swap
¶ Bases:
braket.circuits.gate.Gate
Swap gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
static
swap
(target1: Union[Qubit, int], target2: Union[Qubit, int]) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – Swap instruction.
Examples
>>> circ = Circuit().swap(0, 1)
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
T
¶ Bases:
braket.circuits.gate.Gate
T gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
static
t
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction]¶ Registers this function into the circuit class.
- Parameters
target (Qubit, int, or iterable of Qubit / int) – Target qubit(s)
- Returns
Iterable[Instruction] –
Iterable
of T instructions.
Examples
>>> circ = Circuit().t(0) >>> circ = Circuit().t([0, 1, 2])
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
Ti
¶ Bases:
braket.circuits.gate.Gate
Conjugate transpose of T gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
static
ti
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction]¶ Registers this function into the circuit class.
- Parameters
target (Qubit, int, or iterable of Qubit / int) – Target qubit(s)
- Returns
Iterable[Instruction] –
Iterable
of Ti instructions.
Examples
>>> circ = Circuit().ti(0) >>> circ = Circuit().ti([0, 1, 2])
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
class
Unitary
(matrix: numpy.ndarray, display_name: str = 'U')¶ Bases:
braket.circuits.gate.Gate
Arbitrary unitary gate
- Parameters
matrix (numpy.ndarray) – Unitary matrix which defines the gate.
display_name (str) – Name to be used for an instance of this unitary gate for circuit diagrams. Defaults to
U
.qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError – If
matrix
is not a two-dimensional square matrix, or has a dimension length which is not a positive exponent of 2, or is non-unitary.ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
()¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
static
unitary
(targets: braket.circuits.qubit_set.QubitSet, matrix: numpy.ndarray, display_name: str = 'U') → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
targets (QubitSet) – Target qubits.
matrix (numpy.ndarray) – Unitary matrix which defines the gate. Matrix should be compatible with the supplied targets, with 2 ** len(targets) == matrix.shape[0].
display_name (str) – Name to be used for an instance of this unitary gate for circuit diagrams. Defaults to
U
.
- Returns
Instruction – Unitary instruction.
- Raises
ValueError – If
matrix
is not a two-dimensional square matrix, or has a dimension length which is not compatible with thetargets
, or is non-unitary,
Examples
>>> circ = Circuit().unitary(matrix=np.array([[0, 1],[1, 0]]), targets=[0])
-
class
V
¶ Bases:
braket.circuits.gate.Gate
Square root of not gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
static
v
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction]¶ Registers this function into the circuit class.
- Parameters
target (Qubit, int, or iterable of Qubit / int) – Target qubit(s)
- Returns
Iterable[Instruction] –
Iterable
of V instructions.
Examples
>>> circ = Circuit().v(0) >>> circ = Circuit().v([0, 1, 2])
-
class
Vi
¶ Bases:
braket.circuits.gate.Gate
Conjugate transpose of square root of not gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
static
vi
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction]¶ Registers this function into the circuit class.
- Parameters
target (Qubit, int, or iterable of Qubit / int) – Target qubit(s)
- Returns
Iterable[Instruction] –
Iterable
of Vi instructions.
Examples
>>> circ = Circuit().vi(0) >>> circ = Circuit().vi([0, 1, 2])
-
class
X
¶ Bases:
braket.circuits.gate.Gate
Pauli-X gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
static
x
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction]¶ Registers this function into the circuit class.
- Parameters
target (Qubit, int, or iterable of Qubit / int) – Target qubit(s)
- Returns
Iterable[Instruction] –
Iterable
of X instructions.
Examples
>>> circ = Circuit().x(0) >>> circ = Circuit().x([0, 1, 2])
-
class
XX
(angle: float)¶ Bases:
braket.circuits.angled_gate.AngledGate
Ising XX coupling gate.
- Parameters
angle (float) – angle in radians.
angle – The angle of the gate in radians.
qubit_count (int) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises
ValueError – If the
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle
is`None`
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
static
xx
(target1: Union[Qubit, int], target2: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – XX instruction.
Examples
>>> circ = Circuit().xx(0, 1, 0.15)
-
class
XY
(angle: float)¶ Bases:
braket.circuits.angled_gate.AngledGate
XY gate.
- Parameters
angle (float) – angle in radians.
angle – The angle of the gate in radians.
qubit_count (int) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises
ValueError – If the
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle
is`None`
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
static
xy
(target1: Union[Qubit, int], target2: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – XY instruction.
Examples
>>> circ = Circuit().xy(0, 1, 0.15)
-
class
Y
¶ Bases:
braket.circuits.gate.Gate
Pauli-Y gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
static
y
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction]¶ Registers this function into the circuit class.
- Parameters
target (Qubit, int, or iterable of Qubit / int) – Target qubit(s)
- Returns
Iterable[Instruction] –
Iterable
of Y instructions.
Examples
>>> circ = Circuit().y(0) >>> circ = Circuit().y([0, 1, 2])
-
class
YY
(angle: float)¶ Bases:
braket.circuits.angled_gate.AngledGate
Ising YY coupling gate.
- Parameters
angle (float) – angle in radians.
angle – The angle of the gate in radians.
qubit_count (int) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises
ValueError – If the
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle
is`None`
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
static
yy
(target1: Union[Qubit, int], target2: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – YY instruction.
Examples
>>> circ = Circuit().yy(0, 1, 0.15)
-
class
Z
¶ Bases:
braket.circuits.gate.Gate
Pauli-Z gate.
- Parameters
qubit_count (int) – Number of qubits this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as
qubit_count
, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.
- Raises
ValueError –
qubit_count
is less than 1,ascii_symbols
are None, orascii_symbols
length !=qubit_count
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
static
z
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction]¶ Registers this function into the circuit class.
- Parameters
target (Qubit, int, or iterable of Qubit / int) – Target qubit(s)
- Returns
Iterable[Instruction] –
Iterable
of Z instructions.
Examples
>>> circ = Circuit().z(0) >>> circ = Circuit().z([0, 1, 2])
-
class
ZZ
(angle: float)¶ Bases:
braket.circuits.angled_gate.AngledGate
Ising ZZ coupling gate.
- Parameters
angle (float) – angle in radians.
angle – The angle of the gate in radians.
qubit_count (int) – The number of qubits that this gate interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count
, and index ordering is expected to correlate with the target ordering on the instruction. For instance, if a CNOT instruction has the control qubit on the first index and target qubit on the second index, the ASCII symbols should have["C", "X"]
to correlate a symbol with that index.
- Raises
ValueError – If the
qubit_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
, orangle
is`None`
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)¶ Returns IR object of quantum operator and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the quantum operator and target
-
to_matrix
() → numpy.ndarray¶ Returns a matrix representation of the quantum operator
- Returns
np.ndarray – A matrix representation of the quantum operator
-
static
zz
(target1: Union[Qubit, int], target2: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – ZZ instruction.
Examples
>>> circ = Circuit().zz(0, 1, 0.15)