tr function

Trace operator

Trace operator

Calculates the trace of a square matrix.

tr(x, ...)

Arguments

  • x: Square numeric matrix
  • ...: Additional arguments to lower level functions

Returns

numeric

Examples

tr(diag(1:5))

See Also

crossprod, tcrossprod

Author(s)

Klaus K. Holst

  • Maintainer: Klaus K. Holst
  • License: GPL-3
  • Last published: 2025-01-12