33 #ifndef SCALAR_MATRIX_ADAPTER_HH_
34 #define SCALAR_MATRIX_ADAPTER_HH_
62 for (
size_t i=0; i<A.num_rows(); ++i)
65 for (matrix_type::row_iterator matij = A.begin_row(i);
66 matij != A.end_row(i); ++matij)
68 size_t j = matij.index();
69 if ((i%ncmp) != (j%ncmp))
79 template<
class AT,
class ST=CPUAlgebra>
85 static const int blockSize = AT::blockSize;
92 { m_src.resize_and_clear(newRows/blockSize, newCols/blockSize);}
95 {
return m_src.resize_and_keep_values(newRows/blockSize, newCols/blockSize);}
102 return BlockRef(m_src(r/blockSize, c/blockSize), r%blockSize, c%blockSize);
109 return BlockRef(m_src(r/blockSize, c/blockSize), r%blockSize, c%blockSize);
114 {
return m_src.num_rows()*blockSize; }
118 {
return m_src.num_cols()*blockSize; }
122 {
return m_src.total_num_connections()*blockSize*blockSize; }
125 void print(
const char *text)
const {m_src.print(text);}
128 void printrow(
size_t row)
const {m_src.printrow(row/blockSize);}
142 typename encapsulated_matrix_type::row_iterator
iter;
144 inline void check()
const {iter.check(); }
151 void operator += (
int nr) { iter+=nr; }
153 size_t index()
const {
return iter.index(); }
159 typename encapsulated_matrix_type::const_row_iterator
iter;
161 inline void check()
const {iter.check(); }
168 void operator += (
int nr) { iter+=nr; }
170 size_t index()
const {
return iter.index(); }
187 {
return os << m_src; }
198 {
return m_src(r,c); };
Definition: scalar_matrix_adapter.hh:158
~const_row_iterator()
Definition: scalar_matrix_adapter.hh:164
void check() const
Definition: scalar_matrix_adapter.hh:161
encapsulated_matrix_type::const_row_iterator iter
Definition: scalar_matrix_adapter.hh:159
const value_type & value() const
Definition: scalar_matrix_adapter.hh:171
const_row_iterator(typename encapsulated_matrix_type::const_row_iterator _iter)
Definition: scalar_matrix_adapter.hh:162
size_t index() const
Definition: scalar_matrix_adapter.hh:170
Definition: scalar_matrix_adapter.hh:141
void check() const
Definition: scalar_matrix_adapter.hh:144
encapsulated_matrix_type::row_iterator iter
Definition: scalar_matrix_adapter.hh:142
~row_iterator()
Definition: scalar_matrix_adapter.hh:147
value_type & value()
Definition: scalar_matrix_adapter.hh:154
row_iterator(typename encapsulated_matrix_type::row_iterator _iter)
Definition: scalar_matrix_adapter.hh:145
size_t index() const
Definition: scalar_matrix_adapter.hh:153
Definition: scalar_matrix_adapter.hh:80
ScalarMatrixAdapter(encapsulated_matrix_type &mat)
Definition: scalar_matrix_adapter.hh:89
void resize_and_clear(size_t newRows, size_t newCols)
Definition: scalar_matrix_adapter.hh:91
bool resize_and_keep_values(size_t newRows, size_t newCols)
Definition: scalar_matrix_adapter.hh:94
const encapsulated_matrix_type & m_const
Definition: scalar_matrix_adapter.hh:190
value_type & operator()(size_t r, size_t c)
Definition: scalar_matrix_adapter.hh:98
size_t total_num_connections() const
returns the total number of connections
Definition: scalar_matrix_adapter.hh:121
AT::matrix_type encapsulated_matrix_type
Definition: scalar_matrix_adapter.hh:83
row_iterator begin_row(size_t r)
Definition: scalar_matrix_adapter.hh:175
encapsulated_matrix_type & m_src
Definition: scalar_matrix_adapter.hh:189
size_t num_rows() const
returns number of rows
Definition: scalar_matrix_adapter.hh:113
ST::matrix_type::value_type value_type
Definition: scalar_matrix_adapter.hh:84
const_row_iterator end_row(size_t r) const
Definition: scalar_matrix_adapter.hh:182
row_iterator end_row(size_t r)
Definition: scalar_matrix_adapter.hh:177
size_t num_cols() const
returns the number of cols
Definition: scalar_matrix_adapter.hh:117
std::ostream & outputToStream(std::ostream &os) const
Definition: scalar_matrix_adapter.hh:186
void printrow(size_t row) const
print (block) row of (underlying) matrix
Definition: scalar_matrix_adapter.hh:128
const_row_iterator begin_row(size_t r) const
Definition: scalar_matrix_adapter.hh:180
void print(const char *text) const
print (underlying) matrix
Definition: scalar_matrix_adapter.hh:125
friend std::ostream & operator<<(std::ostream &os, ScalarMatrixAdapter< AT, ST > const &a)
operator overloading for streams
Definition: scalar_matrix_adapter.hh:131
Wrapper for sequential matrices to handle them in parallel.
Definition: parallel_matrix.h:65
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
bool operator==(const MathVector< N, T > &v, const MathVector< N, T > &w)
Definition: math_vector.h:523
bool operator!=(const MathVector< N, T > &v, const MathVector< N, T > &w)
Definition: math_vector.h:552
double & BlockRef(T &vec, size_t i)
Definition: blocks.h:66
ReferenceObjectID operator++(ReferenceObjectID &roid, int)
Definition: grid_base_objects.h:89
void TruncateOffDiag(MT &A, size_t ncmp)
Definition: scalar_matrix_adapter.hh:53
T value_type
Definition: sparsematrix_interface.h:2
size_t num_rows() const
Definition: sparsematrix_interface.h:38
value_type & operator()(size_t r, size_t c)
size_t num_cols() const
Definition: sparsematrix_interface.h:39