Skip to main content

trace

trace(matrix: any[] | Mat | Tensor) : number

param matrix - an Array, Mat or Tensor. Must be 2-D and square.

returns: number - The trace of the matrix.

This function returns the trace of the matrix given. The trace is the sum of the diagonal entries of a matrix. It is useful in certain applications and measurements of matrix properties.