Dune Core Modules (2.3.1)

scalarproducts.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_SCALARPRODUCTS_HH
4#define DUNE_SCALARPRODUCTS_HH
5
6#include <cmath>
7#include <complex>
8#include <iostream>
9#include <iomanip>
10#include <string>
11
12#include "solvercategory.hh"
13
14
15namespace Dune {
42 template<class X>
44 public:
46 typedef X domain_type;
47 typedef typename X::field_type field_type;
48
53 virtual field_type dot (const X& x, const X& y) = 0;
54
58 virtual double norm (const X& x) = 0;
59
60
62 virtual ~ScalarProduct () {}
63 };
64
74 template<class X, class C, int c>
76 {
79
80 enum {
83 };
84 };
85
86
87
88 //=====================================================================
89 // Implementation for ISTL-matrix based operator
90 //=====================================================================
91
93 template<class X>
95 {
96 public:
98 typedef X domain_type;
99 typedef typename X::field_type field_type;
100
102 enum {category=SolverCategory::sequential};
103
108 virtual field_type dot (const X& x, const X& y)
109 {
110 return x.dot(y);
111 }
112
116 virtual double norm (const X& x)
117 {
118 return x.two_norm();
119 }
120 };
121
122 template<class X, class C>
123 struct ScalarProductChooser<X,C,SolverCategory::sequential>
124 {
126 typedef SeqScalarProduct<X> ScalarProduct;
127
128 enum {
131 };
132
133 static ScalarProduct* construct(const C&)
134 {
135 return new ScalarProduct();
136 }
137 };
138
139
142} // end namespace
143
144#endif
Base class for scalar product and norm computation.
Definition: scalarproducts.hh:43
virtual field_type dot(const X &x, const X &y)=0
Dot product of two vectors. It is assumed that the vectors are consistent on the interior+border part...
X domain_type
export types, they come from the derived class
Definition: scalarproducts.hh:46
virtual ~ScalarProduct()
every abstract base class has a virtual destructor
Definition: scalarproducts.hh:62
virtual double norm(const X &x)=0
Norm of a right-hand side vector. The vector must be consistent on the interior+border partition.
Default implementation for the scalar case.
Definition: scalarproducts.hh:95
X domain_type
export types
Definition: scalarproducts.hh:98
virtual field_type dot(const X &x, const X &y)
Dot product of two vectors. In the complex case, the first argument is conjugated....
Definition: scalarproducts.hh:108
virtual double norm(const X &x)
Norm of a right-hand side vector. The vector must be consistent on the interior+border partition.
Definition: scalarproducts.hh:116
Dune namespace.
Definition: alignment.hh:14
Choose the approriate scalar product for a solver category.
Definition: scalarproducts.hh:76
C communication_type
The type of the communication object.
Definition: scalarproducts.hh:78
@ solverCategory
The solver category.
Definition: scalarproducts.hh:82
@ sequential
Category for sequential solvers.
Definition: solvercategory.hh:22
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)