X <- big_attachExtdata()
n <- nrow(X)
m <- ncol(X)
y <- rnorm(m)
test <- big_prodVec(X, y) # vector
true <- X[] %*% y # one-column matrix
all.equal(test, as.numeric(true))
# subsetting
ind.row <- sample(n, n/2)
ind.col <- sample(m, m/2)
tryCatch(test2 <- big_prodVec(X, y, ind.row, ind.col),
error = function(e) print(e))
# returns an error. You need to use the subset of y:
test2 <- big_prodVec(X, y[ind.col], ind.row, ind.col)
true2 <- X[ind.row, ind.col] %*% y[ind.col]
all.equal(test2, as.numeric(true2))
Run the code above in your browser using DataLab