Skip to content
Snippets Groups Projects
Commit 49748583 authored by Uli Sack's avatar Uli Sack Committed by usack
Browse files

adapted to more general low rank operators

[[Imported from SVN: r5642]]
parent 5c96f55a
Branches
Tags
No related merge requests found
...@@ -18,7 +18,7 @@ template <class LowRankFactor, class VectorType> ...@@ -18,7 +18,7 @@ template <class LowRankFactor, class VectorType>
class FullNorm: public Norm<VectorType> class FullNorm: public Norm<VectorType>
{ {
public: public:
FullNorm(double alpha, const LowRankFactor &lowRankFactor) : FullNorm(const double alpha, const LowRankFactor &lowRankFactor) :
lowRankFactor_(lowRankFactor), lowRankFactor_(lowRankFactor),
alpha(alpha) alpha(alpha)
{} {}
...@@ -60,43 +60,43 @@ class FullNorm: public Norm<VectorType> ...@@ -60,43 +60,43 @@ class FullNorm: public Norm<VectorType>
}; };
template<>
class FullNorm<Dune::BlockVector<Dune::FieldVector<double,1> >, Dune::BlockVector<Dune::FieldVector<double,1> > >: class FullNorm<Dune::BlockVector<Dune::FieldVector<double,1> >, Dune::BlockVector<Dune::FieldVector<double,1> > >:
public Norm<Dune::BlockVector<Dune::FieldVector<double,1> > > public Norm<Dune::BlockVector<Dune::FieldVector<double,1> > >
{ {
typedef <Dune::BlockVector<Dune::FieldVector<double,1> > VectorType; typedef Dune::BlockVector<Dune::FieldVector<double,1> > VectorType;
public: public:
FullNorm(double alpha, const VectorType &m) : FullNorm(const double alpha, const VectorType &m) :
m(m), m(m),
alpha(alpha) alpha(alpha)
{} {}
//! Compute the norm of the given vector //! Compute the norm of the given vector
double operator()(const VectorType &v) const double operator()(const VectorType &v) const
{ {
double r = 0.0; double r = 0.0;
for(int row = 0; row < v.size(); ++row) for(int row = 0; row < v.size(); ++row)
r += m[row] * v[row]; r += m[row] * v[row];
return sqrt(fabs(alpha*r*r)); return sqrt(fabs(alpha*r*r));
} }
//! Compute the norm of the difference of two vectors
double diff(const VectorType &v1, const VectorType &v2) const
{
double r = 0.0;
for(int row = 0; row < v1.size(); ++row)
r += (double)m[row] * (v1[row] - v2[row]);
return sqrt(fabs(alpha*r*r));
}
private:
const VectorType &m;
const double alpha;
//! Compute the norm of the difference of two vectors
double diff(const VectorType &v1, const VectorType &v2) const
{
double r = 0.0;
for(int row = 0; row < v1.size(); ++row)
r += (double)m[row] * (v1[row] - v2[row]);
return sqrt(fabs(alpha*r*r));
}
private:
const VectorType &m;
const double alpha;
}; };
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment