braket.default_simulator.operation_helpers module

braket.default_simulator.operation_helpers.from_braket_instruction(instruction) → Union[braket.default_simulator.operation.GateOperation, braket.default_simulator.operation.KrausOperation][source]

Instantiates the concrete GateOperation or KrausOperation object from the specified Braket instruction.

Parameters:instruction – instruction for a circuit specified using the braket.ir.jacqd format.
Returns:Union[GateOperation, KrausOperation] – instance of the concrete GateOperation or KrausOperation class corresponding to the specified instruction.
Raises:NotImplementedError – If no concrete GateOperation or KrausOperation class has been registered for the instruction type.
braket.default_simulator.operation_helpers.pauli_eigenvalues[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]]]) → numpy.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: numpy.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: numpy.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
braket.default_simulator.operation_helpers.check_hermitian(matrix: numpy.ndarray)[source]

Checks that the given matrix is Hermitian.

Parameters:matrix (np.ndarray) – The matrix to check
Raises:ValueError – If the matrix is not Hermitian
braket.default_simulator.operation_helpers.check_cptp(matrices: List[numpy.ndarray])[source]

Checks that the given matrices define a CPTP map.

Parameters:matrices (List[np.ndarray]) – The matrices to check
Raises:ValueError – If the matrices do not define a CPTP map