library(Rfast)
n <- 2000
p <- 3
Y <- matrnorm(n, p, seed = 1) * 10
# decorrelate with implicit whitening matrix
# give same result as explicity whitening matrix
ecl <- eclairs(Y, compute = "covariance")
# get explicit whitening matrix
W <- getWhiteningMatrix(ecl)
# apply explicit whitening matrix
Z1 <- tcrossprod(Y, W)
# use implicit whitening matrix
Z2 <- decorrelate(Y, ecl)
range(Z1 - Z2)
Run the code above in your browser using DataLab