require(bigmemory)
A = as.big.matrix(matrix(1, nrow=3, ncol=2))
B <- big.matrix(2, 3, type="double", init=-1,
dimnames=list(NULL, c("alpha", "beta")), shared=FALSE)
C = big.matrix(3, 3, type="double", init=1,
dimnames=list(NULL, c("alpha", "beta", "gamma")), shared=FALSE)
2*A[,]%*%B[,]+0.5*C[,]
E = dgemm(ALPHA=2.0, A=A, B=B, BETA=0.5, C=C)
E[,] # Same result
# The big.matrix file backings will be deleted when garbage collected.
rm(A,B,C,E)
gc()
Run the code above in your browser using DataLab