diff options
author | David Luevano Alvarado <55825613+luevano@users.noreply.github.com> | 2020-03-09 21:36:58 -0700 |
---|---|---|
committer | David Luevano Alvarado <55825613+luevano@users.noreply.github.com> | 2020-03-09 21:36:58 -0700 |
commit | 480f3868eaac886fbfbfabf709ee7f77464988c7 (patch) | |
tree | 67f5858abd9ac0086bbbc48d468977f0505a3eaa | |
parent | b54d8570a1cc78a49751c39842d20a23527c9657 (diff) |
CM O(n+1) to O(n)
-rw-r--r-- | ml_exp/representations.py | 3 |
1 files changed, 2 insertions, 1 deletions
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 |