From 5bd499e50743397e505af756429daad1033fc1f9 Mon Sep 17 00:00:00 2001
From: Christoph Groth <christoph.groth@cea.fr>
Date: Tue, 25 Apr 2017 11:53:39 +0200
Subject: [PATCH] lll: small optimization

---
 kwant/linalg/lll.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kwant/linalg/lll.py b/kwant/linalg/lll.py
index c9f2540f..117707d5 100644
--- a/kwant/linalg/lll.py
+++ b/kwant/linalg/lll.py
@@ -156,12 +156,12 @@ def cvp(vec, basis, n=1):
         point_coords -= vec.T
         distances = np.sqrt(np.sum(point_coords**2, 1))
         order = np.argsort(distances)
-        distances = distances[order]
-        if distances[n - 1] < nth_dist:
-            nth_dist = distances[n - 1]
+        new_nth_dist = distances[order[n - 1]]
+        if new_nth_dist < nth_dist:
+            nth_dist = new_nth_dist
             rad += 1
         else:
-            return np.array(points[order][:n], int)
+            return np.array(points[order[:n]], int)
 
 
 def voronoi(basis):
-- 
GitLab