Z <- matrix(runif(9), ncol = 3)
U <- eigen(Z %*% t(Z))$vectors
D1 <- diag(runif(3))
D2 <- diag(runif(3))
D3 <- diag(runif(3))
D4 <- diag(runif(3))
X.matrix <- rbind(t(U) %*% D1 %*% U, t(U) %*% D2 %*% U,
t(U) %*% D3 %*% U, t(U) %*% D4 %*% U)
res.matrix <- rjd(X.matrix)
res.matrix$V
round(U %*% res.matrix$V, 4) # should be a signed permutation
# matrix if V is correct.
round(res.matrix$D, 4)
X.array <- aperm(array(t(X.matrix), dim = c(3,3,4)), c(2,1,3))
res.array <- rjd(X.array)
round(res.array$D, 4)Run the code above in your browser using DataLab