From 480f3868eaac886fbfbfabf709ee7f77464988c7 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado <55825613+luevano@users.noreply.github.com> Date: Mon, 9 Mar 2020 21:36:58 -0700 Subject: CM O(n+1) to O(n) --- ml_exp/representations.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ml_exp/representations.py b/ml_exp/representations.py index 6a8cfcaf1..86e75eb31 100644 --- a/ml_exp/representations.py +++ b/ml_exp/representations.py @@ -60,7 +60,8 @@ size. Arrays are not of the right shape.') cm[i, i] = 0.5*nc[i]**2.4 # Calculates the values row-wise for faster timings. - for i in range(n): + # Don't calculate the last element (it's only the diagonal element). + for i in range(n - 1): rv = coords[i + 1:] - coords[i] r = np.linalg.norm(rv, axis=1)/cr val = nc[i]*nc[i +1:]/r -- cgit v1.2.3-54-g00ecf