From ade802ff66675e68904cf9fefe61f55014dfea90 Mon Sep 17 00:00:00 2001
From: Uli Sack <usack@math.fu-berlin.de>
Date: Thu, 24 May 2012 15:08:01 +0000
Subject: [PATCH] make positivity tolerance variable, to be set in constructor

[[Imported from SVN: r6271]]
---
 dune/solvers/norms/energynorm.hh | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/dune/solvers/norms/energynorm.hh b/dune/solvers/norms/energynorm.hh
index 280e95f8..86e68a17 100644
--- a/dune/solvers/norms/energynorm.hh
+++ b/dune/solvers/norms/energynorm.hh
@@ -28,14 +28,14 @@
         /** \brief The type used for the result */
         typedef typename DiscFuncType::field_type field_type;
 
-        EnergyNorm() : iterationStep_(NULL), matrix_(NULL) {}
+        EnergyNorm(const double tol=1e-10 ) : iterationStep_(NULL), matrix_(NULL), tol_(tol) {}
 
-        EnergyNorm(LinearIterationStep<OperatorType, DiscFuncType>& it) 
-            : iterationStep_(&it), matrix_(NULL)
+        EnergyNorm(LinearIterationStep<OperatorType, DiscFuncType>& it, const double tol=1e-10) 
+            : iterationStep_(&it), matrix_(NULL), tol_(tol)
         {}
 
-        EnergyNorm(const OperatorType& matrix) 
-            : iterationStep_(NULL), matrix_(&matrix)
+        EnergyNorm(const OperatorType& matrix, const double tol=1e-10) 
+            : iterationStep_(NULL), matrix_(&matrix), tol_(tol)
         {}
 
         void setMatrix(const OperatorType* matrix) {
@@ -81,7 +81,7 @@
 
             if (ret < 0)
             {
-                if (ret < -1e-13)
+                if (ret < -tol_)
                 {
                     char msg[1024];
                     sprintf(msg, "Supplied linear operator is not positive (semi-)definite: (u,Au) = %e", ret);
@@ -96,7 +96,8 @@
         /** \brief Compute the squared norm for a given vector and matrix
             \todo This could be implemented without the temporary. */
         static field_type normSquared(const DiscFuncType& u, 
-                                      const OperatorType& A)
+                                      const OperatorType& A,
+                                      const double tol=1e-10)
         {
             DiscFuncType tmp(u.size());
             tmp = 0;
@@ -106,7 +107,7 @@
 
             if (ret < 0)
             {
-                if (ret < -1e-13)
+                if (ret < -tol)
                 {
                     char msg[1024];
                     sprintf(msg, "Supplied linear operator is not positive (semi-)definite: (u,Au) = %e", ret);
@@ -125,6 +126,8 @@
 
         const OperatorType* matrix_;
 
+        const double tol_;
+
     };
 
 #endif
-- 
GitLab