Dune Core Modules (2.4.2)

identitymatrix.hh
Go to the documentation of this file.
1#ifndef DUNE_COMMON_IDENTITYMATRIX_HH
2#define DUNE_COMMON_IDENTITYMATRIX_HH
3
6#include <dune/common/math.hh>
8
17namespace Dune
18{
19
20 // IdentityMatrix
21 // --------------
22
34 template< class K, int N >
36 {
38 typedef K field_type;
40 typedef std::size_t size_type;
41
43 DUNE_CONSTEXPR size_type rows () const { return N; }
45 DUNE_CONSTEXPR size_type cols () const { return N; }
46
48 template< class X, class Y >
49 void mv ( const X &x, Y &y ) const
50 {
51 y = x;
52 }
53
55 template< class X, class Y >
56 void mtv ( const X &x, Y &y ) const
57 {
58 y = x;
59 }
60
62 template< class X, class Y >
63 void umv ( const X &x, Y &y ) const
64 {
65 y += x;
66 }
67
69 template< class X, class Y >
70 void umtv ( const X &x, Y &y ) const
71 {
72 y += x;
73 }
74
76 template< class X, class Y >
77 void umhv ( const X &x, Y &y ) const
78 {
79 y += x;
80 }
81
83 template< class X, class Y >
84 void mmv ( const X &x, Y &y ) const
85 {
86 y -= x;
87 }
88
90 template< class X, class Y >
91 void mmtv ( const X &x, Y &y ) const
92 {
93 y -= x;
94 }
95
97 template< class X, class Y >
98 void mmhv ( const X &x, Y &y ) const
99 {
100 y -= x;
101 }
102
104 template< class X, class Y >
105 void usmv ( const field_type &alpha, const X &x, Y &y ) const
106 {
107 y.axpy( alpha, x );
108 }
109
111 template< class X, class Y >
112 void usmtv ( const field_type &alpha, const X &x, Y &y ) const
113 {
114 y.axpy( alpha, x );
115 }
116
118 template< class X, class Y >
119 void usmhv ( const field_type &alpha, const X &x, Y &y ) const
120 {
121 y.axpy( alpha, x );
122 }
123
125 typename FieldTraits< field_type >::real_type frobenius_norm () const
126 {
127 return std::sqrt( frobenius_norm2() );
128 }
129
131 typename FieldTraits< field_type >::real_type frobenius_norm2 () const
132 {
133 return FieldTraits< field_type >::real_type( N );
134 }
135
137 typename FieldTraits< field_type >::real_type infinity_norm () const
138 {
139 return FieldTraits< field_type >::real_type( 1 );
140 }
141
143 typename FieldTraits< field_type >::real_type infinity_norm_real () const
144 {
145 return FieldTraits< field_type >::real_type( 1 );
146 }
147
150 {
151 FieldMatrix< field_type, N, N > fieldMatrix( 0 );
152 for( int i = 0; i < N; ++i )
153 fieldMatrix[ i ][ i ] = field_type( 1 );
154 return fieldMatrix;
155 }
156 };
157
158} // namespace Dune
159
160#endif // #ifndef DUNE_COMMON_IDENTITYMATRIX_HH
A dense n x m matrix.
Definition: fmatrix.hh:67
Definition of the DUNE_CONSTEXPR macro.
#define DUNE_CONSTEXPR
Set method or expression constexpr if supported by the compiler.
Definition: constexpr.hh:21
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Type traits to determine the type of reals (when working with complex numbers)
Some useful basic math stuff.
Dune namespace.
Definition: alignment.hh:10
Read-only identity matrix.
Definition: identitymatrix.hh:36
FieldTraits< field_type >::real_type frobenius_norm() const
frobenius norm: sqrt(sum over squared values of entries)
Definition: identitymatrix.hh:125
void usmhv(const field_type &alpha, const X &x, Y &y) const
y += alpha A^H x
Definition: identitymatrix.hh:119
void mtv(const X &x, Y &y) const
y = A^T x
Definition: identitymatrix.hh:56
std::size_t size_type
size type
Definition: identitymatrix.hh:40
void mmhv(const X &x, Y &y) const
y -= A^H x
Definition: identitymatrix.hh:98
DUNE_CONSTEXPR size_type rows() const
return number of rows
Definition: identitymatrix.hh:43
FieldTraits< field_type >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition: identitymatrix.hh:143
void mmtv(const X &x, Y &y) const
y -= A^T x
Definition: identitymatrix.hh:91
void mv(const X &x, Y &y) const
y = A x
Definition: identitymatrix.hh:49
K field_type
field type
Definition: identitymatrix.hh:38
void mmv(const X &x, Y &y) const
y -= A x
Definition: identitymatrix.hh:84
FieldTraits< field_type >::real_type frobenius_norm2() const
square of frobenius norm, need for block recursion
Definition: identitymatrix.hh:131
FieldTraits< field_type >::real_type infinity_norm() const
infinity norm (row sum norm, how to generalize for blocks?)
Definition: identitymatrix.hh:137
void umv(const X &x, Y &y) const
y += A x
Definition: identitymatrix.hh:63
void usmv(const field_type &alpha, const X &x, Y &y) const
y += alpha A x
Definition: identitymatrix.hh:105
void umhv(const X &x, Y &y) const
y += A^H x
Definition: identitymatrix.hh:77
void umtv(const X &x, Y &y) const
y += A^T x
Definition: identitymatrix.hh:70
DUNE_CONSTEXPR size_type cols() const
return number of columns
Definition: identitymatrix.hh:45
void usmtv(const field_type &alpha, const X &x, Y &y) const
y += alpha A^T x
Definition: identitymatrix.hh:112
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)