HermesCommon  2.0
Hermes::Algebra::SparseMatrix< Scalar > Class Template Referenceabstract

General (abstract) sparse matrix representation in Hermes. More...

#include <matrix.h>

+ Inheritance diagram for Hermes::Algebra::SparseMatrix< Scalar >:

Classes

struct  Page
 Structure for storing indices in sparse matrix. More...
 

Public Member Functions

 SparseMatrix (unsigned int size)
 
virtual void prealloc (unsigned int n)
 
virtual void pre_add_ij (unsigned int row, unsigned int col)
 
virtual void finish ()
 Finish manipulation with matrix (called before solving)
 
virtual unsigned int get_size ()
 
virtual void add_sparse_matrix (SparseMatrix *mat)
 
virtual void add_sparse_to_diagonal_blocks (int num_stages, SparseMatrix< Scalar > *mat)
 
virtual int get_num_row_entries (unsigned int row)
 
virtual void extract_row_copy (unsigned int row, unsigned int len, unsigned int &n_entries, double *vals, unsigned int *idxs)
 
virtual int get_num_col_entries (unsigned int col)
 
virtual void extract_col_copy (unsigned int col, unsigned int len, unsigned int &n_entries, double *vals, unsigned int *idxs)
 
virtual void multiply_with_vector (Scalar *vector_in, Scalar *vector_out)
 Multiply with a vector.
 
virtual void multiply_with_Scalar (Scalar value)
 Multiply with a Scalar.
 
virtual SparseMatrixduplicate ()
 Duplicate sparse matrix (including allocation).
 
virtual double get_fill_in () const =0
 Get fill-in.
 
virtual unsigned int get_nnz () const
 
- Public Member Functions inherited from Hermes::Algebra::Matrix< Scalar >
unsigned int get_size ()
 
 Matrix (unsigned int size)
 
virtual void alloc ()=0
 allocate the memory for stiffness matrix and right-hand side
 
virtual void free ()=0
 free the memory associated with stiffness matrix and right-hand side
 
virtual Scalar get (unsigned int m, unsigned int n)=0
 
virtual void zero ()=0
 Zero the matrix.
 
virtual void add_to_diagonal (Scalar v)=0
 Add a number to each diagonal entry.
 
virtual void add (unsigned int m, unsigned int n, Scalar v)=0
 
virtual void add (unsigned int m, unsigned int n, Scalar **mat, int *rows, int *cols)=0
 
virtual bool dump (FILE *file, const char *var_name, EMatrixDumpFormat fmt=DF_MATLAB_SPARSE, char *number_format="%lf")=0
 
virtual unsigned int get_matrix_size () const =0
 
- Public Member Functions inherited from Hermes::Mixins::Loggable
void set_verbose_output (bool to_set)
 Sets the attribute verbose_output to the paramater option passed.
 
bool get_verbose_output () const
 Returns the current value of verbose_output;.
 
void set_verbose_callback (callbackFn callback)
 
callbackFn get_verbose_callback () const
 Returns the current value of verbose_callback;.
 

Public Attributes

unsigned row_storage:1
 
unsigned col_storage:1
 

Protected Member Functions

int sort_and_store_indices (Page *page, int *buffer, int *max)
 
int get_num_indices ()
 

Protected Attributes

Page ** pages
 array of pages with indices array. Each field of arra contains pages for one column
 
int mem_size
 mem stat
 
- Protected Attributes inherited from Hermes::Algebra::Matrix< Scalar >
unsigned int size
 matrix size
 

Static Protected Attributes

static const int PAGE_SIZE = 62
 Size of page (max number of indices stored in one page).
 

Detailed Description

template<typename Scalar>
class Hermes::Algebra::SparseMatrix< Scalar >

General (abstract) sparse matrix representation in Hermes.

Definition at line 348 of file matrix.h.

Constructor & Destructor Documentation

template<typename Scalar >
Hermes::Algebra::SparseMatrix< Scalar >::SparseMatrix ( unsigned int  size)

Constructor of sparse matrix

Parameters
[in]sizesize of matrix

Definition at line 131 of file matrix.cpp.

Member Function Documentation

template<typename Scalar>
virtual void Hermes::Algebra::SparseMatrix< Scalar >::add_sparse_matrix ( SparseMatrix< Scalar > *  mat)
inlinevirtual

