diff --git a/dune/solvers/norms/energynorm.hh b/dune/solvers/norms/energynorm.hh index c8e819eb0fc985f69e9e1d94a8f15039f6f0e9be..d2caafa142d88976052a456ed4aba0a4c9f13502 100644 --- a/dune/solvers/norms/energynorm.hh +++ b/dune/solvers/norms/energynorm.hh @@ -49,7 +49,7 @@ } //! Compute the norm of the difference of two vectors - double diff(const DiscFuncType& f1, const DiscFuncType& f2) const { + field_type diff(const DiscFuncType& f1, const DiscFuncType& f2) const { if (iterationStep_ == NULL && matrix_ == NULL) DUNE_THROW(Dune::Exception, "You have supplied neither a matrix nor an IterationStep to the EnergyNorm!"); @@ -59,14 +59,14 @@ } //! Compute the norm of the given vector - double operator()(const DiscFuncType& f) const + field_type operator()(const DiscFuncType& f) const { return std::sqrt(this->EnergyNorm<OperatorType,DiscFuncType>::normSquared(f)); } /** \brief Compute the square of the norm of the given vector \todo This could be implemented without the temporary. */ - virtual double normSquared(const DiscFuncType& f) const + virtual field_type normSquared(const DiscFuncType& f) const { if (iterationStep_ == NULL && matrix_ == NULL) DUNE_THROW(Dune::Exception, "You have supplied neither a matrix nor an IterationStep to the EnergyNorm!"); @@ -78,7 +78,7 @@ DiscFuncType tmp(f.size()); A.mv(f, tmp); - double const ret = f*tmp; + field_type const ret = f*tmp; if (ret < 0) { diff --git a/dune/solvers/norms/norm.hh b/dune/solvers/norms/norm.hh index 80d03d6b96102eadd702e9e5e3236ddbb5965738..7ed346393e4661a89205984e56941eb327e22af9 100644 --- a/dune/solvers/norms/norm.hh +++ b/dune/solvers/norms/norm.hh @@ -8,21 +8,23 @@ class Norm { public: typedef V VectorType; + typedef typename VectorType::field_type field_type; + /** \brief Destructor, doing nothing */ virtual ~Norm() {}; //! Compute the norm of the given vector - virtual double operator()(const VectorType& f) const = 0; + virtual field_type operator()(const VectorType& f) const = 0; //! Compute the square of the norm of the given vector - virtual double normSquared(const VectorType& f) const + virtual field_type normSquared(const VectorType& f) const { - double r = this->operator()(f); + field_type r = this->operator()(f); return r*r; } //! Compute the norm of the difference of two vectors - virtual double diff(const VectorType& f1, const VectorType& f2) const = 0; + virtual field_type diff(const VectorType& f1, const VectorType& f2) const = 0; };