scalarproducts.hh

Go to the documentation of this file.
00001 #ifndef DUNE_SCALARPRODUCTS_HH
00002 #define DUNE_SCALARPRODUCTS_HH
00003 
00004 #include<cmath>
00005 #include<complex>
00006 #include<iostream>
00007 #include<iomanip>
00008 #include<string>
00009 
00010 #include"solvercategory.hh"
00011 
00012 
00013 namespace Dune {
00040   template<class X>
00041   class ScalarProduct {
00042   public:
00044         typedef X domain_type;
00045         typedef typename X::field_type field_type;
00046 
00051         virtual field_type dot (const X& x, const X& y) = 0;
00052 
00056         virtual double norm (const X& x) = 0;
00057 
00058 
00060         virtual ~ScalarProduct () {}
00061   };
00062 
00072   template<class X, class C, int c>
00073   struct ScalarProductChooser
00074   {
00076     typedef C communication_type;
00077     
00078     enum{
00080       solverCategory=c
00081         };
00082   };
00083   
00084     
00085   
00086   //=====================================================================
00087   // Implementation for ISTL-matrix based operator
00088   //=====================================================================
00089 
00091   template<class X>
00092   class SeqScalarProduct : public ScalarProduct<X>
00093   {
00094   public:
00096         typedef X domain_type;
00097         typedef typename X::field_type field_type;
00098 
00100         enum {category=SolverCategory::sequential};
00101 
00106         virtual field_type dot (const X& x, const X& y)
00107         {
00108           return x*y;
00109         }
00110 
00114         virtual double norm (const X& x)
00115         {
00116           return x.two_norm();
00117         }
00118   };
00119 
00120   template<class X, class C>
00121   struct ScalarProductChooser<X,C,SolverCategory::sequential>
00122   {
00124     typedef SeqScalarProduct<X> ScalarProduct;
00125     
00126     enum{
00128       solverCategory=SolverCategory::sequential
00129         };
00130     
00131     static ScalarProduct* construct(const C&)
00132     {
00133       return new ScalarProduct();
00134     }
00135   };
00136   
00137 
00140 } // end namespace
00141 
00142 #endif

Generated on Tue Jul 28 22:29:14 2009 for dune-istl by  doxygen 1.5.6