From 23f40eae7597622576c71504f7da4d3c4b7da89a Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Fri, 12 Jul 2013 13:42:19 +0000
Subject: [PATCH] use real_type instead of hard-coded 'double'

[[Imported from SVN: r11784]]
---
 dune/solvers/solvers/loopsolver.cc | 18 +++++++++---------
 dune/solvers/solvers/loopsolver.hh |  5 +++++
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/dune/solvers/solvers/loopsolver.cc b/dune/solvers/solvers/loopsolver.cc
index 146d1d22..aba3bd41 100644
--- a/dune/solvers/solvers/loopsolver.cc
+++ b/dune/solvers/solvers/loopsolver.cc
@@ -66,11 +66,11 @@ void LoopSolver<VectorType, BitVectorType>::solve()
         std::cout << std::endl;
     }
 
-    double error = std::numeric_limits<double>::max();
+    real_type error = std::numeric_limits<real_type>::max();
 
-    double normOfOldCorrection = 1;
-    double normOfOldError = 0;
-    double totalConvRate = 1;
+    real_type normOfOldCorrection = 1;
+    real_type normOfOldError = 0;
+    real_type totalConvRate = 1;
     this->maxTotalConvRate_ = 0;
     int convRateCounter = 0;
 
@@ -88,14 +88,14 @@ void LoopSolver<VectorType, BitVectorType>::solve()
             this->writeIterate(iterationStep_->getSol(), i);
 
         // Compute error
-        double oldNorm = this->errorNorm_->operator()(oldSolution);
+        real_type oldNorm = this->errorNorm_->operator()(oldSolution);
 
-        double normOfError=std::numeric_limits<double>::quiet_NaN();
+        real_type normOfError=std::numeric_limits<real_type>::quiet_NaN();
 
         // Please don't replace this call to 'diff' by computing the norm of the difference.
         // In some nonlinear DD applications the 'diff' method may be nonlinear.
-        double normOfCorrection = this->errorNorm_->diff(oldSolution,iterationStep_->getSol());
-        double convRate = normOfCorrection / normOfOldCorrection;
+        real_type normOfCorrection = this->errorNorm_->diff(oldSolution,iterationStep_->getSol());
+        real_type convRate = normOfCorrection / normOfOldCorrection;
         error = normOfCorrection;
         normOfOldCorrection = normOfCorrection;
 
@@ -115,7 +115,7 @@ void LoopSolver<VectorType, BitVectorType>::solve()
         if (!isinf(convRate) && !isnan(convRate) && i>0)
         {
             totalConvRate *= convRate;
-            this->maxTotalConvRate_ = std::max(this->maxTotalConvRate_, std::pow(totalConvRate, 1/((double)convRateCounter+1)));
+            this->maxTotalConvRate_ = std::max(this->maxTotalConvRate_, std::pow(totalConvRate, 1/((real_type)convRateCounter+1)));
             convRateCounter++;
         }
 
diff --git a/dune/solvers/solvers/loopsolver.hh b/dune/solvers/solvers/loopsolver.hh
index caede049..4e786546 100644
--- a/dune/solvers/solvers/loopsolver.hh
+++ b/dune/solvers/solvers/loopsolver.hh
@@ -13,6 +13,11 @@
 template <class VectorType, class BitVectorType = Dune::BitSetVector<VectorType::block_type::dimension> >
 class LoopSolver : public IterativeSolver<VectorType, BitVectorType>
 {
+    typedef typename VectorType::field_type field_type;
+
+    // For complex-valued data
+    typedef typename Dune::FieldTraits<field_type>::real_type real_type;
+
 public:
 
     /** \brief Constructor taking all relevant data */
-- 
GitLab