I am currently trying to implement a SVD of a very large matrix using bigmemory and irlba. As far as I understand I have to adjust the mult command in the irlba package, which I have done like this:
mult <- function(A, B, transpose=FALSE) {
if(is.null(dim(B))) B <- cbind(B)
if(transpose)
return(cbind((t(B) %*% A)[]))
cbind((A %*% B)[])
}
However, it does not work to run an SVD on a bigmatrix using irlba:
irlbaObject <- irlba(big, nv = 10, mult = mult)
For replicability here is an example of a big matrix I want to do a SVD on:
big <- file("big.txt", open = "a")
replicate(20, {
x <- matrix(rnorm(100 * 100), nrow = 10)
write.table(x, file = 'big.txt', append = TRUE,
row.names = FALSE, col.names = FALSE)
})
big <- read.big.matrix("big.txt", separated = FALSE,
type = "double",
backingfile = "big.bk",
backingpath = "/tmp",
descriptorfile = "big.desc")
This is the error message I get:
Error in A %*% B : requires numeric/complex matrix/vector arguments
Called from: cbind((A %*% B)[])
Does anyone have an idea how to avoid this error?