braket.circuits.quantum_operator_helpers module

braket.circuits.quantum_operator_helpers.verify_quantum_operator_matrix_dimensions(matrix: ndarray) None[source]

Verifies matrix is square and matrix dimensions are positive powers of 2, raising ValueError otherwise.

Parameters:

matrix (ndarray) – matrix to verify

Raises:

ValueError – If matrix is not a two-dimensional square matrix, or has a dimension length that is not a positive power of 2

braket.circuits.quantum_operator_helpers.is_hermitian(matrix: ndarray) bool[source]

Whether matrix is Hermitian

A square matrix \(U\) is Hermitian if

\[U = U^\dagger\]

where \(U^\dagger\) is the conjugate transpose of \(U\).

Parameters:

matrix (ndarray) – matrix to verify

Returns:

bool – If matrix is Hermitian

braket.circuits.quantum_operator_helpers.is_square_matrix(matrix: ndarray) bool[source]

Whether matrix is square, meaning it has exactly two dimensions and the dimensions are equal

Parameters:

matrix (np.ndarray) – matrix to verify

Returns:

bool – If matrix is square

braket.circuits.quantum_operator_helpers.is_unitary(matrix: ndarray) bool[source]

Whether matrix is unitary

A square matrix \(U\) is unitary if

\[UU^\dagger = I\]

where \(U^\dagger\) is the conjugate transpose of \(U\) and \(I\) is the identity matrix.

Parameters:

matrix (np.ndarray) – matrix to verify

Returns:

bool – If matrix is unitary

braket.circuits.quantum_operator_helpers.is_cptp(matrices: Iterable[ndarray]) bool[source]

Whether a transformation defined by these matrices as Kraus operators is a completely positive trace preserving (CPTP) map. This is the requirement for a transformation to be a quantum channel. Reference: Section 8.2.3 in Nielsen & Chuang (2010) 10th edition.

Parameters:

matrices (Iterable[ndarray]) – List of matrices representing Kraus operators.

Returns:

bool – If the matrices define a CPTP map.

braket.circuits.quantum_operator_helpers.get_pauli_eigenvalues(num_qubits: int) ndarray[source]

Get the eigenvalues of Pauli operators and their tensor products as an immutable Numpy ndarray.

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