R/02_algebrahelpers_matrixexponent.R

'%^%' <- function(A,b, tol = 1e-10) {
  if (b==0){
    return(diag(nrow(A)))
  } else {
    res <- Reduce('%*%',rep(list(A),b)) 
    # Tolerance:
    res[abs(res) < tol] <- 0
    as(res, "Matrix")
  }
}

Try the psychonetrics package in your browser

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

psychonetrics documentation built on June 22, 2024, 10:29 a.m.