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
Feel::MatrixEigenDense< T > Class Template Reference

#include <matrixeigendense.hpp>

Detailed Description

template<typename T>
class Feel::MatrixEigenDense< T >

interface to eigen sparse matrix

this class is a wrapper around csr_matrix<> and csc_matrix<> data type from eigen:: .

* // csr matrix
* MatrixEigen<T,eigen::row_major> m;
* // csc matrix
* MatrixEigen<T,eigen::col_major> m;
*
Author
Christophe Prud'homme
See Also
+ Inheritance diagram for Feel::MatrixEigenDense< T >:

Public Types

Typedefs
typedef T value_type
 
typedef type_traits
< value_type >::real_type 
real_type
 
typedef Eigen::Matrix< T,
Eigen::Dynamic, Eigen::Dynamic > 
matrix_type
 
typedef super::graph_type graph_type
 
typedef super::graph_ptrtype graph_ptrtype
 
- Public Types inherited from Feel::MatrixSparse< T >
typedef boost::shared_ptr
< datamap_type
datamap_ptrtype
 
typedef DataMap datamap_type
 
typedef boost::shared_ptr
< graph_type
graph_ptrtype
 
typedef GraphCSR graph_type
 
typedef type_traits< T >::real_type real_type
 
typedef T value_type
 
typedef boost::shared_ptr
< Vector< T > > 
vector_ptrtype
 
typedef Vector< T > vector_type
 

Public Member Functions

Constructors, destructor
 MatrixEigenDense ()
 
 MatrixEigenDense (size_type r, size_type c)
 
 MatrixEigenDense (MatrixEigenDense const &m)
 
 ~MatrixEigenDense ()
 
Operator overloads
MatrixEigenDense< T > & operator= (MatrixSparse< value_type > const &M)
 
value_type operator() (size_type i, size_type j) const
 
Accessors
size_type size1 () const
 
size_type size2 () const
 
size_type nnz () const
 
size_type rowStart () const
 
size_type rowStop () const
 
bool isInitialized () const
 
void close () const
 
bool closed () const
 
matrix_type const & mat () const
 
matrix_type & mat ()
 
Methods
void init (const size_type m, const size_type n, const size_type m_l, const size_type n_l, const size_type nnz=30, const size_type noz=10)
 
void init (const size_type m, const size_type n, const size_type m_l, const size_type n_l, graph_ptrtype const &graph)
 
void clear ()
 
void zero ()
 
void zero (size_type start1, size_type stop1, size_type start2, size_type stop2)
 
void add (const size_type i, const size_type j, const value_type &value)
 
void set (const size_type i, const size_type j, const value_type &value)
 
void printMatlab (const std::string name="NULL") const
 
void resize (size_type nr, size_type nc, bool=false)
 
void diagonal (Vector< T > &dest) const
 
value_type energy (Vector< value_type > const &__v, Vector< value_type > const &__u, bool transpose=false) const
 
void zeroRows (std::vector< int > const &rows, Vector< value_type > const &values, Vector< value_type > &rhs, Context const &on_context)
 
void init ()
 
void addMatrix (const ublas::matrix< T, ublas::row_major > &, const std::vector< size_type > &, const std::vector< size_type > &)
 
void addMatrix (const boost::numeric::ublas::matrix< T, ublas::row_major > &, const std::vector< size_type > &)
 
void addMatrix (value_type v, MatrixSparse< value_type > &_m)
 
void addMatrix (int *rows, int nrows, int *cols, int ncols, value_type *data)
 
void scale (const T a)
 
void transpose (MatrixSparse< value_type > &Mt) const
 
real_type l1Norm () const
 
real_type linftyNorm () const
 
void updateBlockMat (boost::shared_ptr< MatrixSparse< value_type > > m, std::vector< size_type > start_i, std::vector< size_type > start_j)
 
- Public Member Functions inherited from Feel::MatrixSparse< T >
virtual void addMatrix (const ublas::matrix< value_type > &dm, const std::vector< size_type > &rows, const std::vector< size_type > &cols)=0
 
virtual void addMatrix (const ublas::matrix< value_type > &dm, const std::vector< size_type > &dof_indices)=0
 
