braket.default_simulator.operation_helpers module

braket.default_simulator.operation_helpers.from_braket_instruction(instruction) GateOperation | 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(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

braket.default_simulator.operation_helpers.check_hermitian(matrix: 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[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