From 2201d09e2ed4d7af46efe946d6a0a03f33a36742 Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Wed, 6 Mar 2013 21:08:38 +0000
Subject: [PATCH] fabs -> std::abs, sqrt -> std::sqrt

[[Imported from SVN: r8175]]
---
 .../iterationsteps/projectedlinegsstep.cc      |  2 ++
 .../iterationsteps/truncatedblockgsstep.hh     |  6 ++++--
 dune/solvers/norms/diagnorm.hh                 | 10 ++++++----
 dune/solvers/norms/energynorm.hh               |  4 +++-
 dune/solvers/norms/fullnorm.hh                 | 10 ++++++----
 dune/solvers/norms/h1seminorm.hh               |  2 ++
 dune/solvers/norms/pnorm.hh                    | 18 ++++++++++--------
 dune/solvers/norms/twonorm.hh                  |  2 +-
 dune/solvers/solvers/tcgsolver.hh              |  2 ++
 dune/solvers/test/multigridtest.cc             |  3 ++-
 10 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/dune/solvers/iterationsteps/projectedlinegsstep.cc b/dune/solvers/iterationsteps/projectedlinegsstep.cc
index 4b66a694..d2c8dc70 100755
--- a/dune/solvers/iterationsteps/projectedlinegsstep.cc
+++ b/dune/solvers/iterationsteps/projectedlinegsstep.cc
@@ -1,5 +1,7 @@
 #include <dune/istl/scaledidmatrix.hh>
 
+#include <cmath>
+
 #include <dune/solvers/iterationsteps/projectedblockgsstep.hh>
 #include <dune/solvers/norms/energynorm.hh>
 
diff --git a/dune/solvers/iterationsteps/truncatedblockgsstep.hh b/dune/solvers/iterationsteps/truncatedblockgsstep.hh
index 67b9accf..dae872c2 100644
--- a/dune/solvers/iterationsteps/truncatedblockgsstep.hh
+++ b/dune/solvers/iterationsteps/truncatedblockgsstep.hh
@@ -1,6 +1,8 @@
 #ifndef TRUNCATED_BLOCK_GAUSS_SEIDEL_STEP_HH
 #define TRUNCATED_BLOCK_GAUSS_SEIDEL_STEP_HH
 
+#include <cmath>
+
 #include <dune/common/bitsetvector.hh>
 
 #include <dune/solvers/iterationsteps/lineariterationstep.hh>
@@ -217,7 +219,7 @@ public:
                 for(typename MBlock::size_type i=0; i<Aii.N(); ++i)
                 {
                     const typename MBlock::field_type& aii = Aii[i][i];
-                    if (fabs(aii)>1e-13)
+                    if (std::abs(aii)>1e-13)
                     {
                         if (not(ignore[row][i]))
                         {
@@ -262,7 +264,7 @@ public:
             for(typename MBlock::size_type i=0; i<A.N(); ++i)
             {
                 const typename MBlock::field_type& aii = A[i][i];
-                if (fabs(aii)>1e-13)
+                if (std::abs(aii)>1e-13)
                 {
                     if (not(ignore[i]))
                     {
diff --git a/dune/solvers/norms/diagnorm.hh b/dune/solvers/norms/diagnorm.hh
index 4a047a88..b3c94111 100644
--- a/dune/solvers/norms/diagnorm.hh
+++ b/dune/solvers/norms/diagnorm.hh
@@ -3,6 +3,8 @@
 #ifndef DIAGNORM_HH
 #define DIAGNORM_HH
 
+#include <cmath>
+
 #include <dune/common/fvector.hh>
 #include <dune/istl/bvector.hh>
 
@@ -37,7 +39,7 @@ class DiagNorm:
                 r += Dv*v[row];
             }
 
-            return sqrt(fabs(alpha * r));
+            return std::sqrt(std::abs(alpha * r));
         }
 
         //! Compute the norm of the difference of two vectors
@@ -52,7 +54,7 @@ class DiagNorm:
                 r += Dv*(v1[row]-v2[row]);
             }
 
-            return sqrt(fabs(alpha * r));
+            return std::sqrt(std::abs(alpha * r));
         }
 
     private:
@@ -83,7 +85,7 @@ class DiagNorm<Dune::BlockVector<Dune::FieldVector <double,1> >, Dune::BlockVect
             for(SizeType row = 0; row < v.size(); ++row)
                 r += d[row] * v[row] * v[row];
 
-            return sqrt(fabs(alpha * r));
+            return std::sqrt(std::abs(alpha * r));
         }
 
         //! Compute the norm of the difference of two vectors
@@ -94,7 +96,7 @@ class DiagNorm<Dune::BlockVector<Dune::FieldVector <double,1> >, Dune::BlockVect
             for (SizeType row = 0; row < v1.size(); ++row)
                 r += (double)d[row] * (v1[row]-v2[row]) * (v1[row] - v2[row]);
 
-            return sqrt(fabs(alpha * r));
+            return std::sqrt(std::abs(alpha * r));
         }
 
     private:
