Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
matrixvalue.hpp
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2005-11-13
7 
8  Copyright (C) 2005,2006 EPFL
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 3.0 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
29 #ifndef __MatrixValue_H
30 #define __MatrixValue_H 1
31 
32 #include <set>
33 
34 #include <boost/numeric/ublas/vector.hpp>
35 
36 
37 namespace Feel
38 {
50 template<typename T>
52 {
53 public:
54 
55 
59 
60  typedef T value_type;
61 
62  typedef value_type matrix_type;
63  typedef std::vector<std::set<size_type> > pattern_type;
64 
65  static const bool is_row_major = true;
66 
67 
69 
73 
74  MatrixValue( value_type acc = value_type( 0 ) )
75  :
76  M_mat( acc )
77  {}
78  MatrixValue( MatrixValue const & m )
79  :
80  M_mat( m.M_mat )
81  {}
82 
83  ~MatrixValue()
84  {
85  }
86 
88 
92 
94 
98 
103  unsigned int size1 () const
104  {
105  return 1;
106  }
107 
112  unsigned int size2 () const
113  {
114  return 1;
115  }
116 
120  size_type nnz() const
121  {
122  return 1;
123  }
124 
129  unsigned int rowStart () const
130  {
131  return 0;
132  }
133 
138  unsigned int rowStop () const
139  {
140  return 0;
141  }
142 
146  bool isInitialized() const
147  {
148  return true;
149  }
150 
155  void close () const;
156 
157 
162  bool closed() const
163  {
164  return true;
165  }
166 
167 
171  matrix_type const& mat () const
172  {
173  return M_mat;
174  }
175 
179  matrix_type & mat ()
180  {
181  return M_mat;
182  }
183 
187  matrix_type const& wmat () const
188  {
189  return M_mat;
190  }
191 
195  matrix_type & wmat ()
196  {
197  return M_mat;
198  }
199 
200 
201 
203 
207 
208 
210 
214 
223  void init ( const unsigned int /*m*/,
224  const unsigned int /*n*/,
225  const unsigned int /*m_l*/,
226  const unsigned int /*n_l*/,
227  const unsigned int /*nnz*/=30,
228  const unsigned int /*noz*/=10 )
229  {
230  this->zero();
231  }
232 
239  void clear ()
240  {
241  M_mat = 0;
242  }
243 
248  void zero ()
249  {
250  M_mat = 0;
251  }
252 
253  void zero ( size_type /*start1*/, size_type /*stop1*/, size_type /*start2*/, size_type /*stop2*/ )
254  {
255  M_mat = 0;
256  }
257 
261  void add ( const unsigned int /*i*/,
262  const unsigned int /*j*/,
263  const value_type value )
264  {
265  M_mat += value;
266  }
267 
271  void set ( const unsigned int /*i*/,
272  const unsigned int /*j*/,
273  const value_type value )
274  {
275  M_mat = value;
276  }
277 
278 
279 
286  void printMatlab( const std::string name="NULL" ) const;
287 
288 
292  void fill( pattern_type const& );
293 
294  void resize( size_type /* nr*/, size_type /*nc*/, bool /*preserve*/ = false )
295  {
296 
297  }
298 
302  value_type
303  energy( ublas::vector<value_type> const& /*__v*/,
304  ublas::vector<value_type> const& /*__u*/ ) const
305  {
306  return M_mat;
307  }
308 
312  void diagonalize( size_type );
314 
315 
316 
317 protected:
318 
319 private:
320 
324  mutable matrix_type M_mat;
325 
326 };
327 
328 template<typename T>
329 void
330 MatrixValue<T>::diagonalize( size_type __dof_index )
331 {
332  FEELPP_ASSERT( 0 ).error( "diagonalize is undefined for this matrix type" );
333 }
334 template<typename T>
335 void
336 MatrixValue<T>::fill( pattern_type const& /*__pattern*/ )
337 {
338 }
339 
340 template<typename T>
341 void
343 {
344 }
345 
346 template<typename T>
347 void
348 MatrixValue<T>::printMatlab( const std::string /*filename*/ ) const
349 {
350 }
351 
352 } // Feel
353 #endif /* __MatrixValue_H */

Generated on Fri Oct 25 2013 14:24:18 for Feel++ by doxygen 1.8.4