braket.circuits.gates module¶
-
class
braket.circuits.gates.
H
[source]¶ 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
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
h
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction][source]¶ 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])
-
class
braket.circuits.gates.
I
[source]¶ 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
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
i
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction][source]¶ 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])
-
class
braket.circuits.gates.
X
[source]¶ 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)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
x
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction][source]¶ 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
braket.circuits.gates.
Y
[source]¶ 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)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
y
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction][source]¶ 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
braket.circuits.gates.
Z
[source]¶ 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)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
z
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction][source]¶ 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
braket.circuits.gates.
S
[source]¶ 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
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
s
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction][source]¶ 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])
-
class
braket.circuits.gates.
Si
[source]¶ 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
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
si
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction][source]¶ 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])
-
class
braket.circuits.gates.
T
[source]¶ 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
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
t
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction][source]¶ 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])
-
class
braket.circuits.gates.
Ti
[source]¶ 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
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
ti
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction][source]¶ 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])
-
class
braket.circuits.gates.
V
[source]¶ 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)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
v
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction][source]¶ 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
braket.circuits.gates.
Vi
[source]¶ 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)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
vi
(target: Union[Qubit, int, Iterable[Union[Qubit, int]]]) → Iterable[braket.circuits.instruction.Instruction][source]¶ 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
braket.circuits.gates.
Rx
(angle: float)[source]¶ 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`
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
rx
(target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction[source]¶ 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)
-
class
braket.circuits.gates.
Ry
(angle: float)[source]¶ 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`
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
ry
(target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction[source]¶ 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)
-
class
braket.circuits.gates.
Rz
(angle: float)[source]¶ 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`
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
rz
(target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction[source]¶ 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)
-
class
braket.circuits.gates.
PhaseShift
(angle: float)[source]¶ 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`
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
phaseshift
(target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction[source]¶ 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)
-
class
braket.circuits.gates.
CNot
[source]¶ 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
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
cnot
(control: Union[Qubit, int], target: Union[Qubit, int]) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CNot instruction.
Examples
>>> circ = Circuit().cnot(0, 1)
-
class
braket.circuits.gates.
Swap
[source]¶ 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
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
swap
(target1: Union[Qubit, int], target2: Union[Qubit, int]) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – Swap instruction.
Examples
>>> circ = Circuit().swap(0, 1)
-
class
braket.circuits.gates.
ISwap
[source]¶ 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
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
iswap
(target1: Union[Qubit, int], target2: Union[Qubit, int]) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – ISwap instruction.
Examples
>>> circ = Circuit().iswap(0, 1)
-
class
braket.circuits.gates.
PSwap
(angle: float)[source]¶ 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`
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
pswap
(target1: Union[Qubit, int], target2: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – PSwap instruction.
Examples
>>> circ = Circuit().pswap(0, 1, 0.15)
-
class
braket.circuits.gates.
XY
(angle: float)[source]¶ 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)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
xy
(target1: Union[Qubit, int], target2: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – XY instruction.
Examples
>>> circ = Circuit().xy(0, 1, 0.15)
-
class
braket.circuits.gates.
CPhaseShift
(angle: float)[source]¶ 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`
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
cphaseshift
(control: Union[Qubit, int], target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CPhaseShift instruction.
Examples
>>> circ = Circuit().cphaseshift(0, 1, 0.15)
-
class
braket.circuits.gates.
CPhaseShift00
(angle: float)[source]¶ 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`
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
cphaseshift00
(control: Union[Qubit, int], target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CPhaseShift00 instruction.
Examples
>>> circ = Circuit().cphaseshift00(0, 1, 0.15)
-
class
braket.circuits.gates.
CPhaseShift01
(angle: float)[source]¶ 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`
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
cphaseshift01
(control: Union[Qubit, int], target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CPhaseShift01 instruction.
Examples
>>> circ = Circuit().cphaseshift01(0, 1, 0.15)
-
class
braket.circuits.gates.
CPhaseShift10
(angle: float)[source]¶ 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`
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
cphaseshift10
(control: Union[Qubit, int], target: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CPhaseShift10 instruction.
Examples
>>> circ = Circuit().cphaseshift10(0, 1, 0.15)
-
class
braket.circuits.gates.
CY
[source]¶ 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
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
cy
(control: Union[Qubit, int], target: Union[Qubit, int]) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CY instruction.
Examples
>>> circ = Circuit().cy(0, 1)
-
class
braket.circuits.gates.
CZ
[source]¶ 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
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
cz
(control: Union[Qubit, int], target: Union[Qubit, int]) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CZ instruction.
Examples
>>> circ = Circuit().cz(0, 1)
-
class
braket.circuits.gates.
XX
(angle: float)[source]¶ 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)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
xx
(target1: Union[Qubit, int], target2: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – XX instruction.
Examples
>>> circ = Circuit().xx(0, 1, 0.15)
-
class
braket.circuits.gates.
YY
(angle: float)[source]¶ 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)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
yy
(target1: Union[Qubit, int], target2: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – YY instruction.
Examples
>>> circ = Circuit().yy(0, 1, 0.15)
-
class
braket.circuits.gates.
ZZ
(angle: float)[source]¶ 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)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
zz
(target1: Union[Qubit, int], target2: Union[Qubit, int], angle: float) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – ZZ instruction.
Examples
>>> circ = Circuit().zz(0, 1, 0.15)
-
class
braket.circuits.gates.
CCNot
[source]¶ 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
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
ccnot
(control1: Union[Qubit, int], control2: Union[Qubit, int], target: Union[Qubit, int]) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CCNot instruction.
Examples
>>> circ = Circuit().ccnot(0, 1, 2)
-
class
braket.circuits.gates.
CSwap
[source]¶ 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
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
to_matrix
() → numpy.ndarray[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
static
cswap
(control: Union[Qubit, int], target1: Union[Qubit, int], target2: Union[Qubit, int]) → braket.circuits.instruction.Instruction[source]¶ Registers this function into the circuit class.
- Parameters
- Returns
Instruction – CSwap instruction.
Examples
>>> circ = Circuit().cswap(0, 1, 2)
-
class
braket.circuits.gates.
Unitary
(matrix: numpy.ndarray, display_name: str = 'U')[source]¶ 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_matrix
()[source]¶ Returns a matrix representation of the gate
- Returns
np.ndarray – A matrix representation of the gate
-
to_ir
(target: braket.circuits.qubit_set.QubitSet)[source]¶ Returns IR object of gate and target
- Parameters
target (QubitSet) – target qubit(s)
- Returns
IR object of the gate and target
-
static
unitary
(targets: braket.circuits.qubit_set.QubitSet, matrix: numpy.ndarray, display_name: str = 'U') → braket.circuits.instruction.Instruction[source]¶ 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])