pygsti.tools.trace¶
-
pygsti.tools.
trace
(M)¶ The trace of a matrix, sum_i M[i,i].
A memory leak in some version of numpy can cause repeated calls to numpy’s trace function to eat up all available system memory, and this function does not have this problem.
Parameters: M (numpy array) – the matrix (any object that can be double-indexed) Returns: The trace of M. Return type: element type of M