Feel++  0.91.4
Feel::MatrixBlockBase< T > Class Template Reference
Inheritance diagram for Feel::MatrixBlockBase< T >:
Feel::MatrixSparse< T > Feel::MatrixBlock< NR, NC, T >

List of all members.

Public Types

Typedefs
typedef MatrixBlockBase< T > self_type
typedef super::value_type value_type
typedef super::real_type real_type
typedef Backend< value_type > backend_type
typedef boost::shared_ptr
< backend_type
backend_ptrtype
typedef super matrix_type
typedef boost::shared_ptr
< matrix_type
matrix_ptrtype
typedef std::vector
< matrix_ptrtype > 
vector_matrix_ptrtype
typedef super::graph_type graph_type
typedef super::graph_ptrtype graph_ptrtype
- Public Types inherited from Feel::MatrixSparse< T >
typedef Vector< T > vector_type
typedef boost::shared_ptr
< Vector< T > > 
vector_ptrtype

Public Member Functions

Constructors, destructor
 MatrixBlockBase (vf::BlocksBase< matrix_ptrtype > const &blockSet, backend_type &backend, bool copy_values=true, bool diag_is_nonzero=true)
void mergeBlockGraph (graph_ptrtype &globGraphb, matrix_ptrtype m, size_type start_i, size_type start_j)
 MatrixBlockBase (MatrixBlockBase const &mb)
 ~MatrixBlockBase ()
Operator overloads
MatrixBlockBase operator= (MatrixBlockBase const &mb)
Accessors
matrix_ptrtype getSparseMatrix ()
- Public Member Functions inherited from Feel::MatrixSparse< T >
 MatrixSparse ()
 MatrixSparse (DataMap const &dmRow, DataMap const &dmCol, WorldComm const &worldComm=WorldComm())
virtual ~MatrixSparse ()
DataMap const & mapRow () const
DataMap const & mapCol () const
void setMapRow (DataMap const &d)
void setMapCol (DataMap const &d)
virtual bool isInitialized () const
virtual void updateSparsityPattern (const std::vector< std::vector< size_type > > &)
virtual void setIndexSplit (std::vector< std::vector< int > > const &_indexSplit)
std::vector< std::vector< int > > indexSplit () const
bool hasGraph () const
graph_ptrtype const & graph () const
void setGraph (graph_ptrtype const &graph)
void setMatrixProperties (size_type p)
bool isHermitian () const
bool isNonHermitian () const
bool isHermitianPositiveDefinite () const
bool isSingular () const
bool isPositiveDefinite () const
bool haveConsistentProperties () const
void checkProperties () const
WorldComm const & comm () const
void addMatrix (const T &s, boost::shared_ptr< MatrixSparse< T > > &m)
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
void multAddVector (const Vector< T > &arg, Vector< T > &dest) const
MatrixSparse< T > & operator= (boost::shared_ptr< MatrixSparse< value_type > > const &M)
void diagonal (boost::shared_ptr< Vector< T > > &dest) const
boost::shared_ptr
< MatrixSparse< T > > 
transpose () const
void transpose (boost::shared_ptr< MatrixSparse< value_type > > &Mt) const
virtual void symmetricPart (MatrixSparse< value_type > &Ms) const
void symmetricPart (boost::shared_ptr< MatrixSparse< value_type > > &Ms) const
virtual real_type energy (vector_type const &v, vector_type const &u, bool transpose=false) const =0
real_type energy (vector_ptrtype const &v, vector_ptrtype const &u, bool _transpose=false) const
void setInitialized (bool _init)

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 size1, size_type start2, size_type size2)
void close () const
size_type size1 () const
size_type size2 () const
size_type rowStart () const
size_type rowStop () const
void set (const size_type i, const size_type j, const value_type &value)
void add (const size_type i, const size_type j, const value_type &value)
void addMatrix (const ublas::matrix< value_type > &dm, const std::vector< size_type > &rows, const std::vector< size_type > &cols)
void addMatrix (int *rows, int nrows, int *cols, int ncols, value_type *data)
void addMatrix (const ublas::matrix< value_type > &dm, const std::vector< size_type > &dof_indices)
void addMatrix (const value_type, MatrixSparse< value_type > &)
void scale (const value_type)
value_type operator() (const size_type i, const size_type j) const
self_typeoperator= (MatrixSparse< value_type > const &M)
void diagonal (Vector< value_type > &out) const
void transpose (MatrixSparse< value_type > &Mt) const
value_type energy (Vector< value_type > const &__v, Vector< value_type > const &__u, bool transpose=false) const
real_type l1Norm () const
real_type linftyNorm () const
bool closed () const
void print (std::ostream &os=std::cout) const
void printPersonal (std::ostream &=std::cout) const
void printMatlab (const std::string name="NULL") const
void createSubmatrix (MatrixSparse< value_type > &submatrix, const std::vector< size_type > &rows, const std::vector< size_type > &cols) const
void reinitSubmatrix (MatrixSparse< value_type > &submatrix, const std::vector< size_type > &rows, const std::vector< size_type > &cols) const
void zeroRows (std::vector< int > const &rows, std::vector< value_type > const &values, Vector< value_type > &rhs, Context const &on_context)
void updateBlockMat (boost::shared_ptr< MatrixSparse< value_type > > m, size_type start_i, size_type start_j)
template<typename U >
std::ostream & operator<< (std::ostream &os, const MatrixSparse< U > &m)

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 >
WorldComm M_worldComm
 mpi communicator
