Skip to main content

trace

trace(input: any[][] | Mat | Tensor) : Number

param input - Any JavaScript 2d array, Mat, Tensor. Must be 2d and square though.

returns: Number - The trace of the matrix.

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