Reference documentation for deal.II version 8.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
identity_matrix.h
1 // ---------------------------------------------------------------------
2 // @f$Id: identity_matrix.h 30040 2013-07-18 17:06:48Z maier @f$
3 //
4 // Copyright (C) 2006 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 #ifndef __deal2__identity_matrix_h
18 #define __deal2__identity_matrix_h
19 
20 
21 #include <deal.II/base/config.h>
22 #include <deal.II/lac/exceptions.h>
23 
25 
75 {
76 public:
81 
88  IdentityMatrix ();
89 
94  IdentityMatrix (const size_type n);
95 
100  void reinit (const size_type n);
101 
108  size_type m () const;
109 
116  size_type n () const;
117 
126  template <class VECTOR1, class VECTOR2>
127  void vmult (VECTOR1 &out,
128  const VECTOR2 &in) const;
129 
138  template <class VECTOR1, class VECTOR2>
139  void vmult_add (VECTOR1 &out,
140  const VECTOR2 &in) const;
141 
150  template <class VECTOR1, class VECTOR2>
151  void Tvmult (VECTOR1 &out,
152  const VECTOR2 &in) const;
153 
154 
164  template <class VECTOR1, class VECTOR2>
165  void Tvmult_add (VECTOR1 &out,
166  const VECTOR2 &in) const;
167 private:
168 
173  size_type size;
174 };
175 
176 
177 
178 
179 // ------------------------- inline and template functions -------------
180 #ifndef DOXYGEN
181 
182 
183 inline
185  :
186  size (0)
187 {}
188 
189 
190 
191 inline
193  :
194  size (n)
195 {}
196 
197 
198 
199 inline
200 void
202 {
203  size = n;
204 }
205 
206 
207 
208 inline
210 IdentityMatrix::m () const
211 {
212  return size;
213 }
214 
215 
216 
217 inline
219 IdentityMatrix::n () const
220 {
221  return size;
222 }
223 
224 
225 
226 template <class VECTOR1, class VECTOR2>
227 inline
228 void
229 IdentityMatrix::vmult (VECTOR1 &out,
230  const VECTOR2 &in) const
231 {
232  Assert (out.size() == size, ExcDimensionMismatch (out.size(), size));
233  Assert (in.size() == size, ExcDimensionMismatch (in.size(), size));
234 
235  out = in;
236 }
237 
238 
239 
240 template <class VECTOR1, class VECTOR2>
241 inline
242 void
243 IdentityMatrix::vmult_add (VECTOR1 &out,
244  const VECTOR2 &in) const
245 {
246  Assert (out.size() == size, ExcDimensionMismatch (out.size(), size));
247  Assert (in.size() == size, ExcDimensionMismatch (in.size(), size));
248 
249  out += in;
250 }
251 
252 
253 
254 template <class VECTOR1, class VECTOR2>
255 inline
256 void
257 IdentityMatrix::Tvmult (VECTOR1 &out,
258  const VECTOR2 &in) const
259 {
260  Assert (out.size() == size, ExcDimensionMismatch (out.size(), size));
261  Assert (in.size() == size, ExcDimensionMismatch (in.size(), size));
262 
263  out = in;
264 }
265 
266 
267 
268 template <class VECTOR1, class VECTOR2>
269 inline
270 void
271 IdentityMatrix::Tvmult_add (VECTOR1 &out,
272  const VECTOR2 &in) const
273 {
274  Assert (out.size() == size, ExcDimensionMismatch (out.size(), size));
275  Assert (in.size() == size, ExcDimensionMismatch (in.size(), size));
276 
277  out += in;
278 }
279 
280 
281 #endif
282 
285 DEAL_II_NAMESPACE_CLOSE
286 
287 #endif
288 
void vmult_add(VECTOR1 &out, const VECTOR2 &in) const
void Tvmult_add(VECTOR1 &out, const VECTOR2 &in) const
void vmult(VECTOR1 &out, const VECTOR2 &in) const
unsigned int global_dof_index
Definition: types.h:100
#define Assert(cond, exc)
Definition: exceptions.h:299
types::global_dof_index size_type
size_type n() const
void reinit(const size_type n)
void Tvmult(VECTOR1 &out, const VECTOR2 &in) const
::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
size_type m() const