I'm using the bigmemory package. I want to calculate w. My v length is 478000 and k length is 240500. The two matrix multiplication is w very large.
I run the code by loop, but it still is running and is not finished yet and I don't know if will give me the result or not.
I tried to calculate it without the for loop, but I got and error. Please any help to correct my code to make it fast.
v <-read.big.matrix('v.dat',type='double')
k <-read.big.matrix('k.dat',type='double')
m=length(v);
n=length(k);
for(i in 1:m)
{
for(j in 1:n)
{
w[i,j] = 2 * cos(dt * v[i] * k[j]) - 2
}
}
How I can define w before the loop because the size of w is very large I couldn't do like w <- matrix(nr,ncol)
.