braket.default_simulator.operation_helpers module
- braket.default_simulator.operation_helpers.from_braket_instruction(instruction) GateOperation | KrausOperation[source]
Instantiates the concrete
GateOperationorKrausOperationobject from the specified Braket instruction.- Parameters:
instruction – instruction for a circuit specified using the
braket.ir.jacqdformat.- Returns:
GateOperation | KrausOperation – instance of the concrete GateOperation or KrausOperation class corresponding to the specified instruction.
- Raises:
NotImplementedError – If no concrete
GateOperationorKrausOperationclass has been registered for the instruction type.
- braket.default_simulator.operation_helpers.pauli_eigenvalues(num_qubits: int) ndarray[source]
The eigenvalues of Pauli operators and their tensor products.
- Parameters:
num_qubits (int) – the number of qubits the operator acts on
- Returns:
np.ndarray – the eigenvalues of a Pauli product operator of the given size
- braket.default_simulator.operation_helpers.ir_matrix_to_ndarray(matrix: list[list[list[float]]]) ndarray[source]
Converts a JAQCD matrix into a numpy array.
- Parameters:
(list[list[list[float]]] (matrix) – The IR representation of a matrix
- Returns:
np.ndarray – The numpy ndarray representation of the matrix
- braket.default_simulator.operation_helpers.check_matrix_dimensions(matrix: ndarray, targets: tuple[int, ...]) None[source]
Checks that the matrix is of the correct shape to act on the targets.
- Parameters:
matrix (np.ndarray) – The matrix to check
targets (tuple[int, ...]) – The target qubits the matrix acts on
- Raises:
ValueError – If the matrix is not a square matrix or operates on a space of different dimension than that generated by the target qubits
- braket.default_simulator.operation_helpers.check_unitary(matrix: ndarray)[source]
Checks that the given matrix is unitary.
- Parameters:
matrix (np.ndarray) – The matrix to check
- Raises:
ValueError – If the matrix is not unitary