summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2015-10-05 14:39:04 -0600
committerCharles Harris <charlesr.harris@gmail.com>2015-10-05 14:39:04 -0600
commitd5bde029dea303093ecd1f1190c5fb5a478fb414 (patch)
treeaecc4ec447479ea37adfca5decffc25c480a0252 /numpy/lib/function_base.py
parenteef84446662b3743a5dbf2c5ed41bf28c604535c (diff)
parent08e8c1415670b029c26ae8ce0585fb9ea0b11e63 (diff)
downloadnumpy-d5bde029dea303093ecd1f1190c5fb5a478fb414.tar.gz
Merge pull request #6396 from rudimeier/opt-corrcoef
MAINT: corrcoef, memory usage optimization
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 2229682ce..e3c2cd193 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -2352,7 +2352,11 @@ def corrcoef(x, y=None, rowvar=1, bias=np._NoValue, ddof=np._NoValue):
except ValueError: # scalar covariance
# nan if incorrect value (nan, inf, 0), 1 otherwise
return c / c
- return c / sqrt(multiply.outer(d, d))
+ d = sqrt(d)
+ # calculate "c / multiply.outer(d, d)" row-wise ... for memory and speed
+ for i in range(0, d.size):
+ c[i,:] /= (d * d[i])
+ return c
def blackman(M):