dune-istl  2.2.1
scalarproducts.hh
Go to the documentation of this file.
1 #ifndef DUNE_SCALARPRODUCTS_HH
2 #define DUNE_SCALARPRODUCTS_HH
3 
4 #include<cmath>
5 #include<complex>
6 #include<iostream>
7 #include<iomanip>
8 #include<string>
9 
10 #include"solvercategory.hh"
11 
12 
13 namespace Dune {
40  template<class X>
41  class ScalarProduct {
42  public:
44  typedef X domain_type;
45  typedef typename X::field_type field_type;
46 
51  virtual field_type dot (const X& x, const X& y) = 0;
52 
56  virtual double norm (const X& x) = 0;
57 
58 
60  virtual ~ScalarProduct () {}
61  };
62 
72  template<class X, class C, int c>
74  {
76  typedef C communication_type;
77 
78  enum{
81  };
82  };
83 
84 
85 
86  //=====================================================================
87  // Implementation for ISTL-matrix based operator
88  //=====================================================================
89 
91  template<class X>
92  class SeqScalarProduct : public ScalarProduct<X>
93  {
94  public:
96  typedef X domain_type;
97  typedef typename X::field_type field_type;
98 
101 
106  virtual field_type dot (const X& x, const X& y)
107  {
108  return x*y;
109  }
110 
114  virtual double norm (const X& x)
115  {
116  return x.two_norm();
117  }
118  };
119 
120  template<class X, class C>
121  struct ScalarProductChooser<X,C,SolverCategory::sequential>
122  {
125 
126  enum{
129  };
130 
131  static ScalarProduct* construct(const C&)
132  {
133  return new ScalarProduct();
134  }
135  };
136 
137 
140 } // end namespace
141 
142 #endif