Dune Core Modules (2.4.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_ISTL_SCALARPRODUCTS_HH
4#define DUNE_ISTL_SCALARPRODUCTS_HH
5
6#include <cmath>
7#include <complex>
8#include <iostream>
9#include <iomanip>
10#include <string>
11
12#include "bvector.hh"
13#include "solvercategory.hh"
14
15
16namespace Dune {
43 template<class X>
45 public:
47 typedef X domain_type;
48 typedef typename X::field_type field_type;
49
54 virtual field_type dot (const X& x, const X& y) = 0;
55
59 virtual double norm (const X& x) = 0;
60
61
63 virtual ~ScalarProduct () {}
64 };
65
75 template<class X, class C, int c>
77 {
80
81 enum {
84 };
85 };
86
87
88
89 //=====================================================================
90 // Implementation for ISTL-matrix based operator
91 //=====================================================================
92
94 template<class X>
96 {
97 public:
99 typedef X domain_type;
100 typedef typename X::field_type field_type;
101
103 enum {category=SolverCategory::sequential};
104
109 virtual field_type dot (const X& x, const X& y)
110 {
111 return x.dot(y);
112 }
113
117 virtual double norm (const X& x)
118 {
119 return static_cast<double>(x.two_norm());
120 }
121 };
122
123 template<class X, class C>
124 struct ScalarProductChooser<X,C,SolverCategory::sequential>
125 {
127 typedef SeqScalarProduct<X> ScalarProduct;
128
129 enum {
132 };
133
134 static ScalarProduct* construct(const C&)
135 {
136 return new ScalarProduct();
137 }
138 };
139
140
143} // end namespace
144
145#endif
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Base class for scalar product and norm computation.
Definition: scalarproducts.hh:44
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:47
virtual ~ScalarProduct()
every abstract base class has a virtual destructor
Definition: scalarproducts.hh:63
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:96
X domain_type
export types
Definition: scalarproducts.hh:99
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:109
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:117
Dune namespace.
Definition: alignment.hh:10
Choose the approriate scalar product for a solver category.
Definition: scalarproducts.hh:77
C communication_type
The type of the communication object.
Definition: scalarproducts.hh:79
@ solverCategory
The solver category.
Definition: scalarproducts.hh:83
@ sequential
Category for sequential solvers.
Definition: solvercategory.hh:21
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)