Dune Core Modules (2.5.0)

identitymatrix.hh
Go to the documentation of this file.
1#ifndef DUNE_COMMON_IDENTITYMATRIX_HH
2#define DUNE_COMMON_IDENTITYMATRIX_HH
3
4#warning Deprecated since dune-common 2.5: If you really do need an identity matrix, use DiagonalMatrix or ScalarIdentityMatrix (from dune-istl) instead!
5
9#include <dune/common/math.hh>
10
19namespace Dune
20{
21
22 // IdentityMatrix
23 // --------------
24
36 template< class K, int N >
38 {
40 typedef K field_type;
42 typedef std::size_t size_type;
43
45 constexpr size_type rows () const { return N; }
47 constexpr size_type cols () const { return N; }
48
50 template< class X, class Y >
51 void mv ( const X &x, Y &y ) const
52 {
53 y = x;
54 }
55
57 template< class X, class Y >
58 void mtv ( const X &x, Y &y ) const
59 {
60 y = x;
61 }
62
64 template< class X, class Y >
65 void umv ( const X &x, Y &y ) const
66 {
67 y += x;
68 }
69
71 template< class X, class Y >
72 void umtv ( const X &x, Y &y ) const
73 {
74 y += x;
75 }
76
78 template< class X, class Y >
79 void umhv ( const X &x, Y &y ) const
80 {
81 y += x;
82 }
83
85 template< class X, class Y >
86 void mmv ( const X &x, Y &y ) const
87 {
88 y -= x;
89 }
90
92 template< class X, class Y >
93 void mmtv ( const X &x, Y &y ) const
94 {
95 y -= x;
96 }
97
99 template< class X, class Y >
100 void mmhv ( const X &x, Y &y ) const
101 {
102 y -= x;
103 }
104
106 template< class X, class Y >
107 void usmv (const typename FieldTraits<Y>::field_type & alpha,
108 const X& x, Y& y) const
109 {
110 y.axpy( alpha, x );
111 }
112
114 template< class X, class Y >
115 void usmtv (const typename FieldTraits<Y>::field_type & alpha,
116 const X& x, Y& y) const
117 {
118 y.axpy( alpha, x );
119 }
120
122 template< class X, class Y >
123 void usmhv (const typename FieldTraits<Y>::field_type & alpha,
124 const X& x, Y& y) const
125 {
126 y.axpy( alpha, x );
127 }
128
130 typename FieldTraits< field_type >::real_type frobenius_norm () const
131 {
132 return std::sqrt( frobenius_norm2() );
133 }
134
136 typename FieldTraits< field_type >::real_type frobenius_norm2 () const
137 {
138 return FieldTraits< field_type >::real_type( N );
139 }
140
142 typename FieldTraits< field_type >::real_type infinity_norm () const
143 {
144 return FieldTraits< field_type >::real_type( 1 );
145 }
146
148 typename FieldTraits< field_type >::real_type infinity_norm_real () const
149 {
150 return FieldTraits< field_type >::real_type( 1 );
151 }
152 };
153
154 template <class DenseMatrix, class field, int N>
155 struct DenseMatrixAssigner<DenseMatrix, IdentityMatrix<field, N>> {
156 static void apply(DenseMatrix &denseMatrix, IdentityMatrix<field, N> const &rhs) {
157 DUNE_ASSERT_BOUNDS(denseMatrix.M() == N);
158 DUNE_ASSERT_BOUNDS(denseMatrix.N() == N);
159 denseMatrix = field(0);
160 for (int i = 0; i < N; ++i)
161 denseMatrix[i][i] = field(1);
162 }
163 };
164} // namespace Dune
165
166#endif // #ifndef DUNE_COMMON_IDENTITYMATRIX_HH
Macro for wrapping boundary checks.
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)
#define DUNE_ASSERT_BOUNDS(cond)
If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
Definition: boundschecking.hh:28
Some useful basic math stuff.
Dune namespace.
Definition: alignment.hh:11
Read-only identity matrix.
Definition: identitymatrix.hh:38
FieldTraits< field_type >::real_type frobenius_norm() const
frobenius norm: sqrt(sum over squared values of entries)
Definition: identitymatrix.hh:130
void mtv(const X &x, Y &y) const
y = A^T x
Definition: identitymatrix.hh:58
std::size_t size_type
size type
Definition: identitymatrix.hh:42
void mmhv(const X &x, Y &y) const
y -= A^H x
Definition: identitymatrix.hh:100
FieldTraits< field_type >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition: identitymatrix.hh:148
void mmtv(const X &x, Y &y) const
y -= A^T x
Definition: identitymatrix.hh:93
void usmtv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
y += alpha A^T x
Definition: identitymatrix.hh:115
void usmhv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
y += alpha A^H x
Definition: identitymatrix.hh:123
void mv(const X &x, Y &y) const
y = A x
Definition: identitymatrix.hh:51
constexpr size_type rows() const
return number of rows
Definition: identitymatrix.hh:45
constexpr size_type cols() const
return number of columns
Definition: identitymatrix.hh:47
K field_type
field type
Definition: identitymatrix.hh:40
void mmv(const X &x, Y &y) const
y -= A x
Definition: identitymatrix.hh:86
FieldTraits< field_type >::real_type frobenius_norm2() const
square of frobenius norm, need for block recursion
Definition: identitymatrix.hh:136
FieldTraits< field_type >::real_type infinity_norm() const
infinity norm (row sum norm, how to generalize for blocks?)
Definition: identitymatrix.hh:142
void umv(const X &x, Y &y) const
y += A x
Definition: identitymatrix.hh:65
void usmv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
y += alpha A x
Definition: identitymatrix.hh:107
void umhv(const X &x, Y &y) const
y += A^H x
Definition: identitymatrix.hh:79
void umtv(const X &x, Y &y) const
y += A^T x
Definition: identitymatrix.hh:72
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)