QuantumOperator
- class braket.circuits.quantum_operator.QuantumOperator(qubit_count, ascii_symbols)[source]
Bases:
OperatorA quantum operator is the definition of a quantum operation for a quantum device.
- Parameters:
qubit_count (
int|None)ascii_symbols (
Sequence[str])
Initializes a
QuantumOperator.- Parameters:
qubit_count (int | None) – Number of qubits this quantum operator acts on. If all instances of the operator act on the same number of qubits, this argument should be
None, andfixed_qubit_countshould be implemented to return the qubit count; iffixed_qubit_countis implemented and an int is passed in, it must equalfixed_qubit_count, or instantiation will raise a ValueError. An int must be passed in if instances can have a varying number of qubits, in which casefixed_qubit_countshould not be implemented,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:
TypeError –
qubit_countis not an intValueError –
qubit_countis less than 1,ascii_symbolsareNone,fixed_qubit_countis implemented and and not equal toqubit_count, orlen(ascii_symbols) != qubit_count
- static fixed_qubit_count()[source]
Returns the number of qubits this quantum operator acts on, if instances are guaranteed to act on the same number of qubits.
If different instances can act on a different number of qubits, this method returns
NotImplemented.- Return type:
int- Returns:
int – The number of qubits this quantum operator acts on.
- property qubit_count: int
The number of qubits this quantum operator acts on.
- Type:
int
- property ascii_symbols: tuple[str, ...]
Returns the ascii symbols for the quantum operator.
- Type:
tuple[str, …]
- property name: str
Returns the name of the quantum operator
- Returns:
str – The name of the quantum operator as a string
- to_ir(*args, **kwargs)[source]
Returns IR representation of quantum operator.
- Parameters:
*args (Any) – Not Implemented.
**kwargs (Any) – Not Implemented.
- Raises:
NotImplementError – Not Implemented.
- Return type:
Any- Returns:
Any – The the canonical intermediate representation of the operator.
- to_matrix(*args, **kwargs)[source]
Returns a matrix representation of the quantum operator.
- Parameters:
*args (Any) – Not Implemented.
**kwargs (Any) – Not Implemented.
- Raises:
NotImplementError – Not Implemented.
- Return type:
ndarray- Returns:
np.ndarray – A matrix representation of the quantum operator
- matrix_equivalence(other)[source]
Whether the matrix form of two quantum operators are equivalent
- Parameters:
other (QuantumOperator) – Quantum operator instance to compare this quantum operator to
- Return type:
bool- Returns:
bool – If matrix forms of this quantum operator and the other quantum operator are equivalent