diff --git a/dune/solvers/norms/energynorm.hh b/dune/solvers/norms/energynorm.hh
index e6f3f00f..686e60d4 100644
--- a/dune/solvers/norms/energynorm.hh
+++ b/dune/solvers/norms/energynorm.hh
@@ -1,6 +1,8 @@
 #ifndef ENERGY_NORM_HH
 #define ENERGY_NORM_HH
 
+#include <cmath>
+
 #include "norm.hh"
 #include <dune/solvers/iterationsteps/lineariterationstep.hh>
 
@@ -59,7 +61,7 @@
         //! Compute the norm of the given vector
         double operator()(const DiscFuncType& f) const 
         {
-            return sqrt(this->EnergyNorm<OperatorType,DiscFuncType>::normSquared(f));
+            return std::sqrt(this->EnergyNorm<OperatorType,DiscFuncType>::normSquared(f));
         }
 
         /** \brief Compute the square of the norm of the given vector
diff --git a/dune/solvers/norms/fullnorm.hh b/dune/solvers/norms/fullnorm.hh
index 0191cb02..51d5dd1c 100644
--- a/dune/solvers/norms/fullnorm.hh
+++ b/dune/solvers/norms/fullnorm.hh
@@ -3,6 +3,8 @@
 #ifndef FULLNORM_HH
 #define FULLNORM_HH
 
+#include <cmath>
+
 #include <dune/common/fvector.hh>
 #include <dune/istl/bvector.hh>
 
@@ -33,7 +35,7 @@ class FullNorm: public Norm<VectorType>
 
             lowRankFactor_.umv(v,r);
 
-            return sqrt(fabs(alpha*(r*r)));
+            return std::sqrt(std::abs(alpha*(r*r)));
         }
 
     //! Compute the norm of the difference of two vectors
@@ -46,7 +48,7 @@ class FullNorm: public Norm<VectorType>
                 for (typename LowRankFactor::size_type i=0; i<lowRankFactor_.M(); ++i)
                     lowRankFactor_[k][i].umv(v1[i]-v2[i],r[k]);
 
-            return sqrt(fabs(alpha*(r*r)));
+            return std::sqrt(std::abs(alpha*(r*r)));
         }
 
     private:
@@ -77,7 +79,7 @@ class FullNorm<Dune::BlockVector<Dune::FieldVector<double,1> >, Dune::BlockVecto
             for (SizeType row = 0; row < v.size(); ++row)
                 r += m[row] * v[row];
 
-            return sqrt(fabs(alpha*r*r));
+            return std::sqrt(std::abs(alpha*r*r));
         }
 
         //! Compute the norm of the difference of two vectors
@@ -88,7 +90,7 @@ class FullNorm<Dune::BlockVector<Dune::FieldVector<double,1> >, Dune::BlockVecto
             for (SizeType row = 0; row < v1.size(); ++row)
                 r += (double)m[row] * (v1[row] - v2[row]);
 
-            return sqrt(fabs(alpha*r*r));
+            return std::sqrt(std::abs(alpha*r*r));
         }
 
     private:
diff --git a/dune/solvers/norms/h1seminorm.hh b/dune/solvers/norms/h1seminorm.hh
index 33bd77b1..e7a4e9fb 100644
--- a/dune/solvers/norms/h1seminorm.hh
+++ b/dune/solvers/norms/h1seminorm.hh
@@ -1,6 +1,8 @@
 #ifndef DUNE_H1_SEMINORM_HH
 #define DUNE_H1_SEMINORM_HH
 
+#include <cmath>
+
 #include <dune/common/fmatrix.hh>
 #include <dune/istl/bcrsmatrix.hh>
 
diff --git a/dune/solvers/norms/pnorm.hh b/dune/solvers/norms/pnorm.hh
index c12584a4..ca044338 100644
--- a/dune/solvers/norms/pnorm.hh
+++ b/dune/solvers/norms/pnorm.hh
@@ -1,6 +1,8 @@
 #ifndef __PNORM__HH__
 #define __PNORM__HH__
 
+#include <cmath>
+
 #include <dune/common/fvector.hh>
 #include <dune/istl/bvector.hh>
 
@@ -24,7 +26,7 @@ class PNorm: public Norm<Vector>
 			{
 				for(int row = 0; row < v.size(); ++row)
 				{
-					double z = fabs(v[row]);
+					double z = std::abs(v[row]);
 					if (r<z)
 						r = z;
 				}
@@ -32,18 +34,18 @@ class PNorm: public Norm<Vector>
 			else if (p==1)
 			{
 				for(int row = 0; row < v.size(); ++row)
-					r += fabs(v[row]);
+					r += std::abs(v[row]);
 			}
 			else if (p==2)
 			{
 				for(int row = 0; row < v.size(); ++row)
 					r += v[row] * v[row];
-				r = sqrt(r);
+				r = std::sqrt(r);
 			}
 			else
 			{
 				for(int row = 0; row < v.size(); ++row)
-					r += pow(fabs(v[row]), p);
+					r += pow(std::abs(v[row]), p);
 				r = pow(r, 1.0/p);
 			}
 			
@@ -58,7 +60,7 @@ class PNorm: public Norm<Vector>
 			{
 				for(int row = 0; row < v1.size(); ++row)
 				{
-					double z = fabs(v1[row]-v2[row]);
+					double z = std::abs(v1[row]-v2[row]);
 					if (z>r)
 						r = z;
 				}
@@ -66,18 +68,18 @@ class PNorm: public Norm<Vector>
 			else if (p==1)
 			{
 				for(int row = 0; row < v1.size(); ++row)
-					r += fabs(v1[row]-v2[row]);
+					r += std::abs(v1[row]-v2[row]);
 			}
 			else if (p==2)
 			{
 				for(int row = 0; row < v1.size(); ++row)
 					r += (v1[row]-v2[row]) * (v1[row]-v2[row]);
-				r = sqrt(r);
+				r = std::sqrt(r);
 			}
 			else
 			{
 				for(int row = 0; row < v1.size(); ++row)
-					r += pow(fabs(v1[row]-v2[row]), p);
+					r += pow(std::abs(v1[row]-v2[row]), p);
 				r = pow(r, 1.0/p);
 			}
 			
diff --git a/dune/solvers/norms/twonorm.hh b/dune/solvers/norms/twonorm.hh
index feee1112..eefd7795 100644
--- a/dune/solvers/norms/twonorm.hh
+++ b/dune/solvers/norms/twonorm.hh
@@ -1,7 +1,7 @@
 #ifndef TWONORM_HH
 #define TWONORM_HH
 
-#include <cmath>   // For std::sqrt
+#include <cmath>
 #include <cstring> // For size_t
 
 #include "norm.hh"
diff --git a/dune/solvers/solvers/tcgsolver.hh b/dune/solvers/solvers/tcgsolver.hh
index 07d2779c..dbd8698c 100644
--- a/dune/solvers/solvers/tcgsolver.hh
+++ b/dune/solvers/solvers/tcgsolver.hh
@@ -1,6 +1,8 @@
 #ifndef TRUNCATED_CG_SOLVER_HH
 #define TRUNCATED_CG_SOLVER_HH
 
+#include <cmath>
+
 #include <dune/solvers/solvers/iterativesolver.hh>
 #include <dune/solvers/iterationsteps/lineariterationstep.hh>
 #include <dune/solvers/norms/norm.hh>
diff --git a/dune/solvers/test/multigridtest.cc b/dune/solvers/test/multigridtest.cc
index 8f120d1a..cfcde56b 100644
--- a/dune/solvers/test/multigridtest.cc
+++ b/dune/solvers/test/multigridtest.cc
@@ -1,5 +1,6 @@
 #include <config.h>
 
+#include <cmath>
 #include <iostream>
 #include <sstream>
 
@@ -64,7 +65,7 @@ struct MultigridTestSuite
             for (size_t j=0; j<blocksize; ++j)
             {
                 u_ex[i][j] = (1.0*rand())/RAND_MAX;
-//                A[i][i][j][j] += 0.5*fabs(A[0][0][0][0]); // in case of no dirichlet values you can make the matrix pd hereby
+//                A[i][i][j][j] += 0.5*std::abs(A[0][0][0][0]); // in case of no dirichlet values you can make the matrix pd hereby
             }
 
         Vector rhs(A.N());
-- 
GitLab