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 Oct. 3, 2023, 5:09 p.m.