partial_trace
- partial_trace(matrix, sub_dims, keep, *, unp_inner=None)
Compute the partial trace of a matrix. The matrix may be a multidimensional array, with the partial trace taken over the last two dimensions.
- Parameters:
- Return type:
ndarray|Array- Returns:
The resulting matrix after tracing out the specified subsystems.
- Raises:
SimphonyError – If the matrix does not have at least two dimensions, is not square in its last two dimensions, or if the subdimensions do not match the matrix size.