There was an error while loading. Please reload this page.
Returns the trace of a square tensor: the sum of its diagonal elements.
This function is located in the pymath module. See pymath for the matrix and tensor representation.
pymath
t = pymath.trace(A)
A
n × n
r
A[k][k]…[k]
t
number
0
local A = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} local t = pymath.trace(A) -- t == 15 -- 1 + 5 + 9
Minimum PYTHA Version: V27
pymath, pymath.determinant, pymath.dot