void addMatrix (const T &s, boost::shared_ptr< MatrixSparse< T > > &m)
 
void checkProperties () const
 
WorldComm const & comm () const
 
virtual void createSubmatrix (MatrixSparse< T > &submatrix, const std::vector< size_type > &rows, const std::vector< size_type > &cols) const
 
void diagonal (boost::shared_ptr< Vector< T > > &dest) const
 
real_type energy (vector_ptrtype const &v, vector_ptrtype const &u, bool _transpose=false) const
 
graph_ptrtype const & graph () const
 
bool hasGraph () const
 
bool haveConsistentProperties () const
 
std::vector< std::vector
< size_type > > 
indexSplit () const
 
bool isDense () const
 
bool isHermitian () const
 
bool isHermitianPositiveDefinite () const
 
bool isNonHermitian () const
 
bool isPositiveDefinite () const
 
bool isSingular () const
 
datamap_type const & mapCol () const
 
datamap_ptrtype const & mapColPtr () const
 
datamap_type const & mapRow () const
 
datamap_ptrtype const & mapRowPtr () const
 
 MatrixSparse ()
 
 MatrixSparse (datamap_ptrtype const &dmRow, datamap_ptrtype const &dmCol, WorldComm const &worldComm=Environment::worldComm())
 
void multAddVector (const Vector< T > &arg, Vector< T > &dest) const
 
void multVector (const Vector< T > &arg, Vector< T > &dest) const
 
void multVector (const boost::shared_ptr< Vector< T > > &arg, boost::shared_ptr< Vector< T > > &dest) const
 
MatrixSparse< T > & operator= (boost::shared_ptr< MatrixSparse< value_type > > const &M)
 
void print (std::ostream &os=std::cout) const
 
virtual void printPersonal (std::ostream &=std::cout) const
 
virtual void reinitSubmatrix (MatrixSparse< T > &submatrix, const std::vector< size_type > &rows, const std::vector< size_type > &cols) const
 
void setGraph (graph_ptrtype const &graph)
 
virtual void setIndexSplit (std::vector< std::vector< size_type > > const &_indexSplit)
 
void setInitialized (bool _init)
 
void setMapCol (datamap_ptrtype const &d)
 
void setMapRow (datamap_ptrtype const &d)
 
void setMatrixProperties (size_type p)
 
virtual void symmetricPart (MatrixSparse< value_type > &Ms) const
 
void symmetricPart (boost::shared_ptr< MatrixSparse< value_type > > &Ms) const
 
boost::shared_ptr
< MatrixSparse< T > > 
transpose () const
 
void transpose (boost::shared_ptr< MatrixSparse< value_type > > &Mt) const
 
virtual void updateSparsityPattern (const std::vector< std::vector< size_type > > &)
 
virtual ~MatrixSparse ()
 

Additional Inherited Members

- Protected Member Functions inherited from Feel::MatrixSparse< T >
virtual void _get_submatrix (MatrixSparse< T > &, const std::vector< size_type > &, const std::vector< size_type > &, const bool) const
 
- Protected Attributes inherited from Feel::MatrixSparse< T >
graph_ptrtype M_graph
 
std::vector< std::vector
< size_type > > 
M_IndexSplit
 
bool M_is_initialized
 
datamap_ptrtype M_mapCol
 
datamap_ptrtype M_mapRow
 
Context M_mprop
 
WorldComm M_worldComm
 mpi communicator
 

Member Function Documentation

template<typename T>
void Feel::MatrixEigenDense< T >::add ( const size_type  i,
const size_type  j,
const value_type &  value 
)
inlinevirtual

Add value to the element (i,j). Throws an error if the entry does not exist. Still, it is allowed to store zero values in non-existent fields.

Implements Feel::MatrixSparse< T >.

template<typename T>
void Feel::MatrixEigenDense< T >::addMatrix ( const ublas::matrix< T, ublas::row_major > &  ,
const std::vector< size_type > &  ,
const std::vector< size_type > &   
)
inline

Add the full matrix to the Petsc matrix. This is useful for adding an element matrix at assembly time

