R/tr.r

Defines functions tr

Documented in tr

#' Trace of a matrix
#' 
#' This function computes the trace of a matrix.
#' 
#' 
#' @param M square matrix
#' @return The trace of the matrix M.
#' @author Nicole Kraemer
#' @keywords math
#' @examples
#' 
#' M<-matrix(rnorm(8*8),ncol=8)
#' tr.M<-tr(M)
#' 
#' @export tr
tr<-function(M){
return(sum(diag(M)))
}

Try the plsdof package in your browser

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

plsdof documentation built on Dec. 1, 2022, 1:13 a.m.