R/tr.R

Defines functions tr

#' Trace function
#'
#' Matrix algebra
#' @param m a square matrix
#'
#' @noRd

tr <- 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 molaR package in your browser

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

molaR documentation built on Feb. 16, 2023, 10:33 p.m.