template<typename T>
void Feel::MatrixEigenDense< T >::addMatrix ( const boost::numeric::ublas::matrix< T, ublas::row_major > &  ,
const std::vector< size_type > &   
)
inline

Same, but assumes the row and column maps are the same. Thus the matrix dm must be square.

template<typename T>
void Feel::MatrixEigenDense< T >::addMatrix ( value_type  v,
MatrixSparse< value_type > &  _m 
)
virtual

Add a Sparse matrix _X, scaled with _a, to this, stores the result in this: $\texttt{this} = \_a*\_X + \texttt{this} $.

Implements Feel::MatrixSparse< T >.

References Feel::MatrixEigenDense< T >::closed().

template<typename T>
void Feel::MatrixEigenDense< T >::addMatrix ( int *  rows,
int  nrows,
int *  cols,
int  ncols,
value_type *  data 
)
virtual

Add the full matrix to the Sparse matrix. This is useful for adding an element matrix at assembly time

Implements Feel::MatrixSparse< T >.

template<typename T>
void Feel::MatrixEigenDense< T >::clear ( )
inlinevirtual

Release all memory and return to a state just like after having called the default constructor.

Implements Feel::MatrixSparse< T >.

template<typename T >
void Feel::MatrixEigenDense< T >::close ( ) const
virtual

close the eigen matrix, that will copy the content of write optimized matrix into a read optimized matrix

Implements Feel::MatrixSparse< T >.

template<typename T>
bool Feel::MatrixEigenDense< T >::closed ( ) const
inlinevirtual

see if Eigen matrix has been closed and fully assembled yet

Implements Feel::MatrixSparse< T >.

template<typename T>
void Feel::MatrixEigenDense< T >::diagonal ( Vector< T > &  dest) const
virtual

Copies the diagonal part of the matrix into dest.

Implements Feel::MatrixSparse< T >.

template<typename T >
MatrixEigenDense< T >::value_type Feel::MatrixEigenDense< T >::energy ( Vector< value_type > const &  __v,
Vector< value_type > const &  __u,
bool  transpose = false 
) const
virtual
template<typename T >
void Feel::MatrixEigenDense< T >::init ( const size_type  m,
const size_type  n,
const size_type  m_l,
const size_type  n_l,
const size_type  nnz = 30,
const size_type  noz = 10 
)
virtual

Initialize a Eigen matrix that is of global dimension $ m \times n $ with local dimensions $ m_l \times n_l $. nnz is the number of on-processor nonzeros per row (defaults to 30). noz is the number of on-processor nonzeros per row (defaults to 30).

Implements Feel::MatrixSparse< T >.

template<typename T >
void Feel::MatrixEigenDense< T >::init ( const size_type  m,
const size_type  n,
const size_type  m_l,
const size_type  n_l,
graph_ptrtype const &  graph 
)
virtual

Initialize using sparsity structure computed by dof_map.

Implements Feel::MatrixSparse< T >.

template<typename T>
bool Feel::MatrixEigenDense< T >::isInitialized ( ) const
inlinevirtual
Returns
true if matrix is initialized/usable, false otherwise

Reimplemented from Feel::MatrixSparse< T >.

template<typename T>
real_type Feel::MatrixEigenDense< T >::l1Norm ( ) const
inlinevirtual

Return the l1-norm of the matrix, that is $|M|_1=max_{all columns j}\sum_{all rows i} |M_ij|$, (max. sum of columns).

This is the natural matrix norm that is compatible to the l1-norm for vectors, i.e. $|Mv|_1\leq |M|_1 |v|_1$.

Implements Feel::MatrixSparse< T >.

template<typename T>
real_type Feel::MatrixEigenDense< T >::linftyNorm ( ) const
inlinevirtual

Return the linfty-norm of the matrix, that is

$|M|_\infty=max_{all rows i}\sum_{all columns j} |M_ij|$,

(max. sum of rows). This is the natural matrix norm that is compatible to the linfty-norm of vectors, i.e. $|Mv|_\infty \leq |M|_\infty |v|_\infty$.

Implements Feel::MatrixSparse< T >.

template<typename T>
matrix_type const& Feel::MatrixEigenDense< T >::mat ( ) const
inline

