1 #ifndef VIENNACL_LINALG_DETAIL_AMG_AMG_BASE_HPP_
2 #define VIENNACL_LINALG_DETAIL_AMG_AMG_BASE_HPP_
27 #include <boost/numeric/ublas/operation.hpp>
28 #include <boost/numeric/ublas/vector.hpp>
35 #ifdef VIENNACL_WITH_OPENMP
41 #define VIENNACL_AMG_COARSE_RS 1
42 #define VIENNACL_AMG_COARSE_ONEPASS 2
43 #define VIENNACL_AMG_COARSE_RS0 3
44 #define VIENNACL_AMG_COARSE_RS3 4
45 #define VIENNACL_AMG_COARSE_AG 5
46 #define VIENNACL_AMG_INTERPOL_DIRECT 1
47 #define VIENNACL_AMG_INTERPOL_CLASSIC 2
48 #define VIENNACL_AMG_INTERPOL_AG 3
49 #define VIENNACL_AMG_INTERPOL_SA 4
77 unsigned int interpol = 1,
78 double threshold = 0.25,
79 double interpolweight = 0.2,
80 double jacobiweight = 1,
81 unsigned int presmooth = 1,
82 unsigned int postsmooth = 1,
83 unsigned int coarselevels = 0)
84 : coarse_(coarse), interpol_(interpol),
85 threshold_(threshold), interpolweight_(interpolweight), jacobiweight_(jacobiweight),
86 presmooth_(presmooth), postsmooth_(postsmooth), coarselevels_(coarselevels) {}
89 void set_coarse(
unsigned int coarse) {
if (coarse > 0) coarse_ = coarse; }
92 void set_interpol(
unsigned int interpol) {
if (interpol > 0) interpol_ = interpol; }
95 void set_threshold(
double threshold) {
if (threshold > 0 && threshold <= 1) threshold_ = threshold; }
98 void set_as(
double jacobiweight) {
if (jacobiweight > 0 && jacobiweight <= 2) jacobiweight_ = jacobiweight; }
101 void set_interpolweight(
double interpolweight) {
if (interpolweight > 0 && interpolweight <= 2) interpolweight_ = interpolweight; }
104 void set_presmooth(
int presmooth) {
if (presmooth >= 0) presmooth_ = presmooth; }
107 void set_postsmooth(
int postsmooth) {
if (postsmooth >= 0) postsmooth_ = postsmooth; }
110 void set_coarselevels(
int coarselevels) {
if (coarselevels >= 0) coarselevels_ = coarselevels; }
114 unsigned int coarse_, interpol_;
115 double threshold_, interpolweight_, jacobiweight_;
116 unsigned int presmooth_, postsmooth_, coarselevels_;
123 template <
typename InternalType,
typename IteratorType,
typename ScalarType>
146 ScalarType s = 0): m_(m), iter_(iter), i_(i), j_(j), s_(s) {}
155 if (s_ == 0)
return s_;
157 m_->addscalar (iter_,i_,j_,s_);
174 m_->removescalar(iter_,i_);
178 m_->addscalar (iter_,i_,j_,s_);
185 m_->removescalar(iter_,i_);
186 m_->addscalar (iter_,i_,j_,s_);
193 m_->removescalar(iter_,i_);
194 m_->addscalar (iter_,i_,j_,s_);
197 operator ScalarType (
void) {
return s_; }
202 template <
typename InternalType>
207 typedef typename InternalType::mapped_type ScalarType;
209 InternalType & internal_vec;
210 typename InternalType::iterator iter;
221 iter = internal_vec.begin();
223 iter = internal_vec.end();
228 if (iter == other.iter)
235 if (iter != other.iter)
247 unsigned int index()
const {
return (*iter).first; }
248 unsigned int index() {
return (*iter).first; }
253 template <
typename ScalarType>
261 typedef std::map<unsigned int,ScalarType> InternalType;
267 InternalType internal_vector;
279 internal_vector = InternalType();
283 unsigned int size()
const {
return size_;}
286 unsigned int internal_size()
const {
return static_cast<unsigned int>(internal_vector.size()); }
288 void clear() { internal_vector.clear(); }
290 void remove(
unsigned int i) { internal_vector.erase(i); }
293 void add (
unsigned int i, ScalarType s)
295 typename InternalType::iterator iter = internal_vector.find(i);
297 if (iter == internal_vector.end())
306 internal_vector.erase(iter);
311 template <
typename IteratorType>
312 void addscalar(IteratorType & iter,
unsigned int i,
unsigned int , ScalarType s)
319 if (iter != internal_vector.end())
322 internal_vector[i] = s;
326 template <
typename IteratorType>
327 void removescalar(IteratorType & iter,
unsigned int ) { internal_vector.erase(iter); }
332 typename InternalType::iterator it = internal_vector.find(i);
334 if (it != internal_vector.end())
335 return NonzeroScalarType (
this,it,i,i,(*it).second);
337 return NonzeroScalarType (
this,it,i,i,0);
343 const_iterator it = internal_vector.find(i);
345 if (it != internal_vector.end())
353 const_iterator
begin()
const {
return internal_vector.begin(); }
355 const_iterator
end()
const {
return internal_vector.end(); }
358 bool isnonzero(
unsigned int i)
const {
return internal_vector.find(i) != internal_vector.end(); }
361 operator boost::numeric::ublas::vector<ScalarType> (void)
363 boost::numeric::ublas::vector<ScalarType> vec (size_);
364 for (iterator iter =
begin(); iter !=
end(); ++iter)
365 vec [iter.index()] = *iter;
375 template <
typename ScalarType>
381 typedef std::map<unsigned int,ScalarType> RowType;
382 typedef std::vector<RowType> InternalType;
393 InternalType internal_mat;
396 InternalType internal_mat_trans;
401 bool transposed_mode;
414 transposed_mode =
false;
424 AdapterType a (internal_mat, i, j);
426 AdapterType a_trans (internal_mat_trans, j, i);
427 a_trans.
resize (j,i,
false);
432 transposed_mode =
false;
442 AdapterType a (internal_mat, mat.size(), mat.size());
443 AdapterType a_trans (internal_mat_trans, mat.size(), mat.size());
444 a.resize(mat.size(), mat.size());
445 a_trans.resize(mat.size(), mat.size());
448 s1 = s2 = mat.size();
450 transposed_mode =
false;
458 template <
typename MatrixType>
461 AdapterType a (internal_mat, mat.size1(), mat.size2());
462 AdapterType a_trans (internal_mat_trans, mat.size2(), mat.size1());
463 a.resize(mat.size1(), mat.size2());
464 a_trans.resize(mat.size2(), mat.size1());
470 for (
typename MatrixType::const_iterator1 row_iter = mat.begin1(); row_iter != mat.end1(); ++row_iter)
472 for (
typename MatrixType::const_iterator2 col_iter = row_iter.begin(); col_iter != row_iter.end(); ++col_iter)
476 unsigned int x =
static_cast<unsigned int>(col_iter.index1());
477 unsigned int y =
static_cast<unsigned int>(col_iter.index2());
479 a_trans (y,x) = *col_iter;
483 transposed_mode =
false;
491 #ifdef VIENNACL_WITH_OPENMP
499 bool save_mode = transposed_mode;
500 transposed_mode =
false;
502 for (iterator1 row_iter =
begin1(); row_iter !=
end1(); ++row_iter)
503 for (iterator2 col_iter = row_iter.begin(); col_iter != row_iter.end(); ++col_iter)
504 internal_mat_trans[col_iter.index2()][
static_cast<unsigned int>(col_iter.index1())] = *col_iter;
506 transposed_mode = save_mode;
515 transposed_mode = mode;
525 if (!transposed_mode)
527 if (internal_mat[i].find(j) != internal_mat[i].end())
534 if (internal_mat[j].find(i) != internal_mat[j].end())
542 void add (
unsigned int i,
unsigned int j, ScalarType s)
548 typename RowType::iterator col_iter = internal_mat[i].find(j);
550 if (col_iter == internal_mat[i].end())
554 s += (*col_iter).second;
557 (*col_iter).second = s;
559 internal_mat[i].erase(col_iter);
565 template <
typename IteratorType>
566 void addscalar(IteratorType & iter,
unsigned int i,
unsigned int j, ScalarType s)
572 if (iter != internal_mat[i].end())
575 internal_mat[i][j] = s;
581 template <
typename IteratorType>
584 internal_mat[i].erase(iter);
591 typename RowType::iterator iter;
593 if (!transposed_mode)
595 iter = internal_mat[i].find(j);
596 if (iter != internal_mat[i].end())
597 return NonzeroScalarType (
this,iter,i,j,(*iter).second);
599 return NonzeroScalarType (
this,iter,i,j,0);
603 iter = internal_mat[j].find(i);
604 if (iter != internal_mat[j].end())
605 return NonzeroScalarType (
this,iter,j,i,(*iter).second);
607 return NonzeroScalarType (
this,iter,j,i,0);
614 typename RowType::const_iterator iter;
616 if (!transposed_mode)
618 iter = internal_mat[i].find(j);
619 if (iter != internal_mat[i].end())
620 return (*iter).second;
626 iter = internal_mat[j].find(i);
627 if (iter != internal_mat[j].end())
628 return (*iter).second;
634 void resize(
unsigned int i,
unsigned int j,
bool preserve =
true)
636 AdapterType a (internal_mat);
638 AdapterType a_trans (internal_mat_trans);
639 a_trans.
resize(j,i,preserve);
646 AdapterType a (internal_mat, s1, s2);
648 AdapterType a_trans (internal_mat_trans, s2, s1);
655 if (!transposed_mode)
663 if (!transposed_mode)
672 if (!transposed_mode)
680 if (!transposed_mode)
688 if (!
trans && !transposed_mode)
690 AdapterType a (internal_mat, s1, s2);
696 AdapterType a_trans (internal_mat_trans, s2, s1);
703 if (!
trans && !transposed_mode)
705 AdapterType a (internal_mat, s1, s2);
711 AdapterType a_trans (internal_mat_trans, s2, s1);
712 return a_trans.
end1();
718 if (!
trans && !transposed_mode)
720 AdapterType a (internal_mat, s1, s2);
726 AdapterType a_trans (internal_mat_trans, s2, s1);
733 if (!
trans && !transposed_mode)
735 AdapterType a (internal_mat, s1, s2);
741 AdapterType a_trans (internal_mat_trans, s2, s1);
742 return a_trans.
end2();
749 assert((!transposed_mode || (transposed_mode && transposed)) &&
bool(
"Error: Cannot build const_iterator when transposed has not been built yet!"));
750 ConstAdapterType a_const (internal_mat, s1, s2);
756 assert((!transposed_mode || (transposed_mode && transposed)) &&
bool(
"Error: Cannot build const_iterator when transposed has not been built yet!"));
757 ConstAdapterType a_const (internal_mat,
trans ? s2 : s1,
trans ? s1 : s2);
758 return a_const.
end1();
763 assert((!transposed_mode || (transposed_mode && transposed)) &&
bool(
"Error: Cannot build const_iterator when transposed has not been built yet!"));
764 ConstAdapterType a_const (internal_mat,
trans ? s2 : s1,
trans ? s1 : s2);
770 assert((!transposed_mode || (transposed_mode && transposed)) &&
bool(
"Error: Cannot build const_iterator when transposed has not been built yet!"));
771 ConstAdapterType a_const (internal_mat,
trans ? s2 : s1,
trans ? s1 : s2);
772 return a_const.
end2();
778 if (!transposed_mode)
779 return &internal_mat;
783 return &internal_mat_trans;
785 operator boost::numeric::ublas::compressed_matrix<ScalarType> (void)
787 boost::numeric::ublas::compressed_matrix<ScalarType> mat;
791 for (iterator1 row_iter =
begin1(); row_iter !=
end1(); ++row_iter)
792 for (iterator2 col_iter = row_iter.begin(); col_iter != row_iter.end(); ++col_iter)
793 mat (col_iter.index1(), col_iter.index2()) = *col_iter;
797 operator boost::numeric::ublas::matrix<ScalarType> (void)
799 boost::numeric::ublas::matrix<ScalarType> mat;
803 for (iterator1 row_iter =
begin1(); row_iter !=
end1(); ++row_iter)
804 for (iterator2 col_iter = row_iter.begin(); col_iter != row_iter.end(); ++col_iter)
805 mat (col_iter.index1(), col_iter.index2()) = *col_iter;
822 unsigned int influence_;
827 unsigned int coarse_index_;
829 unsigned int offset_;
831 unsigned int aggregate_;
834 ListType influencing_points;
836 ListType influenced_points;
844 amg_point (
unsigned int index,
unsigned int size): index_(index), influence_(0), undecided_(true), cpoint_(false), coarse_index_(0), offset_(0), aggregate_(0)
846 influencing_points = ListType(size);
847 influenced_points = ListType(size);
852 void set_index(
unsigned int index) { index_ = index+offset_; }
853 unsigned int get_index()
const {
return index_-offset_; }
858 bool is_cpoint()
const {
return cpoint_ && !undecided_; }
859 bool is_fpoint()
const {
return !cpoint_ && !undecided_; }
939 typedef std::set<amg_point*,classcomp> ListType;
941 typedef std::vector<amg_point*> VectorType;
942 VectorType pointvector;
945 unsigned int c_points, f_points;
956 pointvector = VectorType(
size);
957 c_points = f_points = 0;
963 for (
unsigned int i=0; i<
size(); ++i)
969 for (
unsigned int i=0; i<
size(); ++i)
970 delete pointvector[i];
993 for (iterator iter = pointvector.begin(); iter != pointvector.end(); ++iter)
995 (*iter)->clear_influencing();
996 (*iter)->clear_influenced();
1001 iterator
begin() {
return pointvector.begin(); }
1002 iterator
end() {
return pointvector.end(); }
1003 const_iterator
begin()
const {
return pointvector.begin(); }
1004 const_iterator
end()
const {
return pointvector.end(); }
1009 pointvector = VectorType(size);
1011 unsigned int size()
const {
return size_; }
1021 for (iterator iter =
begin(); iter !=
end(); ++iter)
1022 pointlist.insert(*iter);
1028 if (pointlist.size() == 0)
1031 if ((*(--pointlist.end()))->get_influence() == 0)
1035 return *(--pointlist.end());
1040 ListType::iterator iter = pointlist.find(point);
1042 if (iter == pointlist.end())
return;
1045 ListType::iterator iter2 = iter;
1049 pointlist.erase(iter);
1053 pointlist.insert(iter2,point);
1058 pointlist.erase(point);
1065 pointlist.erase(point);
1080 unsigned int count = 0;
1082 for (iterator iter = pointvector.begin(); iter != pointvector.end(); ++iter)
1085 if ((*iter)->is_cpoint())
1087 (*iter)->set_coarse_index(count);
1094 template <
typename MatrixType>
1100 for (const_iterator row_iter =
begin(); row_iter !=
end(); ++row_iter)
1101 for (
amg_point::iterator col_iter = (*row_iter)->begin_influencing(); col_iter != (*row_iter)->end_influencing(); ++col_iter)
1102 mat((*row_iter)->get_index(),(*col_iter)->get_index()) =
true;
1104 template <
typename VectorType>
1107 vec = VectorType(size_);
1110 for (const_iterator iter =
begin(); iter !=
end(); ++iter)
1111 vec[(*iter)->get_index()] = (*iter)->get_influence();
1113 template <
typename VectorType>
1116 vec = VectorType(pointlist.size());
1120 for (ListType::const_iterator iter = pointlist.begin(); iter != pointlist.end(); ++iter)
1122 vec[i] = (*iter)->get_index();
1126 template <
typename VectorType>
1129 vec = VectorType(size_);
1132 for (const_iterator iter =
begin(); iter !=
end(); ++iter)
1134 if ((*iter)->is_cpoint())
1135 vec[(*iter)->get_index()] =
true;
1138 template <
typename VectorType>
1141 vec = VectorType(size_);
1144 for (const_iterator iter =
begin(); iter !=
end(); ++iter)
1146 if ((*iter)->is_fpoint())
1147 vec[(*iter)->get_index()] =
true;
1150 template <
typename MatrixType>
1153 mat = MatrixType(size_,size_);
1156 for (const_iterator iter =
begin(); iter !=
end(); ++iter)
1158 if (!(*iter)->is_undecided())
1159 mat((*iter)->get_aggregate(),(*iter)->get_index()) =
true;
1167 template <
typename InternalType1,
typename InternalType2>
1170 typedef typename InternalType1::value_type SparseMatrixType;
1171 typedef typename InternalType2::value_type PointVectorType;
1175 boost::numeric::ublas::vector<InternalType1>
A_slice;
1178 boost::numeric::ublas::vector<boost::numeric::ublas::vector<unsigned int> >
Offset;
1183 void init(
unsigned int levels,
unsigned int threads = 0)
1187 #ifdef VIENNACL_WITH_OPENMP
1188 threads_ = omp_get_num_procs();
1197 A_slice.resize(threads_);
1198 Pointvector_slice.resize(threads_);
1200 Offset.resize(threads_+1);
1202 for (
unsigned int i=0; i<
threads_; ++i)
1204 A_slice[i].resize(levels_);
1205 Pointvector_slice[i].resize(levels_);
1207 Offset[i].resize(levels_+1);
1209 Offset[
threads_].resize(levels_+1);
1213 void slice (
unsigned int level, InternalType1
const & A, InternalType2
const & Pointvector)
1217 slice_new (level, A);
1222 slice_build (level, A, Pointvector);
1226 void join (
unsigned int level, InternalType2 & Pointvector)
const
1228 typedef typename InternalType2::value_type PointVectorType;
1231 Pointvector[level].clear_cf();
1232 for (
typename PointVectorType::iterator iter = Pointvector[level].begin(); iter != Pointvector[level].end(); ++iter)
1234 (*iter)->set_offset(0);
1235 Pointvector[level].update_cf(*iter);
1244 void slice_new (
unsigned int level, InternalType1
const & A)
1247 #ifdef VIENNACL_WITH_OPENMP
1248 #pragma omp parallel for
1250 for (
long i=0; i<=static_cast<long>(
threads_); ++i)
1253 if (i == 0) Offset[i][level] = 0;
1254 else if (i == threads_) Offset[i][level] =
static_cast<unsigned int>(A[level].size1());
1255 else Offset[i][level] =
static_cast<unsigned int>(i*(A[level].size1()/
threads_));
1264 void slice_build (
unsigned int level, InternalType1
const & A, InternalType2
const & Pointvector)
1266 typedef typename SparseMatrixType::const_iterator1 ConstRowIterator;
1267 typedef typename SparseMatrixType::const_iterator2 ConstColIterator;
1272 #ifdef VIENNACL_WITH_OPENMP
1273 #pragma omp parallel for private (x,y,point)
1275 for (
long i=0; i<static_cast<long>(
threads_); ++i)
1278 A_slice[i][level] = SparseMatrixType(Offset[i+1][level]-Offset[i][level],Offset[i+1][level]-Offset[i][level]);
1279 Pointvector_slice[i][level] = PointVectorType(Offset[i+1][level]-Offset[i][level]);
1282 ConstRowIterator row_iter = A[level].begin1();
1283 row_iter += Offset[i][level];
1284 x =
static_cast<unsigned int>(row_iter.index1());
1286 while (x < Offset[i+1][level] && row_iter != A[level].end1())
1289 point = Pointvector[level][x];
1290 point->set_offset(Offset[i][level]);
1291 Pointvector_slice[i][level].add_point(point);
1293 ConstColIterator col_iter = row_iter.begin();
1294 y =
static_cast<unsigned int>(col_iter.index2());
1297 while (y < Offset[i+1][level] && col_iter != row_iter.end())
1299 if (y >= Offset[i][level])
1300 A_slice[i][level](x-Offset[i][level],y-Offset[i][level]) = *col_iter;
1303 y =
static_cast<unsigned int>(col_iter.index2());
1307 x =
static_cast<unsigned int>(row_iter.index1());
1318 template <
typename SparseMatrixType>
1319 void amg_mat_prod (SparseMatrixType & A, SparseMatrixType & B, SparseMatrixType & RES)
1321 typedef typename SparseMatrixType::value_type ScalarType;
1322 typedef typename SparseMatrixType::iterator1 InternalRowIterator;
1323 typedef typename SparseMatrixType::iterator2 InternalColIterator;
1327 RES = SparseMatrixType(static_cast<unsigned int>(A.size1()), static_cast<unsigned int>(B.size2()));
1330 #ifdef VIENNACL_WITH_OPENMP
1331 #pragma omp parallel for private (x,y,z,prod)
1333 for (x=0; x<static_cast<long>(A.size1()); ++x)
1335 InternalRowIterator row_iter = A.begin1();
1337 for (InternalColIterator col_iter = row_iter.begin(); col_iter != row_iter.end(); ++col_iter)
1339 y =
static_cast<unsigned int>(col_iter.index2());
1340 InternalRowIterator row_iter2 = B.begin1();
1343 for(InternalColIterator col_iter2 = row_iter2.begin(); col_iter2 != row_iter2.end(); ++col_iter2)
1345 z =
static_cast<unsigned int>(col_iter2.index2());
1346 prod = *col_iter * *col_iter2;
1358 template <
typename SparseMatrixType>
1361 typedef typename SparseMatrixType::value_type ScalarType;
1362 typedef typename SparseMatrixType::iterator1 InternalRowIterator;
1363 typedef typename SparseMatrixType::iterator2 InternalColIterator;
1367 RES = SparseMatrixType(static_cast<unsigned int>(P.size2()), static_cast<unsigned int>(P.size2()));
1370 #ifdef VIENNACL_WITH_OPENMP
1371 #pragma omp parallel for private (x,y1,y2,z,row)
1373 for (x=0; x<static_cast<long>(P.size2()); ++x)
1376 InternalRowIterator row_iter = P.begin1(
true);
1379 for (InternalColIterator col_iter = row_iter.begin(); col_iter != row_iter.end(); ++col_iter)
1381 y1 =
static_cast<long>(col_iter.index2());
1382 InternalRowIterator row_iter2 = A.begin1();
1385 for(InternalColIterator col_iter2 = row_iter2.begin(); col_iter2 != row_iter2.end(); ++col_iter2)
1387 y2 =
static_cast<long>(col_iter2.index2());
1388 row.
add (y2, *col_iter * *col_iter2);
1394 InternalRowIterator row_iter3 = P.begin1();
1397 for (InternalColIterator col_iter3 = row_iter3.begin(); col_iter3 != row_iter3.end(); ++col_iter3)
1399 z =
static_cast<long>(col_iter3.index2());
1400 RES.add (x, z, *col_iter3 * *iter);
1405 #ifdef VIENNACL_AMG_DEBUG
1406 std::cout <<
"Galerkin Operator: " << std::endl;
1416 template <
typename SparseMatrixType>
1419 typedef typename SparseMatrixType::value_type ScalarType;
1421 boost::numeric::ublas::compressed_matrix<ScalarType> A_temp (A.size1(), A.size2());
1423 boost::numeric::ublas::compressed_matrix<ScalarType> P_temp (P.size1(), P.size2());
1426 boost::numeric::ublas::compressed_matrix<ScalarType> R_temp (P.size1(), P.size2());
1430 boost::numeric::ublas::compressed_matrix<ScalarType> RA (R_temp.size1(),A_temp.size2());
1432 boost::numeric::ublas::compressed_matrix<ScalarType> RAP (RA.size1(),P_temp.size2());
1435 for (
unsigned int x=0; x<RAP.size1(); ++x)
1437 for (
unsigned int y=0; y<RAP.size2(); ++y)
1439 if (std::fabs(static_cast<ScalarType>(RAP(x,y)) - static_cast<ScalarType>(A_i1(x,y))) > 0.0001)
1440 std::cout << x <<
" " << y <<
" " << RAP(x,y) <<
" " << A_i1(x,y) << std::endl;
1450 template <
typename SparseMatrixType,
typename Po
intVectorType>
1453 for (
unsigned int i=0; i<P.size1(); ++i)
1455 if (Pointvector.is_cpoint(i))
1458 for (
unsigned int j=0; j<P.size2(); ++j)
1460 if (P.isnonzero(i,j))
1463 std::cout <<
"Error 1 in row " << i << std::endl;
1464 if (P(i,j) == 1 && set)
1465 std::cout <<
"Error 2 in row " << i << std::endl;
1466 if (P(i,j) == 1 && !set)
1472 if (Pointvector.is_fpoint(i))
1473 for (
unsigned int j=0; j<P.size2(); ++j)
1475 if (P.isnonzero(i,j) && j> Pointvector.get_cpoints()-1)
1476 std::cout <<
"Error 3 in row " << i << std::endl;
1477 if (P.isnonzero(i,j))
1480 for (
unsigned int k=0; k<P.size1(); ++k)
1482 if (P.isnonzero(k,j))
1484 if (Pointvector.is_cpoint(k) && P(k,j) == 1 && A.isnonzero(i,k))
1489 std::cout <<
"Error 4 in row " << i << std::endl;
void clear_influencelists()
Definition: amg_base.hpp:991
iterator begin()
Definition: amg_base.hpp:352
ConstAdapterType::const_iterator2 const_iterator2
Definition: amg_base.hpp:409
amg_sparsevector_iterator(InternalType &vec, bool begin=true)
The constructor.
Definition: amg_base.hpp:218
Debug functionality for AMG. To be removed.
std::size_t vcl_size_t
Definition: forwards.h:58
double get_jacobiweight() const
Definition: amg_base.hpp:102
void set_offset(unsigned int offset)
Definition: amg_base.hpp:850
void set_coarselevels(int coarselevels)
Definition: amg_base.hpp:110
void switch_ftoc()
Definition: amg_base.hpp:904
iterator end()
Definition: amg_base.hpp:354
void set_as(double jacobiweight)
Definition: amg_base.hpp:98
ScalarType value_type
Definition: amg_base.hpp:257
const_iterator2 end2(bool trans=false) const
Definition: amg_base.hpp:768
void add_influencing_point(amg_point *point)
Definition: amg_base.hpp:867
vcl_size_t size1()
Definition: amg_base.hpp:653
amg_sparsematrix(MatrixType const &mat)
Constructor. Builds matrix via another matrix type. (Only necessary feature of this other matrix type...
Definition: amg_base.hpp:459
viennacl::enable_if< viennacl::is_any_sparse_matrix< M1 >::value, matrix_expression< const M1, const M1, op_trans > >::type trans(const M1 &mat)
Returns an expression template class representing a transposed matrix.
Definition: sparse_matrix_operations.hpp:330
void addscalar(IteratorType &iter, unsigned int i, unsigned int, ScalarType s)
Definition: amg_base.hpp:312
A class for the AMG points. Saves point index and influence measure Holds information whether point i...
Definition: amg_base.hpp:816
std::vector< std::map< unsigned int, ScalarType > > * get_internal_pointer()
Definition: amg_base.hpp:776
void addscalar(IteratorType &iter, unsigned int i, unsigned int j, ScalarType s)
Definition: amg_base.hpp:566
amg_nonzero_scalar(InternalType *m, IteratorType &iter, unsigned int i, unsigned int j, ScalarType s=0)
The constructor.
Definition: amg_base.hpp:142
unsigned int get_influence() const
Definition: amg_base.hpp:854
ScalarType operator=(const ScalarType value)
Assignment operator. Writes value into matrix at the given position.
Definition: amg_base.hpp:151
void set_coarse_index(unsigned int index)
Definition: amg_base.hpp:878
void update_cf(amg_point *point)
Definition: amg_base.hpp:982
bool get_trans() const
Definition: amg_base.hpp:520
void get_F(VectorType &vec) const
Definition: amg_base.hpp:1139
const_iterator begin() const
Definition: amg_base.hpp:1003
void get_sorting(VectorType &vec) const
Definition: amg_base.hpp:1114
amg_point * get_nextpoint()
Definition: amg_base.hpp:1025
void test_triplematprod(SparseMatrixType &A, SparseMatrixType &P, SparseMatrixType &A_i1)
Test triple-matrix product by comparing it to ublas functions. Very slow for large matrices! ...
Definition: amg_base.hpp:1417
unsigned int levels_
Definition: amg_base.hpp:1181
iterator begin()
Definition: amg_base.hpp:1001
boost::numeric::ublas::vector< boost::numeric::ublas::vector< unsigned int > > Offset
Definition: amg_base.hpp:1178
A class for the sparse vector type.
Definition: amg_base.hpp:254
void clear()
Definition: amg_base.hpp:644
void prod(const T1 &A, bool transposed_A, const T2 &B, bool transposed_B, T3 &C, ScalarType alpha, ScalarType beta)
Definition: matrix_operations.hpp:2305
void calc_influence()
Definition: amg_base.hpp:881
void init(unsigned int levels, unsigned int threads=0)
Definition: amg_base.hpp:1183
void slice(unsigned int level, InternalType1 const &A, InternalType2 const &Pointvector)
Definition: amg_base.hpp:1213
unsigned int get_coarse() const
Definition: amg_base.hpp:90
iterator2 end2(bool trans=false)
Definition: amg_base.hpp:731
void resize(unsigned int i, unsigned int j, bool preserve=true)
Definition: amg_base.hpp:634
void add(unsigned int i, ScalarType s)
Definition: amg_base.hpp:293
void clear_influencing()
Definition: amg_base.hpp:872
unsigned int get_coarse_index() const
Definition: amg_base.hpp:877
unsigned int get_postsmooth() const
Definition: amg_base.hpp:108
bool is_undecided() const
Definition: amg_base.hpp:860
void printmatrix(MatrixType &, int)
Definition: amg_debug.hpp:77
iterator2 begin2(bool trans=false)
Definition: amg_base.hpp:716
void set_aggregate(unsigned int aggregate)
Definition: amg_base.hpp:855
void set_index(unsigned int index)
Definition: amg_base.hpp:852
VectorType::iterator iterator
Definition: amg_base.hpp:948
void add_influenced_point(amg_point *point)
Definition: amg_base.hpp:869
void clear_cf()
Definition: amg_base.hpp:988
amg_point * operator[](unsigned int i) const
Definition: amg_base.hpp:1000
unsigned int get_cpoints() const
Definition: amg_base.hpp:1014
unsigned int index() const
Definition: amg_base.hpp:247
NonzeroScalarType operator[](unsigned int i)
Definition: amg_base.hpp:330
unsigned int get_offset()
Definition: amg_base.hpp:851
bool operator==(self_type other)
Definition: amg_base.hpp:226
amg_sparsematrix()
Standard constructor.
Definition: amg_base.hpp:412
unsigned int internal_size() const
Definition: amg_base.hpp:286
const_iterator begin_influenced() const
Definition: amg_base.hpp:913
AdapterType::iterator1 iterator1
Definition: amg_base.hpp:406
amg_point(unsigned int index, unsigned int size)
The constructor.
Definition: amg_base.hpp:844
void make_cpoint()
Definition: amg_base.hpp:890
void set_interpolweight(double interpolweight)
Definition: amg_base.hpp:101
ListType::const_iterator const_iterator
Definition: amg_base.hpp:840
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
const_iterator end_influencing() const
Definition: amg_base.hpp:910
unsigned int get_aggregate()
Definition: amg_base.hpp:856
void init_points()
Definition: amg_base.hpp:961
unsigned int number_influencing() const
Definition: amg_base.hpp:863
void sort()
Definition: amg_base.hpp:1019
VectorT prod(std::vector< std::vector< T, A1 >, A2 > const &matrix, VectorT const &vector)
Definition: prod.hpp:91
void resize(unsigned int size)
Definition: amg_base.hpp:1006
ListType::iterator iterator
Definition: amg_base.hpp:839
void add(unsigned int i, unsigned int j, ScalarType s)
Definition: amg_base.hpp:542
void set_presmooth(int presmooth)
Definition: amg_base.hpp:104
self_type & operator--() const
Definition: amg_base.hpp:243
boost::numeric::ublas::vector< InternalType1 > A_slice
Definition: amg_base.hpp:1175
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:144
A tag for algebraic multigrid (AMG). Used to transport information from the user to the implementatio...
Definition: amg_base.hpp:61
void make_cpoint(amg_point *point)
Definition: amg_base.hpp:1056
boost::numeric::ublas::vector< InternalType2 > Pointvector_slice
Definition: amg_base.hpp:1176
const_iterator end() const
Definition: amg_base.hpp:355
bool operator!=(self_type other)
Definition: amg_base.hpp:233
void make_fpoint(amg_point *point)
Definition: amg_base.hpp:1063
void clear_influenced()
Definition: amg_base.hpp:874
iterator begin_influencing()
Definition: amg_base.hpp:907
unsigned int get_fpoints() const
Definition: amg_base.hpp:1016
vcl_size_t size2()
Definition: amg_base.hpp:670
ScalarType operator++()
Definition: amg_base.hpp:189
void test_interpolation(SparseMatrixType &A, SparseMatrixType &P, PointVectorType &Pointvector)
Test if interpolation matrix makes sense. Only vanilla test though! Only checks if basic requirements...
Definition: amg_base.hpp:1451
void removescalar(IteratorType &iter, unsigned int)
Definition: amg_base.hpp:327
bool is_cpoint() const
Definition: amg_base.hpp:858
void get_influence(VectorType &vec) const
Definition: amg_base.hpp:1105
iterator begin_influenced()
Definition: amg_base.hpp:911
void do_trans()
Definition: amg_base.hpp:488
void clear()
Definition: amg_base.hpp:288
void amg_galerkin_prod(SparseMatrixType &A, SparseMatrixType &P, SparseMatrixType &RES)
Sparse Galerkin product: Calculates RES = trans(P)*A*P.
Definition: amg_base.hpp:1359
void add_influence(amg_point *point, unsigned int add)
Definition: amg_base.hpp:1038
unsigned int get_coarselevels() const
Definition: amg_base.hpp:111
void set_threshold(double threshold)
Definition: amg_base.hpp:95
amg_sparsematrix(unsigned int i, unsigned int j)
Constructor. Builds matrix of size (i,j).
Definition: amg_base.hpp:422
const_iterator begin_influencing() const
Definition: amg_base.hpp:909
iterator1 end1(bool trans=false)
Definition: amg_base.hpp:701
void resize(unsigned int size)
Definition: amg_base.hpp:282
void make_fpoint()
Definition: amg_base.hpp:897
AdapterType::iterator2 iterator2
Definition: amg_base.hpp:407
bool isnonzero(unsigned int i, unsigned int j) const
Definition: amg_base.hpp:523
A class for the sparse matrix type. Uses vector of maps as data structure for higher performance and ...
Definition: amg_base.hpp:376
iterator1 begin1(bool trans=false)
Definition: amg_base.hpp:686
unsigned int size() const
Definition: amg_base.hpp:283
ScalarType operator()(unsigned int i, unsigned int j) const
Definition: amg_base.hpp:612
void set_postsmooth(int postsmooth)
Definition: amg_base.hpp:107
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_row > row(const matrix_base< NumericT, F > &A, unsigned int i)
Definition: matrix.hpp:910
double get_threshold() const
Definition: amg_base.hpp:96
ScalarType & operator*() const
Definition: amg_base.hpp:245
double get_interpolweight() const
Definition: amg_base.hpp:99
const_iterator1 begin1() const
Definition: amg_base.hpp:746
unsigned int threads_
Definition: amg_base.hpp:1180
void get_Aggregates(MatrixType &mat) const
Definition: amg_base.hpp:1151
NonzeroScalarType operator()(unsigned int i, unsigned int j)
Definition: amg_base.hpp:589
unsigned int get_index() const
Definition: amg_base.hpp:853
void set_interpol(unsigned int interpol)
Definition: amg_base.hpp:92
self_type & operator++() const
Definition: amg_base.hpp:241
amg_sparsevector_iterator< InternalType > iterator
Definition: amg_base.hpp:270
A class for a scalar that can be written to the sparse matrix or sparse vector datatypes.
Definition: amg_base.hpp:124
void build_index()
Definition: amg_base.hpp:1078
InternalType::const_iterator const_iterator
Definition: amg_base.hpp:271
unsigned int get_interpol() const
Definition: amg_base.hpp:93
void get_influence_matrix(MatrixType &mat) const
Definition: amg_base.hpp:1095
void amg_mat_prod(SparseMatrixType &A, SparseMatrixType &B, SparseMatrixType &RES)
Sparse matrix product. Calculates RES = A*B.
Definition: amg_base.hpp:1319
void delete_points()
Definition: amg_base.hpp:967
const_iterator end_influenced() const
Definition: amg_base.hpp:914
const_iterator end() const
Definition: amg_base.hpp:1004
ConstAdapterType::const_iterator1 const_iterator1
Definition: amg_base.hpp:408
vcl_size_t size1() const
Definition: amg_base.hpp:661
ScalarType operator+=(const ScalarType value)
Addition operator. Adds a constant.
Definition: amg_base.hpp:164
iterator end()
Definition: amg_base.hpp:1002
bool operator()(amg_point *l, amg_point *r) const
Definition: amg_base.hpp:922
bool is_influencing(amg_point *point) const
Definition: amg_base.hpp:865
void set_coarse(unsigned int coarse)
Definition: amg_base.hpp:89
void switch_ftoc(amg_point *point)
Definition: amg_base.hpp:1070
void join(unsigned int level, InternalType2 &Pointvector) const
Definition: amg_base.hpp:1226
const_iterator begin() const
Definition: amg_base.hpp:353
amg_sparsematrix(std::vector< std::map< unsigned int, ScalarType > > const &mat)
Constructor. Builds matrix via std::vector by copying memory (Only necessary feature of thi...
Definition: amg_base.hpp:440
Defines an iterator for the sparse vector type.
Definition: amg_base.hpp:203
void removescalar(IteratorType &iter, unsigned int i)
Definition: amg_base.hpp:582
const_iterator2 begin2(bool trans=false) const
Definition: amg_base.hpp:761
const_iterator1 end1(bool trans=false) const
Definition: amg_base.hpp:754
iterator end_influenced()
Definition: amg_base.hpp:912
amg_pointvector(unsigned int size=0)
The constructor.
Definition: amg_base.hpp:954
unsigned int add_influence(int add)
Definition: amg_base.hpp:884
unsigned int index()
Definition: amg_base.hpp:248
bool is_fpoint() const
Definition: amg_base.hpp:859
Comparison class for the sorted set of points in amg_pointvector. Set is sorted by influence measure ...
Definition: amg_base.hpp:919
iterator end_influencing()
Definition: amg_base.hpp:908
void get_C(VectorType &vec) const
Definition: amg_base.hpp:1127
void add_point(amg_point *point)
Definition: amg_base.hpp:973
void set_trans(bool mode)
Definition: amg_base.hpp:513
bool isnonzero(unsigned int i) const
Definition: amg_base.hpp:358
unsigned int size() const
Definition: amg_base.hpp:1011
amg_tag(unsigned int coarse=1, unsigned int interpol=1, double threshold=0.25, double interpolweight=0.2, double jacobiweight=1, unsigned int presmooth=1, unsigned int postsmooth=1, unsigned int coarselevels=0)
The constructor.
Definition: amg_base.hpp:76
amg_sparsevector(unsigned int size=0)
The constructor.
Definition: amg_base.hpp:277
A class for the matrix slicing for parallel coarsening schemes (RS0/RS3).
Definition: amg_base.hpp:1168
VectorType::const_iterator const_iterator
Definition: amg_base.hpp:949
vcl_size_t size2() const
Definition: amg_base.hpp:678
unsigned int get_presmooth() const
Definition: amg_base.hpp:105
A class for the AMG points. Holds pointers of type amg_point in a vector that can be accessed using [...
Definition: amg_base.hpp:935
ScalarType value_type
Definition: amg_base.hpp:379