R/sqrtm_rs.R

Defines functions sqrtm_rs

Documented in sqrtm_rs

sqrtm_rs <- function(x) {
  # square root of a real symmetric matric by diagonalisation
  # warning: no check is done for symmetry. It is up to the user to call this function appropriately
  CL <- eigen(x, symmetric=TRUE) # C=CL$vectors will be then an orthogonal matrix, so C^{-1} == t(C) 
  #C  <- CL$vectors
  #L  <- CL$values
  #xsq <- C %*% diag(sqrt(L)) %*% t(C)
  xsq <- tcrossprod(CL$vectors %*% diag(sqrt(CL$values)), CL$vectors)
  return(xsq)
}
garciapintado/rDAF documentation built on May 25, 2019, 7:26 p.m.