R/matTr.R

Defines functions matTr2 matTr

matTr <- function(a,b) {
  # trace of a %*% b; dimensions of a and b should match.
  if (!identical(dim(a), dim(b))){
    stop("Dimensions do not match!")
  } else {
    crossprodCpp(as.vector(a), as.vector(t(b)))
  }
}

matTr2 <- function(z) sum(diag(z))

Try the netgsa package in your browser

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

netgsa documentation built on Nov. 14, 2023, 5:09 p.m.