def trace(matlist, K):
    result = K.zero
    for i in range(len(matlist)):
        result += matlist[i][i]
    return result
Returns the trace of a matrix.
dataset/ETHPy150Open sympy/sympy/sympy/matrices/densetools.py/trace