From 38bab31a80202edb535e8e6bd46b4ffbef633801 Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Wed, 14 Dec 2011 15:05:55 +0100
Subject: [PATCH] Use axpy

---
 dune/tectonic/localnonlinearity.hh | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/dune/tectonic/localnonlinearity.hh b/dune/tectonic/localnonlinearity.hh
index d95e5724..4ba501e3 100644
--- a/dune/tectonic/localnonlinearity.hh
+++ b/dune/tectonic/localnonlinearity.hh
@@ -88,15 +88,13 @@ template <int dimension> class LocalNonlinearity {
       A[k][k] += (h2 - h1ox) * x[k] * x[k] / normX2 + h1ox;
   }
 
-  // TODO: do not evaluate at zero
   void addGradient(VectorType const &x, VectorType &y) const {
-    if (x.two_norm() <
-        1e-8 or std::isinf(func_->regularity(x.two_norm()))) // TODO
+    double const xnorm = x.two_norm();
+    if (xnorm < 1e-8 or std::isinf(func_->regularity(xnorm))) // TODO
       return;
 
-    VectorType tmp;
-    upperGradient(x, tmp); // upper and lower gradient coincide in this case
-    y += tmp;
+    // left and right differential coincide in this case
+    y.axpy(func_->rightDifferential(xnorm) / xnorm, x);
   }
 
   void upperGradient(VectorType const &x, VectorType &ret) const {
-- 
GitLab