HermesCommon 1.0
Classes | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes
Hermes::Algebra::SparseMatrix< Scalar > Class Template Reference

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

#include <matrix.h>

Inheritance diagram for Hermes::Algebra::SparseMatrix< Scalar >:
Hermes::Algebra::Matrix< Scalar > Hermes::Mixins::Loggable Hermes::Algebra::CSCMatrix< Scalar > Hermes::Algebra::UMFPackMatrix< Scalar >

List of all members.

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

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) [inline, virtual]

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 
) [inline, virtual]

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

Reimplemented in Hermes::Algebra::CSCMatrix< Scalar >.

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 
) [inline, virtual]

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 
) [inline, virtual]

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 [inline, virtual]

get number of nonzero numbers in matrix

Returns:
number of nonzero numbers in matrix

Reimplemented in Hermes::Algebra::CSCMatrix< Scalar >.

Definition at line 443 of file matrix.h.

template<typename Scalar>
virtual int Hermes::Algebra::SparseMatrix< Scalar >::get_num_col_entries ( unsigned int  col) [inline, virtual]

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) [inline, virtual]

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>
virtual unsigned int Hermes::Algebra::SparseMatrix< Scalar >::get_size ( ) [inline, virtual]

get size of matrix

Returns:
size of matrix

Reimplemented from Hermes::Algebra::Matrix< Scalar >.

Definition at line 370 of file matrix.h.

Referenced by Hermes::Algebra::CSCMatrix< Scalar >::add_matrix(), and Hermes::Algebra::CSCMatrix< Scalar >::add_to_diagonal_blocks().

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: