diff options
author | Lars Buitinck <larsmans@gmail.com> | 2015-10-04 13:31:57 +0200 |
---|---|---|
committer | Lars Buitinck <larsmans@gmail.com> | 2015-10-04 14:18:27 +0200 |
commit | 881849c5385524ceafc462d230960463a01e47a6 (patch) | |
tree | bb6b2503956205f9f6bc81a123f1b97c1f0a8d67 /numpy/lib/function_base.py | |
parent | df0afda4c69e9e1fd47afcb7d79236bc101c502f (diff) | |
download | numpy-881849c5385524ceafc462d230960463a01e47a6.tar.gz |
ENH: halve the memory requirement of np.cov
Prevents allocation of an n²-sized array.
XXX For large arrays, multiplying by 1/fact is more than 10% faster
than dividing by fact, but that doesn't pass the tests.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 3c941ca5b..a0c9f1274 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -2286,7 +2286,9 @@ def cov(m, y=None, rowvar=1, bias=0, ddof=None, fweights=None, aweights=None): X_T = X.T else: X_T = (X*w).T - return (dot(X, X_T.conj())/fact).squeeze() + c = dot(X, X_T.conj()) + c /= fact + return c.squeeze() def corrcoef(x, y=None, rowvar=1, bias=np._NoValue, ddof=np._NoValue): |