bool _M_is_initialized
graph_ptrtype _M_graph
Context M_mprop
std::vector< std::vector< int > > M_IndexSplit
DataMap M_mapRow
DataMap M_mapCol

Member Function Documentation

template<typename T >
void Feel::MatrixBlockBase< 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::MatrixBlockBase< T >::addMatrix ( const ublas::matrix< value_type > &  dm,
const std::vector< size_type > &  rows,
const std::vector< size_type > &  cols 
)
virtual

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

Implements Feel::MatrixSparse< T >.

Referenced by Feel::MatrixBlockBase< T >::addMatrix().

template<typename T >
void Feel::MatrixBlockBase< 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::MatrixBlockBase< T >::addMatrix ( const ublas::matrix< value_type > &  dm,
const std::vector< size_type > &  dof_indices 
)
inlinevirtual

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

Implements Feel::MatrixSparse< T >.

References Feel::MatrixBlockBase< T >::addMatrix().

template<typename T >
void Feel::MatrixBlockBase< T >::addMatrix ( const value_type  a_in,
MatrixSparse< value_type > &  X_in 
)
inlinevirtual

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 >.

template<typename T >
void Feel::MatrixBlockBase< T >::clear ( )
virtual

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::MatrixBlockBase< T >::close ( ) const
inlinevirtual

Call the Sparse assemble routines. sends necessary messages to other processors

Implements Feel::MatrixSparse< T >.

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

see if Sparse matrix has been closed and fully assembled yet

Implements Feel::MatrixSparse< T >.

template<typename T>
void Feel::MatrixBlockBase< T >::createSubmatrix ( MatrixSparse< value_type > &  submatrix,
const std::vector< size_type > &  rows,
const std::vector< size_type > &  cols 
) const
inlinevirtual

This function creates a matrix called "submatrix" which is defined by the row and column indices given in the "rows" and "cols" entries. Currently this operation is only defined for the PetscMatrix type.

Reimplemented from Feel::MatrixSparse< T >.

References Feel::MatrixSparse< T >::_get_submatrix().

template<typename T >
void Feel::MatrixBlockBase< T >::diagonal ( Vector< value_type > &  out) const
virtual

Returns the diagonal of the block matrix

Parameters:
outthe vector to store the diagonal

Implements Feel::MatrixSparse< T >.

template<typename T >
MatrixBlockBase< T >::value_type Feel::MatrixBlockBase< T >::energy ( Vector< value_type > const &  __v,
Vector< value_type > const &  __u,
bool  transpose = false 
) const
Returns:
$ v^T M u $
template<typename T >
void Feel::MatrixBlockBase< 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 Petsc 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::MatrixBlockBase< 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 >
MatrixBlockBase< T >::real_type Feel::MatrixBlockBase< 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 >
MatrixBlockBase< T >::real_type Feel::MatrixBlockBase< 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 >
MatrixBlockBase< T >::value_type Feel::MatrixBlockBase< T >::operator() ( const size_type  i,
const 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::MatrixBlockBase< T >::print ( std::ostream &  os = std::cout) const

Print the contents of the matrix to the screen in a uniform style, regardless of matrix/solver package being used.

Reimplemented from Feel::MatrixSparse< T >.

template<typename T >
void Feel::MatrixBlockBase< 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>
void Feel::MatrixBlockBase< T >::printPersonal ( std::ostream &  = std::cout) const
inlinevirtual

Print the contents of the matrix to the screen in a package-personalized style, if available.

Reimplemented from Feel::MatrixSparse< T >.

template<typename T>
void Feel::MatrixBlockBase< T >::reinitSubmatrix ( MatrixSparse< value_type > &  submatrix,
const std::vector< size_type > &  rows,
const std::vector< size_type > &  cols 
) const
inlinevirtual

This function is similar to the one above, but it allows you to reuse the existing sparsity pattern of "submatrix" instead of reallocating it again. This should hopefully be more efficient if you are frequently extracting submatrices of the same size.

Reimplemented from Feel::MatrixSparse< T >.

References Feel::MatrixSparse< T >::_get_submatrix().

template<typename T >
size_type Feel::MatrixBlockBase< 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::MatrixBlockBase< 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::MatrixBlockBase< T >::set ( const size_type  i,
const size_type  j,
const value_type &  value 
)
inlinevirtual

Set the element (i,j) to value. 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::MatrixBlockBase< 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::MatrixBlockBase< 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::MatrixBlockBase< T >::transpose ( MatrixSparse< value_type > &  Mt) const
virtual

Returns the transpose of a matrix

Parameters:
Mtthe matrix transposed

Implements Feel::MatrixSparse< T >.

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

update a block matrix

Implements Feel::MatrixSparse< T >.

template<typename T >
void Feel::MatrixBlockBase< T >::zero ( )
virtual

Set all entries to 0.

Implements Feel::MatrixSparse< T >.

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

Set entries between to 0.

Implements Feel::MatrixSparse< T >.

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

eliminate rows 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 >.


Friends And Related Function Documentation

template<typename T>
template<typename U >
std::ostream& operator<< ( std::ostream &  os,
const MatrixSparse< U > &  m 
)
friend

Same as the print method above, but allows you to print to a stream in the standard syntax.

Reimplemented from Feel::MatrixSparse< T >.