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
matrixeigensparse.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  Copyright (C) 2007-2012 Universite Joseph Fourier (Grenoble I)
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 3.0 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
30 #ifndef __MatrixEigenSparse_H
31 #define __MatrixEigenSparse_H 1
32 
33 #include <set>
34 
35 #include <boost/version.hpp>
36 #if (BOOST_VERSION >= 103400)
37 #include <boost/none.hpp>
38 #else
39 #include <boost/none_t.hpp>
40 #endif /* BOOST_VERSION >= 103400 */
41 
42 #include <Eigen/Core>
43 #include <Eigen/SparseCore>
44 
47 
48 
49 namespace Feel
50 {
51 template<typename T, typename Storage> class VectorUblas;
52 
71 template<typename T>
73 {
74  typedef MatrixSparse<T> super;
75 public:
76 
77 
81 
82  typedef T value_type;
83  typedef typename type_traits<value_type>::real_type real_type;
84  typedef Eigen::SparseMatrix<T> matrix_type;
85  typedef typename super::graph_type graph_type;
86  typedef typename super::graph_ptrtype graph_ptrtype;
87  typedef Eigen::Triplet<T> triplet;
89 
93 
95 
97 
99 
101 
102 
104 
108 
109  MatrixEigenSparse<T> & operator = ( MatrixSparse<value_type> const& M )
110  {
111  return *this;
112  }
113 
114 
115  value_type operator()( size_type i, size_type j ) const
116  {
117  //return M_mat.row(i).col(j);
118  return 0.;
119  }
120 
122 
126 
131  size_type size1 () const
132  {
133  return M_mat.rows();
134  }
135 
140  size_type size2 () const
141  {
142  return M_mat.cols();
143  }
144 
148  size_type nnz() const
149  {
150  return M_mat.rows()*M_mat.cols();
151  }
152 
158  {
159  return 0;
160  }
161 
167  {
168  return 0;
169  }
170 
174  bool isInitialized() const
175  {
176  return M_is_initialized;
177  }
178 
183  void close () const;
184 
185 
190  bool closed() const
191  {
192  return M_is_closed;
193  }
194 
195 
199  matrix_type const& mat () const
200  {
201  return M_mat;
202  }
203 
207  matrix_type & mat ()
208  {
209  return M_mat;
210  }
211 
213 
217 
218 
220 
224 
233  void init ( const size_type m,
234  const size_type n,
235  const size_type m_l,
236  const size_type n_l,
237  const size_type nnz=30,
238  const size_type noz=10 );
239 
243  void init ( const size_type m,
244  const size_type n,
245  const size_type m_l,
246  const size_type n_l,
247  graph_ptrtype const& graph );
248 
255  void clear ()
256  {
257  //eigen::resize( M_mat, 0, 0 );
258  M_mat.setZero();
259  }
260 
265  void zero ()
266  {
267  M_mat.setZero();
268  }
269 
270  void zero ( size_type start1, size_type stop1, size_type start2, size_type stop2 )
271  {
272  }
273 
282  void add ( const size_type i,
283  const size_type j,
284  const value_type& value )
285  {
286  M_tripletList.push_back(triplet(i, j, value) );
287  }
288 
297  void set ( const size_type i,
298  const size_type j,
299  const value_type& value )
300  {
301  FEELPP_ASSERT( 0 ).error( "nor supported" );
302  }
303 
304 
311  void printMatlab( const std::string name="NULL" ) const;
312 
313 
314 
315  void resize( size_type nr, size_type nc, bool /*preserve*/ = false );
316 
320  void diagonal ( Vector<T>& dest ) const;
321 
325  real_type
326  energy( Vector<value_type> const& __v,
327  Vector<value_type> const& __u, bool transpose = false ) const;
328 
336  void zeroRows( std::vector<int> const& rows, Vector<value_type> const& values, Vector<value_type>& rhs, Context const& on_context );
337 
338  void init() {}
339 
346  void addMatrix( const ublas::matrix<T, ublas::row_major>&,
347  const std::vector<size_type>&,
348  const std::vector<size_type>& ) {}
349 
354  void addMatrix( const boost::numeric::ublas::matrix<T, ublas::row_major>&, const std::vector<size_type>& ) {}
355 
361  void addMatrix( value_type v, MatrixSparse<value_type>& _m );
362 
369  void addMatrix ( int* rows, int nrows,
370  int* cols, int ncols,
371  value_type* data );
372 
373  void scale( const T a );
374 
381  void transpose( MatrixSparse<value_type>& Mt ) const;
382 
390  real_type l1Norm() const
391  {
392  return real_type( 0 );
393  }
394 
405  real_type linftyNorm() const
406  {
407  return real_type( 0 );
408  }
409 
413  void updateBlockMat( boost::shared_ptr<MatrixSparse<value_type> > m, std::vector<size_type> start_i, std::vector<size_type> start_j );
414 
416 
417 
418 
419 protected:
420 
421 private:
422 
423  bool M_is_initialized;
424  mutable bool M_is_closed;
425 
429  mutable matrix_type M_mat;
430  mutable std::vector<triplet> M_tripletList;
431 };
432 
433 
434 
435 } // Feel
436 #endif /* __MatrixEigenSparse_H */

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