# braket.default_simulator.linalg_utils module¶

braket.default_simulator.linalg_utils.multiply_matrix(state: numpy.ndarray, matrix: numpy.ndarray, targets: Tuple[int, ...]) → numpy.ndarray[source]

Multiplies the given matrix by the given state, applying the matrix on the target qubits.

Parameters: state (np.ndarray) – The state to multiply the matrix by. matrix (np.ndarray) – The matrix to apply to the state. targets (Tuple[int]) – The qubits to apply the state on. np.ndarray – The state after the matrix has been applied.
braket.default_simulator.linalg_utils.marginal_probability(probabilities: numpy.ndarray, targets: List[int] = None) → numpy.ndarray[source]

Return the marginal probability of the computational basis states.

The marginal probability is obtained by summing the probabilities on the unused qubits. If no targets are specified, then the probability of all basis states is returned.

Parameters: probabilities (np.ndarray) – The probability distribution to marginalize. targets (List[int]) – The qubits of the marginal distribution; if no targets are specified, then the probability of all basis states is returned. np.ndarray – The marginal probability distribution.
braket.default_simulator.linalg_utils.partial_trace(density_matrix: numpy.ndarray, targets: Optional[List[int]] = None) → numpy.ndarray[source]

Returns the reduced density matrix for the target qubits.

If no target qubits are supplied, this method returns the trace of the density matrix.

Parameters: density_matrix (np.ndarray) – The density matrix to reduce, as a tensor product of qubit states. targets (List[int]) – The qubits of the output reduced density matrix; if no target qubits are supplied, this method returns the trace of the density matrix. np.ndarray – The partial trace of the density matrix.