From 1f9b62cc9c204d0f3bd77c5fbe2e87d6895b160e Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Sun, 16 Oct 2011 00:27:14 +0200
Subject: [PATCH] Check the norm rather than each component

---
 src/samplefunctional.hh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/samplefunctional.hh b/src/samplefunctional.hh
index c64a608c..63849e74 100644
--- a/src/samplefunctional.hh
+++ b/src/samplefunctional.hh
@@ -35,7 +35,9 @@ template <int dimension> class SampleFunctional {
   }
 
   void descentDirection(const SmallVector x, SmallVector &ret) const {
-    if (x == SmallVector(0.0)) {
+    // Check the squared norm rather than each component because
+    // negative_projection() divides by it
+    if (x.two_norm2() == 0.0) {
       // If there is a direction of descent, this is it
       SmallVector const d = smoothGradient(x);
 
-- 
GitLab