summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authorLars Buitinck <larsmans@gmail.com>2015-10-04 13:31:57 +0200
committerLars Buitinck <larsmans@gmail.com>2015-10-04 14:18:27 +0200
commit881849c5385524ceafc462d230960463a01e47a6 (patch)
treebb6b2503956205f9f6bc81a123f1b97c1f0a8d67 /numpy/lib/function_base.py
parentdf0afda4c69e9e1fd47afcb7d79236bc101c502f (diff)
downloadnumpy-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.py4
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):