|
ug4
|
sparse matrix for big, variable sparse matrices. More...
#include <mapsparsematrix.h>
Classes | |
| struct | connection |
| class | const_row_iterator |
| class | row_iterator |
Public Types | |
| enum | { rows_sorted =true } |
| typedef SparseMatrix< value_type > | this_type |
| typedef TValueType | value_type |
Public Member Functions | |
| template<typename M > | |
| void | add (const M &mat) |
| void | add_matrix_row (size_t row, connection *c, size_t nr) |
| template<typename Vector_type > | |
| bool | apply (Vector_type &res, const Vector_type &x) const |
| calculate res = A x | |
| template<typename Vector_type > | |
| bool | apply_transposed (Vector_type &res, const Vector_type &x) const |
| calculate res = A.T x | |
| template<typename vector_t > | |
| bool | axpy (vector_t &dest, const number &alpha1, const vector_t &v1, const number &beta1, const vector_t &w1) const |
| calculate dest = alpha1*v1 + beta1*A*w1 (A = this matrix) | |
| template<typename vector_t > | |
| bool | axpy_transposed (vector_t &dest, const number &alpha1, const vector_t &v1, const number &beta1, const vector_t &w1) const |
| calculate dest = alpha1*v1 + beta1*A^T*w1 (A = this matrix) | |
| row_iterator | begin_row (size_t r) |
| const_row_iterator | begin_row (size_t r) const |
| void | defragment () |
| row_iterator | end_row (size_t r) |
| const_row_iterator | end_row (size_t r) const |
| template<typename M > | |
| void | get (M &mat) const |
| get local matrix | |
| row_iterator | get_connection (size_t r, size_t c) |
| const_row_iterator | get_connection (size_t r, size_t c) const |
| row_iterator | get_connection (size_t r, size_t c, bool &bFound) |
| const_row_iterator | get_connection (size_t r, size_t c, bool &bFound) const |
| bool | is_isolated (size_t i) const |
| check for isolated condition of an index | |
| MapSparseMatrix () | |
| constructor for empty SparseMatrix | |
| template<typename vector_t > | |
| void | mat_mult_add_row (size_t row, typename vector_t::value_type &dest, double alpha, const vector_t &v) const |
| calculates dest += alpha * A[row, .] v; | |
| template<typename Vector_type > | |
| bool | matmul_minus (Vector_type &res, const Vector_type &x) const |
| calculate res -= A x | |
| size_t | num_cols () const |
| returns the number of cols | |
| size_t | num_connections (size_t i) const |
| returns number of connections of row row. | |
| size_t | num_rows () const |
| returns number of rows | |
| value_type & | operator() (size_t r, size_t c) |
| const value_type & | operator() (size_t r, size_t c) const |
| SparseMatrix< value_type > & | operator*= (double d) |
| SparseMatrix< value_type > & | operator= (const SparseMatrix< value_type > &B) |
| void | p () const |
| void | pr (size_t row) const |
| void | print (const char *const name=NULL) const |
| void | print_to_file (const char *filename) const |
| void | printrow (size_t row) const |
| void | printtype () const |
| bool | resize (size_t newRows, size_t newCols) |
| resizes the SparseMatrix | |
| bool | scale (double d) |
| template<typename M > | |
| void | set (const M &mat) |
| set local matrix | |
| bool | set (double a) |
| set matrix to Id*a | |
| bool | set_as_copy_of (const MapSparseMatrix< value_type > &B, double scale=1.0) |
| create/recreate this as a copy of SparseMatrix B | |
| bool | set_as_transpose_of (const SparseMatrix< value_type > &B, double scale=1.0) |
| write in a empty SparseMatrix (this) the transpose SparseMatrix of B. | |
| void | set_matrix_row (size_t row, connection *c, size_t nr) |
| size_t | total_num_connections () const |
| returns the total number of connections | |
| virtual | ~MapSparseMatrix () |
| destructor | |
Protected Attributes | |
| size_t | cols |
| std::vector< std::map< size_t, TValueType > > | data |
Private Member Functions | |
| MapSparseMatrix (MapSparseMatrix &) | |
| disallow copy operator | |
Friends | |
| std::ostream & | operator<< (std::ostream &out, const MapSparseMatrix &m) |
sparse matrix for big, variable sparse matrices.
| T | blocktype |
| typedef SparseMatrix<value_type> ug::MapSparseMatrix< TValueType >::this_type |
| typedef TValueType ug::MapSparseMatrix< TValueType >::value_type |
| ug::MapSparseMatrix< T >::MapSparseMatrix | ( | ) |
constructor for empty SparseMatrix
|
inlinevirtual |
destructor
|
private |
disallow copy operator
| void ug::MapSparseMatrix< TValueType >::add | ( | const M & | mat | ) |
Add a local matrix
The local matrix type must declare the following members:
| mat | the whole local matrix type |
| void ug::MapSparseMatrix< T >::add_matrix_row | ( | size_t | row, |
| connection * | c, | ||
| size_t | nr | ||
| ) |
adds the connections c to the matrixrow row. if c has a connection con with con.iIndex=i, and the matrix already has a connection (row, i), the function will set A(row,i) += con.dValue. otherwise the connection A(row, i) is created and set to con.dValue.
| row | row to add to |
| c | connections ("row") to be added the row. |
| nr | number of connections in array c. |
References ug::MapSparseMatrix< TValueType >::connection::iIndex, and PROFILE_BEGIN_GROUP.
|
inline |
calculate res = A x
References ug::MapSparseMatrix< TValueType >::axpy().
|
inline |
calculate res = A.T x
References ug::MapSparseMatrix< TValueType >::axpy_transposed().
| bool ug::MapSparseMatrix< T >::axpy | ( | vector_t & | dest, |
| const number & | alpha1, | ||
| const vector_t & | v1, | ||
| const number & | beta1, | ||
| const vector_t & | w1 | ||
| ) | const |
calculate dest = alpha1*v1 + beta1*A*w1 (A = this matrix)
References begin_row(), end_row(), ug::MapSparseMatrix< TValueType >::const_row_iterator::index(), ug::MatMult(), ug::MatMultAdd(), num_rows(), PROFILE_BEGIN_GROUP, ug::MapSparseMatrix< TValueType >::const_row_iterator::value(), and ug::VecScaleAssign().
Referenced by ug::MapSparseMatrix< TValueType >::apply(), and ug::MapSparseMatrix< TValueType >::matmul_minus().
| bool ug::MapSparseMatrix< T >::axpy_transposed | ( | vector_t & | dest, |
| const number & | alpha1, | ||
| const vector_t & | v1, | ||
| const number & | beta1, | ||
| const vector_t & | w1 | ||
| ) | const |
calculate dest = alpha1*v1 + beta1*A^T*w1 (A = this matrix)
References begin_row(), end_row(), ug::MatMultTransposedAdd(), num_rows(), PROFILE_BEGIN_GROUP, and ug::VecScaleAssign().
Referenced by ug::MapSparseMatrix< TValueType >::apply_transposed(), and ug::MatMultTransposedAdd().
|
inline |
References ug::MapSparseMatrix< TValueType >::data.
Referenced by ug::MapSparseMatrix< TValueType >::set_as_copy_of().
|
inline |
References ug::MapSparseMatrix< TValueType >::data.
|
inline |
|
inline |
|
inline |
References ug::MapSparseMatrix< TValueType >::data.
| void ug::MapSparseMatrix< TValueType >::get | ( | M & | mat | ) | const |
get local matrix
|
inline |
| r | index of the row |
| c | index of the column |
References ug::MapSparseMatrix< TValueType >::data, and ug::find().
|
inline |
| r | index of the row |
| c | index of the column |
References ug::MapSparseMatrix< TValueType >::data, and ug::find().
|
inline |
| r | index of the row |
| c | index of the column |
References ug::MapSparseMatrix< TValueType >::data, ug::MapSparseMatrix< TValueType >::end_row(), and ug::find().
|
inline |
| r | index of the row |
| c | index of the column |
References ug::MapSparseMatrix< TValueType >::data, ug::MapSparseMatrix< TValueType >::end_row(), and ug::find().
|
inline |
check for isolated condition of an index
| i |
References begin_row(), end_row(), num_rows(), and UG_ASSERT.
|
inline |
calculates dest += alpha * A[row, .] v;
References begin_row(), end_row(), and ug::MatMultAdd().
|
inline |
calculate res -= A x
References ug::MapSparseMatrix< TValueType >::axpy().
|
inline |
returns the number of cols
References ug::MapSparseMatrix< TValueType >::cols.
Referenced by ug::MapSparseMatrix< TValueType >::set_as_copy_of().
|
inline |
returns number of connections of row row.
References ug::MapSparseMatrix< TValueType >::data.
Referenced by ug::MapSparseMatrix< TValueType >::total_num_connections().
|
inline |
returns number of rows
References ug::MapSparseMatrix< TValueType >::data.
Referenced by ug::MapSparseMatrix< TValueType >::set_as_copy_of().
|
inline |
operator() (size_t r, size_t c) const access or create connection (r, c)
| r | row |
| c | column |
References ug::MapSparseMatrix< TValueType >::data.
|
inline |
operator() (size_t r, size_t c) const access connection (r, c)
| r | row |
| c | column |
References ug::MapSparseMatrix< TValueType >::data.
|
inline |
References ug::MapSparseMatrix< TValueType >::scale().
|
inline |
|
inline |
References ug::MapSparseMatrix< TValueType >::print().
|
inline |
References ug::MapSparseMatrix< TValueType >::printrow().
| void ug::MapSparseMatrix< T >::print | ( | const char *const | text = NULL | ) | const |
print to console whole SparseMatrix
References num_cols(), num_rows(), and UG_LOG.
Referenced by ug::MapSparseMatrix< TValueType >::p().
| void ug::MapSparseMatrix< TValueType >::print_to_file | ( | const char * | filename | ) | const |
| void ug::MapSparseMatrix< T >::printrow | ( | size_t | row | ) | const |
print the row row to the console
References begin_row(), end_row(), and UG_LOG.
Referenced by ug::MapSparseMatrix< TValueType >::pr().
| void ug::MapSparseMatrix< T >::printtype | ( | ) | const |
| bool ug::MapSparseMatrix< T >::resize | ( | size_t | newRows, |
| size_t | newCols | ||
| ) |
resizes the SparseMatrix
| newRows | new nr of rows |
| newCols | new nr of cols |
References PROFILE_BEGIN_GROUP.
| bool ug::MapSparseMatrix< T >::scale | ( | double | d | ) |
References begin_row(), end_row(), num_rows(), and PROFILE_BEGIN_GROUP.
Referenced by ug::MapSparseMatrix< TValueType >::operator*=().
| void ug::MapSparseMatrix< TValueType >::set | ( | const M & | mat | ) |
set local matrix
| bool ug::MapSparseMatrix< T >::set | ( | double | a | ) |
set matrix to Id*a
References begin_row(), end_row(), num_rows(), and PROFILE_BEGIN_GROUP.
| bool ug::MapSparseMatrix< T >::set_as_copy_of | ( | const MapSparseMatrix< value_type > & | B, |
| double | scale = 1.0 |
||
| ) |
create/recreate this as a copy of SparseMatrix B
| B | the matrix of which to create a copy of |
| scale | an optional scaling |
References ug::MapSparseMatrix< TValueType >::begin_row(), ug::MapSparseMatrix< TValueType >::end_row(), ug::MapSparseMatrix< TValueType >::num_cols(), ug::MapSparseMatrix< TValueType >::num_rows(), PROFILE_BEGIN_GROUP, and resize().
Referenced by ug::MapSparseMatrix< TValueType >::operator=().
| bool ug::MapSparseMatrix< T >::set_as_transpose_of | ( | const SparseMatrix< value_type > & | B, |
| double | scale = 1.0 |
||
| ) |
write in a empty SparseMatrix (this) the transpose SparseMatrix of B.
| B | the matrix of which to create the transpose of |
| scale | an optional scaling |
References ug::SparseMatrix< TValueType >::begin_row(), ug::SparseMatrix< TValueType >::end_row(), ug::SparseMatrix< TValueType >::num_cols(), ug::SparseMatrix< TValueType >::num_rows(), PROFILE_BEGIN_GROUP, and resize().
| void ug::MapSparseMatrix< T >::set_matrix_row | ( | size_t | row, |
| connection * | c, | ||
| size_t | nr | ||
| ) |
set a row of the matrix. all previous content in this row is destroyed (
| row | index of the row to set |
| c | pointer to a array of sorted connections of size nr |
| nr | number of connections in c |
References ug::MapSparseMatrix< TValueType >::connection::iIndex, and PROFILE_BEGIN_GROUP.
|
inline |
returns the total number of connections
References ug::MapSparseMatrix< TValueType >::data, and ug::MapSparseMatrix< TValueType >::num_connections().
|
friend |
|
protected |
Referenced by ug::MapSparseMatrix< TValueType >::num_cols().
|
protected |
Referenced by ug::MapSparseMatrix< TValueType >::begin_row(), ug::MapSparseMatrix< TValueType >::begin_row(), ug::MapSparseMatrix< TValueType >::end_row(), ug::MapSparseMatrix< TValueType >::end_row(), ug::MapSparseMatrix< TValueType >::get_connection(), ug::MapSparseMatrix< TValueType >::get_connection(), ug::MapSparseMatrix< TValueType >::get_connection(), ug::MapSparseMatrix< TValueType >::get_connection(), ug::MapSparseMatrix< TValueType >::num_connections(), ug::MapSparseMatrix< TValueType >::num_rows(), ug::MapSparseMatrix< TValueType >::operator()(), ug::MapSparseMatrix< TValueType >::operator()(), and ug::MapSparseMatrix< TValueType >::total_num_connections().