Reference documentation for deal.II version 8.5.1
identity_matrix.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2006 - 2015 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 at
12 // the top level of the deal.II distribution.
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 #include <deal.II/lac/exceptions.h>
22 
23 DEAL_II_NAMESPACE_OPEN
24 
71 {
72 public:
77 
82  IdentityMatrix ();
83 
87  IdentityMatrix (const size_type n);
88 
92  void reinit (const size_type n);
93 
98  size_type m () const;
99 
104  size_type n () const;
105 
110  template <typename OutVectorType, typename InVectorType>
111  void vmult (OutVectorType &out,
112  const InVectorType &in) const;
113 
119  template <typename OutVectorType, typename InVectorType>
120  void vmult_add (OutVectorType &out,
121  const InVectorType &in) const;
122 
128  template <typename OutVectorType, typename InVectorType>
129  void Tvmult (OutVectorType &out,
130  const InVectorType &in) const;
131 
132 
138  template <typename OutVectorType, typename InVectorType>
139  void Tvmult_add (OutVectorType &out,
140  const InVectorType &in) const;
141 private:
142 
147 };
148 
149 
150 
151 
152 // ------------------------- inline and template functions -------------
153 #ifndef DOXYGEN
154 
155 
156 inline
158  :
159  size (0)
160 {}
161 
162 
163 
164 inline
165 IdentityMatrix::IdentityMatrix (const size_type n)
166  :
167  size (n)
168 {}
169 
170 
171 
172 inline
173 void
174 IdentityMatrix::reinit (const size_type n)
175 {
176  size = n;
177 }
178 
179 
180 
181 inline
183 IdentityMatrix::m () const
184 {
185  return size;
186 }
187 
188 
189 
190 inline
192 IdentityMatrix::n () const
193 {
194  return size;
195 }
196 
197 
198 
199 template <typename OutVectorType, typename InVectorType>
200 inline
201 void
202 IdentityMatrix::vmult (OutVectorType &out,
203  const InVectorType &in) const
204 {
205  Assert (out.size() == size, ExcDimensionMismatch (out.size(), size));
206  Assert (in.size() == size, ExcDimensionMismatch (in.size(), size));
207 
208  out = in;
209 }
210 
211 
212 
213 template <typename OutVectorType, typename InVectorType>
214 inline
215 void
216 IdentityMatrix::vmult_add (OutVectorType &out,
217  const InVectorType &in) const
218 {
219  Assert (out.size() == size, ExcDimensionMismatch (out.size(), size));
220  Assert (in.size() == size, ExcDimensionMismatch (in.size(), size));
221 
222  out += in;
223 }
224 
225 
226 
227 template <typename OutVectorType, typename InVectorType>
228 inline
229 void
230 IdentityMatrix::Tvmult (OutVectorType &out,
231  const InVectorType &in) const
232 {
233  Assert (out.size() == size, ExcDimensionMismatch (out.size(), size));
234  Assert (in.size() == size, ExcDimensionMismatch (in.size(), size));
235 
236  out = in;
237 }
238 
239 
240 
241 template <typename OutVectorType, typename InVectorType>
242 inline
243 void
244 IdentityMatrix::Tvmult_add (OutVectorType &out,
245  const InVectorType &in) const
246 {
247  Assert (out.size() == size, ExcDimensionMismatch (out.size(), size));
248  Assert (in.size() == size, ExcDimensionMismatch (in.size(), size));
249 
250  out += in;
251 }
252 
253 
254 #endif
255 
258 DEAL_II_NAMESPACE_CLOSE
259 
260 #endif
void vmult_add(OutVectorType &out, const InVectorType &in) const
unsigned int global_dof_index
Definition: types.h:88
#define Assert(cond, exc)
Definition: exceptions.h:313
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void Tvmult_add(OutVectorType &out, const InVectorType &in) const
types::global_dof_index size_type
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