Add matrix

Parameters
matmatrix to add

Definition at line 374 of file matrix.h.

template<typename Scalar>
virtual void Hermes::Algebra::SparseMatrix< Scalar >::add_sparse_to_diagonal_blocks ( int  num_stages,
SparseMatrix< Scalar > *  mat 
)
inlinevirtual

Add matrix to diagonal Matrices must be the same type of solver

Parameters
[in]num_stagesmatrix is added to num_stages positions. num_stages * size(added matrix) = size(target matrix)
[in]matadded matrix

Definition at line 383 of file matrix.h.

template<typename Scalar>
virtual void Hermes::Algebra::SparseMatrix< Scalar >::extract_col_copy ( unsigned int  col,
unsigned int  len,
unsigned int &  n_entries,
double *  vals,
unsigned int *  idxs 
)
inlinevirtual

Extract the copy of a column

Parameters
[in]col- global column to extract
[in]len- length of 'vals' and 'idxs' arrays.
[out]n_entries- number of nonzero entries extracted.
[out]vals- extracted values for this column.
[out]idxs- extracted global row indices for the corresponding values.

Definition at line 418 of file matrix.h.

template<typename Scalar>
virtual void Hermes::Algebra::SparseMatrix< Scalar >::extract_row_copy ( unsigned int  row,
unsigned int  len,
unsigned int &  n_entries,
double *  vals,
unsigned int *  idxs 
)
inlinevirtual

Extract the copy of a row

Parameters
[in]row- global row to extract
[in]len- length of 'vals' and 'idxs' arrays.
[out]n_entries- number of nonzero entries extracted.
[out]vals- extracted values for this row.
[out]idxs- extracted global column indices for the corresponding values.

Definition at line 401 of file matrix.h.

template<typename Scalar>
virtual unsigned int Hermes::Algebra::SparseMatrix< Scalar >::get_nnz ( ) const
inlinevirtual

get number of nonzero numbers in matrix

Returns
number of nonzero numbers in matrix

Definition at line 443 of file matrix.h.

template<typename Scalar>
virtual int Hermes::Algebra::SparseMatrix< Scalar >::get_num_col_entries ( unsigned int  col)
inlinevirtual

Return the number of entries in a specified column

Parameters
[in]col- index of the column
Returns
- the number of entries in the column 'col'

Definition at line 409 of file matrix.h.

template<typename Scalar >
int Hermes::Algebra::SparseMatrix< Scalar >::get_num_indices ( )
protected

get number of indices in all pages

Returns
number of indices

Definition at line 197 of file matrix.cpp.

template<typename Scalar>
virtual int Hermes::Algebra::SparseMatrix< Scalar >::get_num_row_entries ( unsigned int  row)
inlinevirtual

Return the number of entries in a specified row

Parameters
[in]row- index of the row
Returns
- the number of entries in the row 'row'

Definition at line 392 of file matrix.h.

template<typename Scalar >
void Hermes::Algebra::SparseMatrix< Scalar >::pre_add_ij ( unsigned int  row,
unsigned int  col 
)
virtual

add indices of nonzero matrix element

Parameters
[in]row- row index
[in]col- column index

Definition at line 162 of file matrix.cpp.

template<typename Scalar >
void Hermes::Algebra::SparseMatrix< Scalar >::prealloc ( unsigned int  n)
virtual

prepare memory

Parameters
[in]n- number of unknowns

Definition at line 153 of file matrix.cpp.

template<typename Scalar >
int Hermes::Algebra::SparseMatrix< Scalar >::sort_and_store_indices ( Page page,
int *  buffer,
int *  max 
)
protected

gather all pages in the buffer, delete them, sort buffer and remove duplicities

Parameters
[in]pagefirst page with indices
[out]bufferbuffer to which indices will be copied
[in]maxmaximum indices to be stored (probably)
Todo:
max parameter does nothing (not implemented)
Returns
number of indices

Definition at line 175 of file matrix.cpp.

Member Data Documentation

template<typename Scalar>
unsigned Hermes::Algebra::SparseMatrix< Scalar >::col_storage
Todo:
document

Definition at line 439 of file matrix.h.

template<typename Scalar>
unsigned Hermes::Algebra::SparseMatrix< Scalar >::row_storage
Todo:
document

Definition at line 438 of file matrix.h.


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