test_that("generalized eigenvectors are B-orthonormal", { set.seed(1) n <- 10 T_len <- 6 X <- list( lapply(seq_len(n), function(i) matrix(rnorm(T_len * 3), T_len, 3)), lapply(seq_len(n), function(i) matrix(rnorm(T_len * 2), T_len, 2)) ) fit <- mcca_fit(method = "kernel", X = X, ncomp = 2) V <- do.call(rbind, fit$weights) B <- fit$B M <- t(V) %*% B %*% V expect_equal(M, diag(ncol(M)), tolerance = 1e-6) })