diff --git a/dune/solvers/norms/h1seminorm.hh b/dune/solvers/norms/h1seminorm.hh index 531ecdf03da74e02a5a134bd2c1652ecfd3ca849..449dd1f38fb5c2add402021d7ea2ed5b652449e9 100644 --- a/dune/solvers/norms/h1seminorm.hh +++ b/dune/solvers/norms/h1seminorm.hh @@ -14,21 +14,21 @@ class H1SemiNorm : public Norm<VectorType> { public: H1SemiNorm() : matrix_(NULL) {} - - H1SemiNorm(const Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> >& matrix) + + H1SemiNorm(const Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> >& matrix) : matrix_(&matrix) {} //! Compute the norm of the difference of two vectors - double diff(const VectorType& u1, const VectorType& u2) const + double diff(const VectorType& u1, const VectorType& u2) const { double sum = 0; - - for (size_t i=0; i<matrix_->N(); i++) + + for (size_t i=0; i<matrix_->N(); i++) { typename Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> >::row_type::const_iterator cIt = (*matrix_)[i].begin(); typename Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> >::row_type::const_iterator cEndIt = (*matrix_)[i].end(); - + typename VectorType::block_type differ_i = u1[i] - u2[i]; for (; cIt!=cEndIt; ++cIt) sum += differ_i * (u1[cIt.index()]-u2[cIt.index()]) * (*cIt); @@ -36,7 +36,7 @@ public: return std::sqrt(sum); } - + //! Compute the norm of the given vector double operator()(const VectorType& u) const { @@ -45,22 +45,22 @@ public: // we compute sqrt{uAu^t}. We have implemented this by hand because the matrix is // always scalar but the vectors may not be double sum = 0; - + for (size_t i=0; i<matrix_->N(); i++) { - + typename Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> >::row_type::const_iterator cIt = (*matrix_)[i].begin(); typename Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> >::row_type::const_iterator cEndIt = (*matrix_)[i].end(); - + for (; cIt!=cEndIt; ++cIt) sum += u[i]*u[cIt.index()] * (*cIt); - + } - + return std::sqrt(sum); } - + const Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> >* matrix_; - + }; #endif