summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <55825613+luevano@users.noreply.github.com>2020-03-09 21:36:58 -0700
committerDavid Luevano Alvarado <55825613+luevano@users.noreply.github.com>2020-03-09 21:36:58 -0700
commit480f3868eaac886fbfbfabf709ee7f77464988c7 (patch)
tree67f5858abd9ac0086bbbc48d468977f0505a3eaa
parentb54d8570a1cc78a49751c39842d20a23527c9657 (diff)
CM O(n+1) to O(n)
-rw-r--r--ml_exp/representations.py3
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