Reputation: 570
R = randn(960,d); creates a matrix of random numbers.
I have another matrix X
of dimension 1000000 by 960
. When I am doing the operation
B = (X*R >=0) ;
I get the error
Error using *
Out of memory. Type HELP MEMORY for your options.
for d = 4096
. But, there is no error for d < 4096
esp. d = [32 64 128 256 512 1024 2048 ]
gives no problem except for cases of d>4096
. X has data elements that are in single precision format.
Typing memory
gives
Maximum possible array: 15663 MB (1.642e+010 bytes) *
Memory available for all arrays: 15663 MB (1.642e+010 bytes) *
Memory used by MATLAB: 4706 MB (4.935e+009 bytes)
Physical Memory (RAM): 8151 MB (8.547e+009 bytes)
* Limited by System Memory (physical + swap file) available.
I have no idea how I can solve this problem. I am running Matlab 64 bit 2011b version on Windows 64 bit OS with 8 GB RAM and i7 processor. Please help!
Upvotes: 1
Views: 129
Reputation: 3177
Here a little math comes handy.
In Matlab 1 element in single precision occupies 4 Bytes in memory whereas a 1 element in double precision occupies 8 Bytes.
The size of X
(single precision) is 1000000*960 elements, 4 Bytes each, for a total of 3.84 GB.
The size of R
(double precision) is 960*4096 elements, 8 Bytes each, for a total of 0.0315 GB.
Now the problem is the product X*R
, that must be preallocated and then evaluated in order to feed the logical indexing on B
. The matrix X*R
will have size 1000000*4096 and by supposing such matrix is in single precision (to my knowledge, the product between a double and a single is a single as well), it will occupy something like 16GB. This will most certainly clog both the physical and the virtual memory (and also 16GB is greater than the Maximum possible array
size from your memory command).
Upvotes: 1