X <- big_attachExtdata()
n <- nrow(X)
m <- ncol(X)
A <- matrix(0, n, 10); A[] <- rnorm(length(A))
test <- big_cprodMat(X, A)
true <- crossprod(X[], A)
all.equal(test, true)
X2 <- big_copy(X, type = "double")
all.equal(crossprod(X2, A), true)
# subsetting
ind.row <- sample(n, n/2)
ind.col <- sample(m, m/2)
tryCatch(test2 <- big_cprodMat(X, A, ind.row, ind.col),
error = function(e) print(e))
# returns an error. You need to use the subset of A:
test2 <- big_cprodMat(X, A[ind.row, ], ind.row, ind.col)
true2 <- crossprod(X[ind.row, ind.col], A[ind.row, ])
all.equal(test2, true2)
Run the code above in your browser using DataLab