R/Trace.R

Defines functions .Trace

# Finds the trace of a _SQUARE_ matrix
.Trace <- function(m) 
{
  if ( !is.matrix(m) || (dim(m)[1] != dim(m)[2]) ) stop("m must be a square matrix")
  
  return( sum(diag(m)) )
}

Try the synlik package in your browser

Any scripts or data that you put into this service are public.

synlik documentation built on March 7, 2023, 8:39 p.m.