8#ifndef SCALARPRODUCTS_HH_
9#define SCALARPRODUCTS_HH_
12#include <dune/common/fvector.hh>
13#include <dune/common/fmatrix.hh>
26 typedef typename Type::value_type return_type;
27 typedef typename Type::const_iterator iterator;
30 template <
class value_type,
int rows>
31 struct NormTraits<
Dune::FieldVector<value_type,rows> >{
32 typedef value_type return_type;
36 template <
class value_type,
int rows,
int cols>
37 struct NormTraits<
Dune::FieldMatrix<value_type,rows,cols> >{
38 typedef value_type return_type;
52 typename NormTraits<Type>::return_type
operator()(Type
const& v1, Type
const& v2)
const
54 typename NormTraits<Type>::return_type result(0);
55 typename NormTraits<Type>::iterator iend = v1.end(), it1 = v1.begin(), it2 = v2.begin();
56 for(; it1 != iend; ++it1, ++it2)
57 result += (*it1) * (*it2);
63 template <
class>
struct Norm;
66 template <
class ScalarProduct_>
74 typename NormTraits<Type>::return_type
operator()(Type
const& type)
const
76 return scalarProduct(type,type);
84 template <
class ScalarProduct_>
92 typename NormTraits<Type>::return_type
operator()(Type
const& type)
const
94 return sqrt(normSquared(type));
115 typename NormTraits<Type>::return_type
operator()(Type
const& type)
const
117 typename NormTraits<Type>::return_type result(0);
118 typename NormTraits<Type>::iterator iend = type.end(), iter = type.begin();
119 for(; iter != iend; ++iter)
if(result < fabs(*iter)) result = fabs(*iter);
132 typename NormTraits<Type>::return_type
operator()(Type
const& type)
const
134 typename NormTraits<Type>::return_type result(0);
135 typename NormTraits<Type>::iterator iend = type.end(), iter = type.begin();
136 for(; iter != iend; ++iter)
137 result += fabs(*iter);
Norm< EuclideanScalarProduct > EuclideanNorm
Euclidean norm.
NormSquared< EuclideanScalarProduct > EuclideanNormSquared
Euclidean norm squared.
Euclidean scalar product.
NormTraits< Type >::return_type operator()(Type const &v1, Type const &v2) const
Infinity norm for stl-container, Dune::FieldVector and Dune::FieldMatrix.
NormTraits< Type >::return_type operator()(Type const &type) const
Norm defined via ScalarProdcut.
NormTraits< Type >::return_type operator()(Type const &type) const
NormSquared< ScalarProduct > AssociatedNormSquared
Norm(ScalarProduct const sp=ScalarProduct())
ScalarProduct_ ScalarProduct
Norm squared defined via ScalarProduct.
NormTraits< Type >::return_type operator()(Type const &type) const
NormSquared(ScalarProduct const sp=ScalarProduct())
Norm< ScalarProduct > AssociatedNorm
ScalarProduct_ ScalarProduct
One norm for stl-container, Dune::FieldVector and Dune::FieldMatrix.
NormTraits< Type >::return_type operator()(Type const &type) const