Skip to content
Snippets Groups Projects
Commit 2201d09e authored by Elias Pipping's avatar Elias Pipping Committed by pipping
Browse files

fabs -> std::abs, sqrt -> std::sqrt

[[Imported from SVN: r8175]]
parent 3d17ff5a
No related branches found
No related tags found
No related merge requests found
#include <dune/istl/scaledidmatrix.hh>
#include <cmath>
#include <dune/solvers/iterationsteps/projectedblockgsstep.hh>
#include <dune/solvers/norms/energynorm.hh>
......
#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]))
{
......
......@@ -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:
......
#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
......
......@@ -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:
......
#ifndef DUNE_H1_SEMINORM_HH
#define DUNE_H1_SEMINORM_HH
#include <cmath>
#include <dune/common/fmatrix.hh>
#include <dune/istl/bcrsmatrix.hh>
......
#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);
}
......
#ifndef TWONORM_HH
#define TWONORM_HH
#include <cmath> // For std::sqrt
#include <cmath>
#include <cstring> // For size_t
#include "norm.hh"
......
#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>
......
#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());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment