Dune Core Modules (2.3.1)

operators.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_ISTLOPERATORS_HH
4#define DUNE_ISTLOPERATORS_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 {
16
39 //=====================================================================
40 // Abstract operator interface
41 //=====================================================================
42
43
61 template<class X, class Y>
63 public:
65 typedef X domain_type;
67 typedef Y range_type;
69 typedef typename X::field_type field_type;
70
75 virtual void apply (const X& x, Y& y) const = 0;
76
78 virtual void applyscaleadd (field_type alpha, const X& x, Y& y) const = 0;
79
81 virtual ~LinearOperator () {}
82 };
83
84
93 template<class M, class X, class Y>
95 public:
97 typedef M matrix_type;
98 typedef X domain_type;
99 typedef Y range_type;
100 typedef typename X::field_type field_type;
101
103 virtual const M& getmat () const = 0;
104
107 };
108
109
110
111 //=====================================================================
112 // Implementation for ISTL-matrix based operator
113 //=====================================================================
114
120 template<class M, class X, class Y>
122 {
123 public:
125 typedef M matrix_type;
126 typedef X domain_type;
127 typedef Y range_type;
128 typedef typename X::field_type field_type;
129
131 enum {category=SolverCategory::sequential};
132
134 explicit MatrixAdapter (const M& A) : _A_(A) {}
135
137 virtual void apply (const X& x, Y& y) const
138 {
139 _A_.mv(x,y);
140 }
141
143 virtual void applyscaleadd (field_type alpha, const X& x, Y& y) const
144 {
145 _A_.usmv(alpha,x,y);
146 }
147
149 virtual const M& getmat () const
150 {
151 return _A_;
152 }
153
154 private:
155 const M& _A_;
156 };
157
160} // end namespace
161
162#endif
A linear operator exporting itself in matrix form.
Definition: operators.hh:94
virtual const M & getmat() const =0
get matrix via *
M matrix_type
export types, usually they come from the derived class
Definition: operators.hh:97
virtual ~AssembledLinearOperator()
every abstract base class has a virtual destructor
Definition: operators.hh:106
A linear operator.
Definition: operators.hh:62
virtual ~LinearOperator()
every abstract base class has a virtual destructor
Definition: operators.hh:81
X::field_type field_type
The field type of the operator.
Definition: operators.hh:69
virtual void applyscaleadd(field_type alpha, const X &x, Y &y) const =0
apply operator to x, scale and add:
Y range_type
The type of the range of the operator.
Definition: operators.hh:67
virtual void apply(const X &x, Y &y) const =0
apply operator to x: The input vector is consistent and the output must also be consistent on the in...
X domain_type
The type of the domain of the operator.
Definition: operators.hh:65
Adapter to turn a matrix into a linear operator.
Definition: operators.hh:122
virtual const M & getmat() const
get matrix via *
Definition: operators.hh:149
virtual void applyscaleadd(field_type alpha, const X &x, Y &y) const
apply operator to x, scale and add:
Definition: operators.hh:143
MatrixAdapter(const M &A)
constructor: just store a reference to a matrix
Definition: operators.hh:134
virtual void apply(const X &x, Y &y) const
apply operator to x:
Definition: operators.hh:137
M matrix_type
export types
Definition: operators.hh:125
Dune namespace.
Definition: alignment.hh:14
@ 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)