33 #ifndef __H__UG__MAP_ALGEBRA__SPARSEMATRIX_IMPL__
34 #define __H__UG__MAP_ALGEBRA__SPARSEMATRIX_IMPL__
79 template<
typename vector_t>
89 template<
typename vector_t>
91 const number &alpha1,
const vector_t &v1,
92 const number &beta1,
const vector_t &w1)
const
100 if(conn ==
end_row(i))
continue;
102 for(++conn; conn !=
end_row(i); ++conn)
107 else if(&dest == &v1)
110 for(
size_t i=0; i <
num_rows(); i++)
113 mat_mult_add_row(i, dest[i], beta1, w1);
117 for(
size_t i=0; i <
num_rows(); i++)
118 mat_mult_add_row(i, dest[i], beta1, w1);
123 for(
size_t i=0; i <
num_rows(); i++)
126 mat_mult_add_row(i, dest[i], beta1, w1);
134 template<
typename vector_t>
136 const number &alpha1,
const vector_t &v1,
137 const number &beta1,
const vector_t &w1)
const
144 else if(alpha1 != 1.0)
147 else if(alpha1 == 0.0)
156 if(conn.value() != 0.0)
169 for(
size_t row=0; row<
num_rows(); row++)
172 if(it.index() == row)
187 if(it.index() != i && it.value() != 0.0)
197 for(
size_t i=0; i<nr; i++)
198 operator()(row, c[i].
iIndex) = c[i].dValue;
205 for(
size_t i=0; i<nr; i++)
206 operator()(row, c[i].
iIndex) += c[i].dValue;
215 for(
size_t i=0; i < B.
num_rows(); i++)
227 for(
size_t i=0; i <
num_rows(); i++)
Definition: mapsparsematrix.h:334
size_t index() const
Definition: mapsparsematrix.h:339
const value_type & value()
Definition: mapsparsematrix.h:338
Definition: mapsparsematrix.h:326
sparse matrix for big, variable sparse matrices.
Definition: mapsparsematrix.h:54
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)
Definition: mapsparsematrix_impl.h:135
bool set_as_copy_of(const MapSparseMatrix< value_type > &B, double scale=1.0)
create/recreate this as a copy of SparseMatrix B
Definition: mapsparsematrix_impl.h:211
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;
Definition: mapsparsematrix_impl.h:80
void set(const M &mat)
set local matrix
bool resize(size_t newRows, size_t newCols)
resizes the SparseMatrix
Definition: mapsparsematrix_impl.h:57
size_t num_cols() const
returns the number of cols
Definition: mapsparsematrix.h:290
size_t num_rows() const
returns number of rows
Definition: mapsparsematrix.h:287
bool is_isolated(size_t i) const
check for isolated condition of an index
Definition: mapsparsematrix_impl.h:182
row_iterator begin_row(size_t r)
Definition: mapsparsematrix.h:343
MapSparseMatrix()
constructor for empty SparseMatrix
Definition: mapsparsematrix_impl.h:52
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)
Definition: mapsparsematrix_impl.h:90
row_iterator end_row(size_t r)
Definition: mapsparsematrix.h:344
void set_matrix_row(size_t row, connection *c, size_t nr)
Definition: mapsparsematrix_impl.h:194
void add_matrix_row(size_t row, connection *c, size_t nr)
Definition: mapsparsematrix_impl.h:202
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.
Definition: mapsparsematrix_impl.h:67
bool scale(double d)
Definition: mapsparsematrix_impl.h:224
sparse matrix for big, variable sparse matrices.
Definition: sparsematrix.h:99
size_t num_rows() const
returns number of rows
Definition: sparsematrix.h:342
row_iterator end_row(size_t r)
Definition: sparsematrix.h:485
size_t num_cols() const
returns the number of cols
Definition: sparsematrix.h:345
row_iterator begin_row(size_t r)
Definition: sparsematrix.h:484
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
double number
Definition: types.h:124
bool MatMultTransposedAdd(vector_t &dest, const number &alpha1, const vector_t &v1, const number &beta1, const matrix_t &A1, const vector_t &w1)
calculates dest = alpha1*v1 + beta1 * A1 *w1;
Definition: operations_mat.h:121
bool MatMultAdd(vector_t &dest, const number &alpha1, const vector_t &v1, const number &beta1, const matrix_t &A1, const vector_t &w1)
calculates dest = alpha1*v1 + beta1 * A1 *w1;
Definition: operations_mat.h:68
bool MatMult(vector_t &dest, const number &beta1, const matrix_t &A1, const vector_t &w1)
calculates dest = beta1 * A1;
Definition: operations_mat.h:59
void VecScaleAssign(double &dest, double alpha1, const double &v1)
calculates dest = alpha1*v1. for doubles
Definition: operations_vec.h:49
#define PROFILE_BEGIN_GROUP(name, groups)
Definition: profiler.h:255
T value_type
Definition: sparsematrix_interface.h:2
bool resize(size_t newRows, size_t newCols)
size_t num_rows() const
Definition: sparsematrix_interface.h:38
const_row_iterator end_row(size_t row) const
value_type & operator()(size_t r, size_t c)
const_row_iterator begin_row(size_t row) const
Definition: mapsparsematrix.h:64
size_t iIndex
Definition: mapsparsematrix.h:65