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

Make TwoNorm work for FieldVectors

[[Imported from SVN: r12469]]
parent 048a725a
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,8 @@
#include <cmath>
#include <cstring> // For size_t
#include <dune/common/fvector.hh>
#include "norm.hh"
//! Wrapper around the two_norm() method of a vector class
......@@ -46,4 +48,36 @@ class TwoNorm : public Norm<VectorType>
};
template <typename T, int dimension>
class TwoNorm<Dune::FieldVector<T, dimension> >
: public Norm<Dune::FieldVector<T, dimension> >
{
typedef Dune::FieldVector<T, dimension> VectorType;
public:
/** \brief Destructor, doing nothing */
virtual ~TwoNorm() {};
//! Compute the norm of the given vector
virtual double operator()(const VectorType& f) const
{
return f.two_norm();
}
//! Compute the square of the norm of the given vector
virtual double normSquared(const VectorType& f) const
{
return f.two_norm2();
}
//! Compute the norm of the difference of two vectors
virtual double diff(const VectorType& f1, const VectorType& f2) const
{
VectorType tmp = f1;
tmp -= f2;
return tmp.two_norm();
}
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment