3 # (Slower, but trusted) R version of Moments_M2
4 .Moments_M2_R = function(X,Y)
12 M21 = M2_1 = tensor(v,v)
14 M21 = M21 + Y[i] * tensor(X[i,],X[i,])
21 L = L + Y[i]*tensor(e[,j],e[,j])
30 test_that("both versions of Moments_M2 agree on various inputs",
36 X = matrix( runif(n*d,min=-1,max=1), nrow=n )
37 Y = runif(n,min=-1,max=1)
39 M2_R = .Moments_M2_R(X,Y)
40 expect_equal(max(abs(M2 - M2_R)), 0)