[Numpy-discussion] speed of numpy vs matlab on dot product
Paulo Jose da Silva e Silva
pjssilva at ime.usp.br
Sun Jun 11 18:03:18 CDT 2006
Em Sáb, 2006-06-10 às 15:15 -0700, JJ escreveu:
> python
> import numpy
> import scipy
> a = scipy.random.normal(0,1,[10000,2000])
> b = scipy.random.normal(0,1,[10000,2000])
> c = scipy.dot(a,scipy.transpose(b))
Interesting enough, I may have found "the reason". I am using only numpy
(as I don't have scipy compiled and it is not necessary to the code
above).
The problem is probably memory consumption. Let me explain.
After creating a, ipython reports 160Mb of memory usage. After creating
b, 330Mb. But when I run the last line, the memory footprint jumps to
1.2gb! This is four times the original memory consumption. In my
computer the result is swapping and the calculation would take forever.
Why is the memory usage getting so high?
Paulo
Obs: As a side not. If you decrease the matrix sizes (like for example
2000x2000), numpy and matlab spend basically the same time. If the
transpose imposes some penalty for numpy, it imposes the same penalty
for matlab (version 6.5, R13).
More information about the Numpy-discussion
mailing list