33 #ifndef __H__UG__CPU_ALGEBRA__SPARSEMATRIX_UTIL__
34 #define __H__UG__CPU_ALGEBRA__SPARSEMATRIX_UTIL__
38 #include "../small_algebra/small_algebra.h"
77 template<
typename ABC_type,
typename A_type,
typename B_type,
typename C_type>
81 UG_ASSERT(C.num_rows() == B.num_cols() && B.num_rows() == A.num_cols(),
"sizes must match");
84 M.resize_and_clear(A.num_rows(), C.num_cols());
90 typedef typename RowType::iterator RowIterator;
91 RowType row(C.num_cols());;
93 std::vector<typename ABC_type::connection> con2;
96 typename ABC_type::connection c;
98 typedef typename A_type::const_row_iterator cAiterator;
99 typedef typename B_type::const_row_iterator cBiterator;
100 typedef typename C_type::const_row_iterator cCiterator;
104 for(
size_t i=0; i < A.num_rows(); i++)
107 cAiterator itAikEnd = A.end_row(i);
108 for(cAiterator itAik = A.begin_row(i); itAik != itAikEnd; ++itAik)
110 if(itAik.value() == 0.0)
continue;
112 size_t k = itAik.index();
113 cBiterator itBklEnd = B.end_row(k);
114 for(cBiterator itBkl = B.begin_row(k); itBkl != itBklEnd; ++itBkl)
116 if(itBkl.value() == 0.0)
continue;
117 size_t l = itBkl.index();
121 cCiterator itCljEnd = C.end_row(l);
122 for(cCiterator itClj = C.begin_row(l); itClj != itCljEnd; ++itClj)
124 if(itClj.value() == 0.0)
continue;
125 AddMult( row (itClj.index() ),
ab, itClj.value());
130 if(epsilonTruncation != 0.0)
133 for(RowIterator it = row.begin(); it != row.end(); ++it)
138 m *= epsilonTruncation;
140 for(RowIterator it = row.begin(); it != row.end(); ++it)
143 M.set_matrix_row(i, &con2[0], con2.size());
146 M.set_matrix_row(i, row.unsorted_raw_ptr(), row.num_connections());
166 template<
typename ABC_type,
typename A_type,
typename B_type,
typename C_type>
170 UG_ASSERT(C.num_rows() == B.num_cols(),
"sizes must match: nRows(C) =" << C.num_rows()<<
"!="<< B.num_cols() <<
"=Cols(B)");
171 UG_ASSERT(B.num_rows() == A.num_cols(),
"sizes must match: nRows(B) =" << B.num_rows()<<
"!="<< A.num_cols() <<
"=nCols(A)");
174 if(M.num_rows() != A.num_rows())
175 UG_THROW(
"AddMultiplyOf: row sizes mismatch: M.num_rows = "<<
176 M.num_rows()<<
", A.num_rows = "<<A.num_rows());
177 if(M.num_cols() != C.num_cols())
178 UG_THROW(
"AddMultiplyOf: column sizes mismatch: M.num_cols = "<<
179 M.num_cols()<<
", C.num_cols = "<<C.num_cols());
184 typedef typename RowType::iterator RowIterator;
185 RowType row(C.num_cols());;
187 std::vector<typename ABC_type::connection> con2;
190 typename ABC_type::connection c;
192 typedef typename A_type::const_row_iterator cAiterator;
193 typedef typename B_type::const_row_iterator cBiterator;
194 typedef typename C_type::const_row_iterator cCiterator;
198 for(
size_t i=0; i < A.num_rows(); i++)
201 cAiterator itAikEnd = A.end_row(i);
202 for(cAiterator itAik = A.begin_row(i); itAik != itAikEnd; ++itAik)
204 if(itAik.value() == 0.0)
continue;
206 size_t k = itAik.index();
207 cBiterator itBklEnd = B.end_row(k);
208 for(cBiterator itBkl = B.begin_row(k); itBkl != itBklEnd; ++itBkl)
210 if(itBkl.value() == 0.0)
continue;
211 size_t l = itBkl.index();
215 cCiterator itCljEnd = C.end_row(l);
216 for(cCiterator itClj = C.begin_row(l); itClj != itCljEnd; ++itClj)
218 if(itClj.value() == 0.0)
continue;
219 AddMult( row (itClj.index() ),
ab, itClj.value());
224 if(epsilonTruncation != 0.0)
227 for(RowIterator it = row.begin(); it != row.end(); ++it)
232 m *= epsilonTruncation;
234 for(RowIterator it = row.begin(); it != row.end(); ++it)
237 M.add_matrix_row(i, &con2[0], con2.size());
240 M.add_matrix_row(i, row.unsorted_raw_ptr(), row.num_connections());
257 template<
typename AB_type,
typename A_type,
typename B_type>
261 UG_ASSERT(B.num_rows() == A.num_cols(),
"sizes must match");
264 M.resize_and_clear(A.num_rows(), B.num_cols());
267 typedef typename A_type::const_row_iterator cAiterator;
268 typedef typename B_type::const_row_iterator cBiterator;
271 RowType row(B.num_cols());
274 for(
size_t i=0; i < A.num_rows(); i++)
277 cAiterator itAikEnd = A.end_row(i);
278 for(cAiterator itAik = A.begin_row(i); itAik != itAikEnd; ++itAik)
280 if(itAik.value() == 0.0)
continue;
281 size_t k = itAik.index();
283 cBiterator itBklEnd = B.end_row(k);
284 for(cBiterator itBkj = B.begin_row(k); itBkj != itBklEnd; ++itBkj)
286 if(itBkj.value() == 0.0)
continue;
287 size_t j = itBkj.index();
288 AddMult( row(j), itAik.value(), itBkj.value());
292 M.set_matrix_row(i, row.unsorted_raw_ptr(), row.num_connections());
308 template<
typename matrix_type>
312 UG_ASSERT(A.num_rows() == B.num_rows() && A.num_cols() == B.num_cols(),
"sizes must match");
313 typedef typename matrix_type::const_row_iterator criterator;
317 M.resize_and_clear(A.num_rows(), A.num_cols());
320 std::vector<typename matrix_type::connection > con; con.reserve(10);
322 typename matrix_type::connection c;
323 for(
size_t i=0; i < A.num_rows(); i++)
326 criterator itA = A.begin_row(i), endA = A.end_row(i);
327 criterator itB = B.begin_row(i), endB = B.end_row(i);
329 while(itA != endA && itB != endB)
331 if(itA.index() == itB.index())
333 c.dValue = alpha1 * itA.value() + alpha2 * itB.value();
334 c.iIndex = itA.index();
337 else if (itA.index() < itB.index())
339 c.dValue = itA.value();
341 c.iIndex = itA.index();
346 c.dValue = itB.value();
348 c.iIndex = itB.index();
355 c.dValue = itA.value();
357 c.iIndex = itA.index();
363 c.dValue = itB.value();
365 c.iIndex = itB.index();
370 M.set_matrix_row(i, &con[0], con.size());
382 template<
typename matrix_type>
386 UG_ASSERT(A.num_rows() == B.num_rows() && A.num_cols() == B.num_cols(),
"sizes must match");
387 typedef typename matrix_type::const_row_iterator criterator;
391 M.resize_and_clear(A.num_rows(), A.num_cols());
394 std::vector<typename matrix_type::connection > con; con.reserve(10);
396 typename matrix_type::connection c;
397 for(
size_t i=0; i < A.num_rows(); i++)
401 criterator itA = A.begin_row(i), endA = A.end_row(i);
402 criterator itB = B.begin_row(i), endB = B.end_row(i);
419 while(itA != endA && itB != endB)
425 if(itA.index() == itB.index())
427 c.dValue = alpha1 * itA.value() + alpha2 * Bij;
428 c.iIndex = itA.index();
431 else if (itA.index() < itB.index())
433 c.dValue = itA.value();
435 c.iIndex = itA.index();
442 c.iIndex = itB.index();
449 c.dValue = itA.value();
451 c.iIndex = itA.index();
461 c.iIndex = itB.index();
466 M.set_matrix_row(i, &con[0], con.size());
471 template<
typename TSparseMatrix>
472 void GetNeighborhood_worker(
const TSparseMatrix &A,
size_t node,
size_t depth, std::vector<size_t> &indices, std::vector<bool> &bVisited)
475 size_t iSizeBefore = indices.size();
476 typename TSparseMatrix::const_row_iterator itEnd = A.end_row(node);
477 for(
typename TSparseMatrix::const_row_iterator it = A.begin_row(node); it != itEnd; ++it)
479 if(it.value() == 0)
continue;
480 if(bVisited[it.index()] ==
false)
483 bVisited[it.index()] =
true;
484 indices.push_back(it.index());
489 size_t iSizeAfter = indices.size();
490 for(
size_t i=iSizeBefore; i<iSizeAfter; i++)
494 template<
typename TSparseMatrix>
495 void GetNeighborhood(
const TSparseMatrix &A,
size_t node,
size_t depth, std::vector<size_t> &indices, std::vector<bool> &bVisited,
bool bResetVisitedFlags=
true)
500 if(bVisited[node] ==
false)
502 bVisited[node] =
true;
503 indices.push_back(node);
507 if(bResetVisitedFlags)
508 for(
size_t i=0; i<indices.size(); i++)
509 bVisited[indices[i]] =
false;
512 template<
typename TSparseMatrix>
513 void GetNeighborhood(
const TSparseMatrix &A,
size_t node,
size_t depth, std::vector<size_t> &indices)
516 std::vector<bool> bVisited(max(A.num_cols(), A.num_rows()),
false);
521 template<
typename TSparseMatrix>
522 void MarkNeighbors(
const TSparseMatrix &A,
size_t node,
size_t depth, std::vector<bool> &bVisited)
524 typename TSparseMatrix::const_row_iterator itEnd = A.end_row(node);
525 for(
typename TSparseMatrix::const_row_iterator it = A.begin_row(node); it != itEnd; ++it)
527 if(it.value() == 0)
continue;
528 bVisited[it.index()] =
true;
533 template<
typename TSparseMatrix>
534 void GetNeighborhoodHierachy_worker(
const TSparseMatrix &A,
size_t node,
size_t depth,
size_t maxdepth, std::vector< std::vector<size_t> > &indices, std::vector<bool> &bVisited)
536 size_t iSizeBefore = indices[depth].size();
537 typename TSparseMatrix::const_row_iterator itEnd = A.end_row(node);
538 for(
typename TSparseMatrix::const_row_iterator it = A.begin_row(node); it != itEnd; ++it)
540 if(it.value() == 0)
continue;
541 if(bVisited[it.index()] ==
false)
543 bVisited[it.index()] =
true;
544 indices[depth].push_back(it.index());
548 if(depth==maxdepth)
return;
549 size_t iSizeAfter = indices[depth].size();
550 for(
size_t i=iSizeBefore; i<iSizeAfter; i++)
554 template<
typename TSparseMatrix>
555 void GetNeighborhoodHierachy(
const TSparseMatrix &A,
size_t node,
size_t depth, std::vector< std::vector<size_t> > &indices, std::vector<bool> &bVisited,
556 bool bResetVisitedFlags=
true)
559 if(indices.size() != depth+1)
560 indices.resize(depth+1);
561 for(
size_t i=0; i < depth+1; i++)
564 bVisited[node] =
true;
565 indices[0].push_back(node);
569 for(
size_t d = 0; d < depth; d++)
571 for(
size_t i=0; i<indices[d].size(); i++)
573 size_t k = indices[d][i];
574 typename TSparseMatrix::const_row_iterator itEnd = A.end_row(k);
575 for(
typename TSparseMatrix::const_row_iterator it = A.begin_row(k); it != itEnd; ++it)
577 if(it.value() == 0)
continue;
578 if(bVisited[it.index()] ==
false)
580 bVisited[it.index()] =
true;
581 indices[d+1].push_back(it.index());
588 if(bResetVisitedFlags)
589 for(
size_t i=0; i < depth+1; i++)
590 for(
size_t j=0; i<indices[j].size(); j++)
595 template<
typename TSparseMatrix>
598 std::vector<bool> bVisited(std::max(A.num_cols(), A.num_rows()),
false);
624 vector<typename SparseMatrix<T>::const_row_iterator> iterators;
625 iterators.reserve(depth);
627 iterators.push_back( A.
begin_row(node) );
629 while(iterators.size() != 0)
631 if(iterators.back().isEnd())
632 iterators.pop_back();
635 size_t index = iterators.back().index();
637 if(iterators.size() < depth)
638 iterators.push_back( A.
begin_row(index) );
642 if(posInConnections == NULL)
644 for(pos=0; pos<indices.size(); pos++)
645 if(indices[pos] == index)
647 if(pos == indices.size())
648 indices.push_back(index);
652 pos = posInConnections[index];
655 pos = posInConnections[index] = indices.size();
656 indices.push_back(index);
667 for(
size_t i=0; i<indices.size(); i++)
668 posInConnections[indices[i]] = -1;
672 sort(indices.begin(), indices.end());
688 template<
typename TSparseMatrix>
691 typedef typename TSparseMatrix::const_row_iterator iterator;
692 if(distance == 0)
return A.is_isolated(node);
694 iterator itEnd = A.end_row(node);
695 for(iterator itA = A.begin_row(node); itA != itEnd && !bFound; ++itA)
709 template <
typename TSparseMatrix>
712 typedef typename TSparseMatrix::row_iterator iterator;
714 iterator itEnd = A.end_row(i);
715 for(iterator conn = A.begin_row(i); conn != itEnd; ++conn)
719 for(
size_t beta = 0; beta < (size_t)
GetCols(block); ++beta)
734 template <
typename TSparseMatrix>
738 for(
size_t row = 0; row != A.num_rows(); ++row)
742 for(
size_t beta = 0; beta < (size_t)
GetRows(block); ++beta)
758 template <
typename TSparseMatrix>
761 typedef typename TSparseMatrix::row_iterator iterator;
762 iterator itEnd = A.end_row(i);
763 for(iterator conn = A.begin_row(i); conn != itEnd; ++conn)
776 template <
typename TSparseMatrix>
779 typedef typename TSparseMatrix::row_iterator iterator;
780 iterator itEnd = A.end_row(i);
781 for(iterator conn = A.begin_row(i); conn != itEnd; ++conn)
795 template <
typename TSparseMatrix>
798 typedef typename TSparseMatrix::row_iterator iterator;
802 iterator itEnd = A.end_row(i);
803 for(iterator conn = A.begin_row(i); conn != itEnd; ++conn)
807 for(
size_t beta = 0; beta < (size_t)
GetCols(block); ++beta)
816 template <
typename TSparseMatrix>
819 typedef typename TSparseMatrix::const_row_iterator iterator;
827 iterator itEnd = A.end_row(i);
828 for(iterator conn = A.begin_row(i); conn != itEnd; ++conn)
832 for(
size_t beta = 0; beta < (size_t)
GetCols(block); ++beta)
849 template <
typename TSparseMatrix>
852 typedef typename TSparseMatrix::row_iterator iterator;
854 iterator itEnd = A.end_row(i);
855 for(iterator conn = A.begin_row(i); conn != itEnd; ++conn)
871 template <
typename TSparseMatrix>
874 typedef typename TSparseMatrix::row_iterator iterator;
876 std::vector<size_t>::const_iterator iter = vIndex.begin();
877 std::vector<size_t>::const_iterator iterEnd = vIndex.end();
879 for(; iter < iterEnd; ++iter)
881 const size_t i = *iter;
882 UG_ASSERT(i < A.num_rows(),
"Index to large in index set.");
884 iterator itEnd = A.end_row(i);
885 for(iterator conn = A.begin_row(i); conn != itEnd; ++conn)
894 template<
typename TSparseMatrix,
class TOStream>
897 typedef typename TSparseMatrix::const_row_iterator iterator;
901 for(
size_t i=0; i < A.num_rows(); i++)
908 iterator itEnd = A.end_row(i);
909 for(iterator conn = A.begin_row(i); conn != itEnd; ++conn)
918 template <
typename TSparseMatrix,
class TIStream>
925 A.resize_and_clear(numRows, numCols);
927 std::vector<typename TSparseMatrix::connection> con; con.reserve(16);
929 for(
size_t i=0; i < A.num_rows; i++)
945 template<
typename TSparseMatrix>
948 typedef typename TSparseMatrix::row_iterator iterator;
949 for(
size_t r=0; r < A.num_rows(); r++)
951 iterator itEnd = A.end_row(r);
952 for(iterator it = A.begin_row(r); it != itEnd; ++it)
958 template<
typename TSparseMatrix,
typename vector_t>
960 const number &alpha1,
const vector_t &v1,
961 const number &beta1,
const vector_t &w1)
963 typedef typename TSparseMatrix::const_row_iterator iterator;
969 for(
size_t i=0; i < A.num_rows(); i++)
971 iterator conn = A.begin_row(i);
972 iterator itEnd = A.end_row(i);
973 if(conn == itEnd)
continue;
974 MatMult(dest[i], beta1, conn.value(), w1[conn.index()]);
975 for(++conn; conn != itEnd; ++conn)
977 MatMultAdd(dest[i], 1.0, dest[i], beta1, conn.value(), w1[conn.index()]);
980 else if(&dest == &v1)
983 for(
size_t i=0; i < A.num_rows(); i++)
986 A.mat_mult_add_row(i, dest[i], beta1, w1);
989 for(
size_t i=0; i < A.num_rows(); i++)
990 A.mat_mult_add_row(i, dest[i], beta1, w1);
995 for(
size_t i=0; i < A.num_rows(); i++)
998 A.mat_mult_add_row(i, dest[i], beta1, w1);
1006 template<
typename TSparseMatrix,
typename vector_t>
1008 const number &alpha1,
const vector_t &v1,
1009 const number &beta1,
const vector_t &w1)
1011 typedef typename TSparseMatrix::const_row_iterator iterator;
1018 else if(alpha1 != 1.0)
1021 else if(alpha1 == 0.0)
1026 for(
size_t i=0; i<A.num_rows(); i++)
1028 iterator itEnd = A.end_row(i);
1029 for(iterator conn = A.begin_row(i); conn != itEnd; ++conn)
1031 if(conn.value() != 0.0)
1041 template<
typename TSparseMatrix>
1044 typedef typename TSparseMatrix::const_row_iterator iterator;
1046 for(
size_t i=0; i<A.num_rows(); i++)
1048 iterator itEnd = A.end_row(i);
1049 for(iterator it = A.begin_row(i); it != itEnd; ++it)
1050 if(it.value() != 0.0) m++;
1056 template<
typename TSparseMatrix>
1059 typedef typename TSparseMatrix::const_row_iterator iterator;
1061 for(
size_t i=0; i<A.num_rows(); i++)
1066 iterator itEnd = A.end_row(i);
1067 for(iterator it = A.begin_row(i); it != itEnd; ++it)
1068 if(it.value() != 0.0) n++;
1076 template<
typename TSparseMatrix>
1082 for(
size_t i=0; i<A.num_rows(); i++)
1084 if (A.nrOfRowIterators[i] !=0)
UG_LOG (
"CheckRowIterators: Failed for row " << i << std::endl);
1085 iIter += A.nrOfRowIterators[i];
1093 template<
typename TSparseMatrix>
1100 for(
size_t i=0; i<A.num_rows(); i++)
1105 UG_LOG(
"WARNING: entry " << i <<
" = " << A(i,i) <<
" not invertible\n");
1115 template<
typename TVector>
1123 for(
size_t i=0; i<v.size(); i++)
1128 UG_LOG(
"WARNING: entry " << i <<
" = " << v[i] <<
" not invertible\n");
1139 template<
typename TSparseMatrix>
1145 template<
typename TVector>
1153 template<
typename TSparseMatrix>
1159 template<
typename TSparseMatrix>
1164 typedef typename TSparseMatrix::const_row_iterator sparse_row_iterator;
1165 size_t numRows = S.num_rows();
1166 size_t numCols = S.num_cols();
1168 A.resize(numRows, numCols);
1169 for(
size_t r=0; r<numRows; r++)
1170 for(
size_t c=0; c<numCols; c++)
1172 for(
size_t r=0; r<numRows; r++)
1175 sparse_row_iterator itEnd = S.end_row(r);
1176 for(sparse_row_iterator it = S.begin_row(r); it != itEnd; ++it)
1177 A(r, it.index()) = it.value();
1183 template<
typename TSparseMatrix>
1188 return S.num_rows() * nrOfRows;
1191 template<
typename TDoubleType,
typename TSparseMatrix>
1195 for(
size_t r=0; r<S.num_rows(); r++)
1196 for(
typename TSparseMatrix::const_row_iterator it = S.begin_row(r); it != S.end_row(r); ++it)
1198 size_t rr = r*nrOfRows;
1199 size_t cc = it.index()*nrOfRows;
1200 for(
size_t r2=0; r2<nrOfRows; r2++)
1201 for(
size_t c2=0; c2<nrOfRows; c2++)
1202 A(rr + r2, cc + c2) =
BlockRef(it.value(), r2, c2);
1206 template<
typename TDenseType,
typename TSparseMatrix>
1216 template<
typename TDoubleSparse,
typename TSparseMatrix>
1221 A.resize_and_clear(N, N);
Definition: sparsematrix_interface.h:37
const_row_iterator begin_row(size_t row) const
Definition: densematrix.h:57
Wrapper for sequential matrices to handle them in parallel.
Definition: parallel_matrix.h:65
ConstSmartPtr< AlgebraLayouts > layouts() const
returns the algebra layouts
Definition: parallel_matrix.h:94
Definition: parallel_vector.h:60
ConstSmartPtr< AlgebraLayouts > layouts() const
returns the algebra layouts
Definition: parallel_vector.h:97
Definition: unsorted_sparse_vector.h:60
void ScaleRow(TSparseMatrix &A, size_t i, number fac)
Definition: sparsematrix_util.h:777
void GetDoubleFromSparseBlock(TDoubleType &A, const TSparseMatrix &S)
Definition: sparsematrix_util.h:1192
size_t GetDoubleSize(const TSparseMatrix &S)
Definition: sparsematrix_util.h:1184
void AddMultiplyOf(ABC_type &M, const A_type &A, const B_type &B, const C_type &C, double epsilonTruncation=0.0)
Calculates M += A*B*C.
Definition: sparsematrix_util.h:167
DenseMatrixFromSparseMatrix< TSparseMatrix >::type & GetDenseFromSparse(typename DenseMatrixFromSparseMatrix< TSparseMatrix >::type &A, const TSparseMatrix &S)
Definition: sparsematrix_util.h:1161
bool CheckDiagonalInvertible(const TSparseMatrix &A)
Definition: sparsematrix_util.h:1094
bool CheckVectorInvertible(const TVector &v)
Definition: sparsematrix_util.h:1116
bool CheckRowIterators(const TSparseMatrix &A)
Definition: sparsematrix_util.h:1077
void GetNeighborhood(const TSparseMatrix &A, size_t node, size_t depth, std::vector< size_t > &indices, std::vector< bool > &bVisited, bool bResetVisitedFlags=true)
Definition: sparsematrix_util.h:495
size_t GetDoubleSparseFromBlockSparse(TDoubleSparse &A, const TSparseMatrix &S)
Definition: sparsematrix_util.h:1217
bool AxpyCommonSparseMatrix(const TSparseMatrix &A, vector_t &dest, const number &alpha1, const vector_t &v1, const number &beta1, const vector_t &w1)
Definition: sparsematrix_util.h:959
void GetNeighborhood_worker(const TSparseMatrix &A, size_t node, size_t depth, std::vector< size_t > &indices, std::vector< bool > &bVisited)
Definition: sparsematrix_util.h:472
void MarkNeighbors(const TSparseMatrix &A, size_t node, size_t depth, std::vector< bool > &bVisited)
Definition: sparsematrix_util.h:522
size_t GetNNZs(const TSparseMatrix &A)
returns the number of non-zeroes (!= number of connections)
Definition: sparsematrix_util.h:1042
bool IsDirichletRow(const TSparseMatrix &A, size_t i, size_t alpha)
Evaluates 'true', iff corresponding row is Dirichlet.
Definition: sparsematrix_util.h:817
void CreateAsMultiplyOf(ABC_type &M, const A_type &A, const B_type &B, const C_type &C, double epsilonTruncation=0.0)
Calculates M = A*B*C.
Definition: sparsematrix_util.h:78
size_t GetDenseDoubleFromSparse(TDenseType &A, const TSparseMatrix &S)
Definition: sparsematrix_util.h:1207
bool Axpy_transposedCommonSparseMatrix(const TSparseMatrix &A, vector_t &dest, const number &alpha1, const vector_t &v1, const number &beta1, const vector_t &w1)
Definition: sparsematrix_util.h:1007
void SetDirichletRow(TSparseMatrix &A, size_t i, size_t alpha)
Definition: sparsematrix_util.h:796
bool IsCloseToBoundary(const TSparseMatrix &A, size_t node, size_t distance)
gets the neighborhood of a node in the connectivity graph of a SparseMatrix.
Definition: sparsematrix_util.h:689
void GetNeighborhoodHierachy_worker(const TSparseMatrix &A, size_t node, size_t depth, size_t maxdepth, std::vector< std::vector< size_t > > &indices, std::vector< bool > &bVisited)
Definition: sparsematrix_util.h:534
void SetRow(TSparseMatrix &A, size_t i, size_t alpha, number val=0.0)
Definition: sparsematrix_util.h:710
void SetCol(TSparseMatrix &A, size_t i, size_t alpha, number val=0.0)
Definition: sparsematrix_util.h:735
void MatAddNonDirichlet(matrix_type &M, number alpha1, const matrix_type &A, number alpha2, const matrix_type &B)
Calculates M = A + B.
Definition: sparsematrix_util.h:383
void GetNeighborhoodHierachy(const TSparseMatrix &A, size_t node, size_t depth, std::vector< std::vector< size_t > > &indices, std::vector< bool > &bVisited, bool bResetVisitedFlags=true)
Definition: sparsematrix_util.h:555
void DeserializeMatrix(TIStream &buf, TSparseMatrix &A)
Definition: sparsematrix_util.h:919
size_t GetMaxConnections(const TSparseMatrix &A)
returns max number of non-zero connections in rows
Definition: sparsematrix_util.h:1057
void ScaleSparseMatrixCommon(TSparseMatrix &A, double d)
Definition: sparsematrix_util.h:946
void SerializeMatrix(TOStream &buf, const TSparseMatrix &A)
Definition: sparsematrix_util.h:895
void MatAdd(matrix_t &mOut, const matrix_t &m1, const matrix_t &m2)
adds two matrices and stores the result in a third one
Definition: math_matrix_functions_common_impl.hpp:52
bool AllProcsTrue(bool bFlag, ProcessCommunicator comm)
Definition: pcl_util.cpp:54
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_THROW(msg)
Definition: error.h:57
#define UG_LOG(msg)
Definition: log.h:367
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition: error.h:61
double number
Definition: types.h:124
CPUAlgebra::matrix_type matrix_type
size_t GetCols(const T &t)
bool GetInverse(block_traits< T >::inverse_type &inv, const T &m)
void AssignMult(A &dest, const B &b, const C &vec)
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
double & BlockRef(T &vec, size_t i)
Definition: blocks.h:66
void Deserialize(TIStream &buf, ParallelVector< T > &v)
Deerialize for ParallelVector<T>
Definition: restart_bridge.cpp:112
void Serialize(TOStream &buf, const ParallelVector< T > &v)
Serialize for ParallelVector<T>
Definition: restart_bridge.cpp:103
size_t GetRows(const T &t)
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 AddMult(A &dest, const B &b, const C &vec)
double BlockNorm(const TYPE &v)
Definition: blocks.h:57
void VecScaleAssign(double &dest, double alpha1, const double &v1)
calculates dest = alpha1*v1. for doubles
Definition: operations_vec.h:49
#define PROFILE_FUNC_GROUP(groups)
Definition: profiler.h:258
class SparseMatrix B_type
T value_type
Definition: sparsematrix_interface.h:2
size_t num_connections(size_t row) const
class SparseMatrix ABC_type
Calculates M = A*B*C.
class SparseMatrix A_type
Definition: sparsematrix_util.h:1155
DenseMatrix< VariableArray2< typename TSparseMatrix::value_type > > type
Definition: sparsematrix_util.h:1156
Definition: file_io_grdecl.cpp:60
Definition: smallalgebra_interface.h:42
Definition: communication_policies.h:58