# NOT RUN {
## Generate random data.
p <- c(2, 3, 4)
X <- array(stats::rnorm(prod(p)), dim = p)
## Calculate HOOI
r <- c(2, 2, 2)
hooi_x <- hooi(X, r = r)
G <- hooi_x$G
U <- hooi_x$U
## Reconstruct the hooi approximation.
X_approx <- atrans(G, U)
fnorm(X - X_approx)
# }
Run the code above in your browser using DataLab