AngledGate
- class braket.circuits.angled_gate.AngledGate(angle, qubit_count, ascii_symbols)[source]
Bases:
Gate,ParameterizableClass
AngledGaterepresents a quantum gate that operates on N qubits and an angle.- Parameters:
angle (
float|FreeParameterExpression)qubit_count (
int|None)ascii_symbols (
Sequence[str])
Initializes an
AngledGate.- Parameters:
angle (float | FreeParameterExpression) – The angle of the gate in radians or expression representation.
qubit_count (int | None) – 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_countis less than 1,ascii_symbolsareNone, orascii_symbolslength !=qubit_count, orangleisNone
- property parameters: list[float | FreeParameterExpression]
Returns the parameters associated with the object, either unbound free parameters or bound values.
- Returns:
list[float | FreeParameterExpression] – The free parameters or fixed value associated with the object.
- property angle: float | FreeParameterExpression
Returns the angle of the gate
- Returns:
float | FreeParameterExpression – The angle of the gate in radians
- class braket.circuits.angled_gate.DoubleAngledGate(angle_1, angle_2, qubit_count, ascii_symbols)[source]
Bases:
Gate,ParameterizableClass
DoubleAngledGaterepresents a quantum gate that operates on N qubits and two angles.- Parameters:
angle_1 (
float|FreeParameterExpression)angle_2 (
float|FreeParameterExpression)qubit_count (
int|None)ascii_symbols (
Sequence[str])
Inits a
DoubleAngledGate.- Parameters:
angle_1 (float | FreeParameterExpression) – The first angle of the gate in radians or expression representation.
angle_2 (float | FreeParameterExpression) – The second angle of the gate in radians or expression representation.
qubit_count (int | None) – 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
qubit_countis less than 1,ascii_symbolsareNone, orascii_symbolslength !=qubit_count, orangle_1orangle_2isNone
- property parameters: list[float | FreeParameterExpression]
Returns the parameters associated with the object, either unbound free parameters or bound values.
- Returns:
list[float | FreeParameterExpression] – The free parameters or fixed value associated with the object.
- property angle_1: float | FreeParameterExpression
Returns the first angle of the gate
- Returns:
float | FreeParameterExpression – The first angle of the gate in radians
- property angle_2: float | FreeParameterExpression
Returns the second angle of the gate
- Returns:
float | FreeParameterExpression – The second angle of the gate in radians
- bind_values(**kwargs)[source]
Takes in parameters and attempts to assign them to values.
- Parameters:
**kwargs (FreeParameterExpression | str) – The parameters that are being assigned.
- Return type:
- Returns:
AngledGate – A new Gate of the same type with the requested parameters bound.
- Raises:
NotImplementedError – Subclasses should implement this function.
- class braket.circuits.angled_gate.TripleAngledGate(angle_1, angle_2, angle_3, qubit_count, ascii_symbols)[source]
Bases:
Gate,ParameterizableClass
TripleAngledGaterepresents a quantum gate that operates on N qubits and three angles.- Parameters:
angle_1 (
float|FreeParameterExpression)angle_2 (
float|FreeParameterExpression)angle_3 (
float|FreeParameterExpression)qubit_count (
int|None)ascii_symbols (
Sequence[str])
Inits a
TripleAngledGate.- Parameters:
angle_1 (float | FreeParameterExpression) – The first angle of the gate in radians or expression representation.
angle_2 (float | FreeParameterExpression) – The second angle of the gate in radians or expression representation.
angle_3 (float | FreeParameterExpression) – The third angle of the gate in radians or expression representation.
qubit_count (int | None) – 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
qubit_countis less than 1,ascii_symbolsareNone, orascii_symbolslength !=qubit_count, orangle_1orangle_2orangle_3isNone
- property parameters: list[float | FreeParameterExpression]
Returns the parameters associated with the object, either unbound free parameters or bound values.
- Returns:
list[float | FreeParameterExpression] – The free parameters or fixed value associated with the object.
- property angle_1: float | FreeParameterExpression
Returns the first angle of the gate
- Returns:
float | FreeParameterExpression – The first angle of the gate in radians
- property angle_2: float | FreeParameterExpression
Returns the second angle of the gate
- Returns:
float | FreeParameterExpression – The second angle of the gate in radians
- property angle_3: float | FreeParameterExpression
Returns the third angle of the gate
- Returns:
float | FreeParameterExpression – The third angle of the gate in radians
- bind_values(**kwargs)[source]
Takes in parameters and attempts to assign them to values.
- Parameters:
**kwargs (FreeParameterExpression | str) – The parameters that are being assigned.
- Return type:
- Returns:
AngledGate – A new Gate of the same type with the requested parameters bound.
- Raises:
NotImplementedError – Subclasses should implement this function.
- braket.circuits.angled_gate.angled_ascii_characters(gate, angle)[source]
Generates a formatted ascii representation of an angled gate.
- Parameters:
gate (str) – The name of the gate.
angle (float | FreeParameterExpression) – The angle for the gate.
- Return type:
str- Returns:
str – Returns the ascii representation for an angled gate.
- braket.circuits.angled_gate.get_angle(gate, **kwargs)[source]
Gets the angle with all values substituted in that are requested.
- Parameters:
gate (AngledGate) – The subclass of AngledGate for which the angle is being obtained.
**kwargs (FreeParameterExpression | str) – The named parameters that are being filled for a particular gate.
- Return type:
- Returns:
AngledGate – A new gate of the type of the AngledGate originally used with all angles updated.