Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
identity_matrix.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2006 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_identity_matrix_h
17 #define dealii_identity_matrix_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/lac/exceptions.h>
23 
24 DEAL_II_NAMESPACE_OPEN
25 
72 {
73 public:
78 
84 
88  explicit IdentityMatrix(const size_type n);
89 
93  void
94  reinit(const size_type n);
95 
100  size_type
101  m() const;
102 
107  size_type
108  n() const;
109 
114  template <typename OutVectorType, typename InVectorType>
115  void
116  vmult(OutVectorType &out, const InVectorType &in) const;
117 
123  template <typename OutVectorType, typename InVectorType>
124  void
125  vmult_add(OutVectorType &out, const InVectorType &in) const;
126 
132  template <typename OutVectorType, typename InVectorType>
133  void
134  Tvmult(OutVectorType &out, const InVectorType &in) const;
135 
136 
142  template <typename OutVectorType, typename InVectorType>
143  void
144  Tvmult_add(OutVectorType &out, const InVectorType &in) const;
145 
146 private:
151 };
152 
153 
154 
155 // ------------------------- inline and template functions -------------
156 #ifndef DOXYGEN
157 
158 
160  : size(0)
161 {}
162 
163 
164 
165 inline IdentityMatrix::IdentityMatrix(const size_type n)
166  : size(n)
167 {}
168 
169 
170 
171 inline void
172 IdentityMatrix::reinit(const size_type n)
173 {
174  size = n;
175 }
176 
177 
178 
180 IdentityMatrix::m() const
181 {
182  return size;
183 }
184 
185 
186 
188 IdentityMatrix::n() const
189 {
190  return size;
191 }
192 
193 
194 
195 template <typename OutVectorType, typename InVectorType>
196 inline void
197 IdentityMatrix::vmult(OutVectorType &out, const InVectorType &in) const
198 {
199  Assert(out.size() == size, ExcDimensionMismatch(out.size(), size));
200  Assert(in.size() == size, ExcDimensionMismatch(in.size(), size));
201 
202  out = in;
203 }
204 
205 
206 
207 template <typename OutVectorType, typename InVectorType>
208 inline void
209 IdentityMatrix::vmult_add(OutVectorType &out, const InVectorType &in) const
210 {
211  Assert(out.size() == size, ExcDimensionMismatch(out.size(), size));
212  Assert(in.size() == size, ExcDimensionMismatch(in.size(), size));
213 
214  out += in;
215 }
216 
217 
218 
219 template <typename OutVectorType, typename InVectorType>
220 inline void
221 IdentityMatrix::Tvmult(OutVectorType &out, const InVectorType &in) const
222 {
223  Assert(out.size() == size, ExcDimensionMismatch(out.size(), size));
224  Assert(in.size() == size, ExcDimensionMismatch(in.size(), size));
225 
226  out = in;
227 }
228 
229 
230 
231 template <typename OutVectorType, typename InVectorType>
232 inline void
233 IdentityMatrix::Tvmult_add(OutVectorType &out, const InVectorType &in) const
234 {
235  Assert(out.size() == size, ExcDimensionMismatch(out.size(), size));
236  Assert(in.size() == size, ExcDimensionMismatch(in.size(), size));
237 
238  out += in;
239 }
240 
241 
242 #endif
243 
246 DEAL_II_NAMESPACE_CLOSE
247 
248 #endif
types::global_dof_index size_type
void vmult_add(OutVectorType &out, const InVectorType &in) const
#define Assert(cond, exc)
Definition: exceptions.h:1407
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void Tvmult_add(OutVectorType &out, const InVectorType &in) const
unsigned int global_dof_index
Definition: types.h:89
void reinit(const size_type n)
void Tvmult(OutVectorType &out, const InVectorType &in) const
size_type n() const
size_type m() const
void vmult(OutVectorType &out, const InVectorType &in) const