Returns the read optimized eigen matrix.

template<typename T>
matrix_type& Feel::MatrixEigenDense< T >::mat ( )
inline

Returns the read optimized eigen matrix.

template<typename T>
size_type Feel::MatrixEigenDense< T >::nnz ( ) const
inline
Returns
the number of non-zeros entries in the matrix
template<typename T>
value_type Feel::MatrixEigenDense< T >::operator() ( size_type  i,
size_type  j 
) const
inlinevirtual

Return the value of the entry (i,j). This may be an expensive operation and you should always take care where to call this function. In order to avoid abuse, this function throws an exception if the required element does not exist in the matrix.

In case you want a function that returns zero instead (for entries that are not in the sparsity pattern of the matrix), use the el function.

Implements Feel::MatrixSparse< T >.

template<typename T >
void Feel::MatrixEigenDense< T >::printMatlab ( const std::string  name = "NULL") const
virtual

Print the contents of the matrix in Matlab's sparse matrix format. Optionally prints the matrix to the file named name. If name is not specified it is dumped to the screen.

Reimplemented from Feel::MatrixSparse< T >.

template<typename T>
size_type Feel::MatrixEigenDense< T >::rowStart ( ) const
inlinevirtual

return row_start, the index of the first matrix row stored on this processor

Implements Feel::MatrixSparse< T >.

template<typename T>
size_type Feel::MatrixEigenDense< T >::rowStop ( ) const
inlinevirtual

return row_stop, the index of the last matrix row (+1) stored on this processor

Implements Feel::MatrixSparse< T >.

template<typename T>
void Feel::MatrixEigenDense< T >::set ( const size_type  i,
const size_type  j,
const value_type &  value 
)
inlinevirtual

set value to the element (i,j). Throws an error if the entry does not exist. Still, it is allowed to store zero values in non-existent fields.

Implements Feel::MatrixSparse< T >.

template<typename T>
size_type Feel::MatrixEigenDense< T >::size1 ( ) const
inlinevirtual
Returns
m, the row-dimension of the matrix where the marix is $ M \times N $.

Implements Feel::MatrixSparse< T >.

template<typename T>
size_type Feel::MatrixEigenDense< T >::size2 ( ) const
inlinevirtual
Returns
n, the column-dimension of the matrix where the marix is $ M \times N $.

Implements Feel::MatrixSparse< T >.

template<typename T >
void Feel::MatrixEigenDense< T >::transpose ( MatrixSparse< value_type > &  Mt) const
virtual

Returns the transpose of a matrix

Parameters
Mthe matrix to transpose
Mtthe matrix transposed

Implements Feel::MatrixSparse< T >.

template<typename T >
void Feel::MatrixEigenDense< T >::updateBlockMat ( boost::shared_ptr< MatrixSparse< value_type > >  m,
std::vector< size_type start_i,
std::vector< size_type start_j 
)
virtual

update a block matrix

Implements Feel::MatrixSparse< T >.

template<typename T>
void Feel::MatrixEigenDense< T >::zero ( )
inlinevirtual

Set all entries to 0. This method retains sparsity structure.

Implements Feel::MatrixSparse< T >.

template<typename T>
void Feel::MatrixEigenDense< T >::zero ( size_type  start1,
size_type  size1,
size_type  start2,
size_type  size2 
)
inlinevirtual

Set entries between to 0.

Implements Feel::MatrixSparse< T >.

template<typename T >
void Feel::MatrixEigenDense< T >::zeroRows ( std::vector< int > const &  rows,
Vector< value_type > const &  values,
Vector< value_type > &  rhs,
Context const &  on_context 
)
virtual

eliminates row without change pattern, and put 1 on the diagonal entry

Warning
if the matrix was symmetric before this operation, it won't be afterwards. So use the proper solver (nonsymmetric)

Implements Feel::MatrixSparse< T >.

References Feel::ON_ELIMINATION_KEEP_DIAGONAL, and Feel::Vector< T >::set().


The documentation for this class was generated from the following files:

Generated on Sun Dec 22 2013 13:11:20 for Feel++ by doxygen 1.8.5