AngledGate

class braket.circuits.angled_gate.AngledGate(angle, qubit_count, ascii_symbols)[source]

Bases: Gate, Parameterizable

Class AngledGate represents a quantum gate that operates on N qubits and an angle.

Parameters:

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_count is less than 1, ascii_symbols are None, or ascii_symbols length != qubit_count, or angle is None

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

bind_values(**kwargs)[source]

Takes in parameters and attempts to assign them to values.

Return type:

AngledGate

Returns:

AngledGate – A new Gate of the same type with the requested parameters bound.

Raises:

NotImplementedError – Subclasses should implement this function.

adjoint()[source]

Returns the adjoint of this gate as a singleton list.

Return type:

list[Gate]

Returns:

list[Gate] – A list containing the gate with negated angle.

class braket.circuits.angled_gate.DoubleAngledGate(angle_1, angle_2, qubit_count, ascii_symbols)[source]

Bases: Gate, Parameterizable

Class DoubleAngledGate represents a quantum gate that operates on N qubits and two angles.

Parameters:

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_count is less than 1, ascii_symbols are None, or ascii_symbols length != qubit_count, or angle_1 or angle_2 is None

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:

AngledGate

Returns:

AngledGate – A new Gate of the same type with the requested parameters bound.

Raises:

NotImplementedError – Subclasses should implement this function.

adjoint()[source]

Returns the adjoint of this gate as a singleton list.

Return type:

list[Gate]

Returns:

list[Gate] – A list containing the gate with negated angle.

class braket.circuits.angled_gate.TripleAngledGate(angle_1, angle_2, angle_3, qubit_count, ascii_symbols)[source]

Bases: Gate, Parameterizable

Class TripleAngledGate represents a quantum gate that operates on N qubits and three angles.

Parameters:

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_count is less than 1, ascii_symbols are None, or ascii_symbols length != qubit_count, or angle_1 or angle_2 or angle_3 is None

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:

AngledGate

Returns:

AngledGate – A new Gate of the same type with the requested parameters bound.

Raises:

NotImplementedError – Subclasses should implement this function.

adjoint()[source]

Returns the adjoint of this gate as a singleton list.

Return type:

list[Gate]

Returns:

list[Gate] – A list containing the gate with negated angle.

braket.circuits.angled_gate.angled_ascii_characters(gate, angle)[source]

Generates a formatted ascii representation of an angled gate.

Parameters:
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:

AngledGate

Returns:

AngledGate – A new gate of the type of the AngledGate originally used with all angles updated.