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

generalized the fullnorm to low rank matrices instead of just rank-1 ones....

generalized the fullnorm to low rank matrices instead of just rank-1 ones. Kept old FullNorm as template specialization. This will require old code using the FullNorm to specify template parameters

[[Imported from SVN: r5602]]
parent b6ca8da6
No related branches found
No related tags found
No related merge requests found
#ifndef __FULLNORM__HH__ #ifndef FULLNORM_HH
#define __FULLNORM__HH__ #define FULLNORM_HH
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
#include <dune/istl/bvector.hh> #include <dune/istl/bvector.hh>
#include "norm.hh" #include "norm.hh"
typedef Dune::BlockVector<Dune::FieldVector<double,1> > Vector; /** \brief Vector norm induced by filled in low rank linear operator M
*
* \f$M = m^t*m\f$
* \f$\Vert u \Vert_M = (u, Mu)^{1/2} = (mu,mu)^{1/2}\f$
*
* \tparam LowRankFactor the type of the factor used to represent the low rank operator
* \tparam Vector the vector type the norm may be applied to
*/
template <class LowRankFactor, class Vector>
class FullNorm: public Norm<Vector> class FullNorm: public Norm<Vector>
{ {
public:
FullNorm(double alpha, const LowRankFactor &lowRankFactor) :
lowRankFactor_(lowRankFactor),
alpha(alpha)
{}
//! Compute the norm of the given vector
double operator()(const Vector &v) const
{
Vector r(lowRankFactor_.N());
r = 0.0;
lowRankFactor_.umv(v,r);
// for(int row = 0; row < v.size(); ++row)
// r += m[row] * v[row];
return sqrt(fabs(alpha*(r*r)));
}
//! Compute the norm of the difference of two vectors
double diff(const Vector &v1, const Vector &v2) const
{
Vector r(lowRankFactor_.N());
r = 0.0;
// Vector temp(v1);
// v1 -= v2;
// lowRankFactor_.umv(temp,r);
for (typename LowRankFactor::size_type k=0; k<lowRankFactor_.N(); ++k)
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)));
}
private:
const LowRankFactor& lowRankFactor_;
const double alpha;
};
class FullNorm<Dune::BlockVector<Dune::FieldVector<double,1> >, Dune::BlockVector<Dune::FieldVector<double,1> > >:
public Norm<Dune::BlockVector<Dune::FieldVector<double,1> > >
{
typedef <Dune::BlockVector<Dune::FieldVector<double,1> > Vector;
public: public:
FullNorm(double alpha, const Vector &m) : FullNorm(double alpha, const Vector &m) :
m(m), m(m),
...@@ -44,5 +99,4 @@ class FullNorm: public Norm<Vector> ...@@ -44,5 +99,4 @@ class FullNorm: public Norm<Vector>
const double alpha; 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