braket.circuits.quantum_operator module

class braket.circuits.quantum_operator.QuantumOperator(qubit_count: int, ascii_symbols: Sequence[str])[source]

Bases: braket.circuits.operator.Operator

A quantum operator is the definition of a quantum operation for a quantum device.

Parameters
  • qubit_count (int) – Number of qubits this quantum operator interacts with.

  • ascii_symbols (Sequence[str]) – ASCII string symbols for the quantum operator. 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

ValueErrorqubit_count is less than 1, ascii_symbols are None, or ascii_symbols length != qubit_count

property qubit_count

Returns number of qubits this quantum operator interacts with.

Type

int

property ascii_symbols

Returns the ascii symbols for the quantum operator.

Type

List[str]

property name

Returns the name of the quantum operator

Returns

The name of the quantum operator as a string

to_ir(*args, **kwargs) → Any[source]

Returns IR representation of quantum operator

Parameters
  • *args – Positional arguments

  • **kwargs – Keyword arguments

to_matrix(*args, **kwargs) → Any[source]

Returns a matrix representation of the quantum operator

Returns

np.ndarray – A matrix representation of the quantum operator

matrix_equivalence(other)[source]

Whether the matrix form of two gates are equivalent

Parameters

other (Gate) – Gate instance to compare this quantum operator to

Returns

bool – If matrix forms of this quantum operator and the other quantum operator are equivalent