R/wrappers.R
trace.Rd
Returns the trace (sum of diagonal elements) of a square matrix or aMatrix.
aMatrix
trace(x)
A square matrix, sparse sparseMatrix, or aMatrix.
sparseMatrix
A single numeric scalar equal to the sum of diagonal elements.
trace(diag(1:4)) #> [1] 10