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) { coarse_ = coarse; }
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; }
114 unsigned int coarse_, interpol_;
115 double threshold_, interpolweight_, jacobiweight_;
116 unsigned int presmooth_, postsmooth_, coarselevels_;
123 template<
typename InternalT,
typename IteratorT,
typename NumericT>
132 template <
typename T>
133 bool is_zero(T value)
const {
return value <= 0 && value >= 0; }
135 template <
typename T>
136 bool is_zero(T * value)
const {
return value == NULL; }
152 NumericT s = 0): m_(m), iter_(iter), i_(i), j_(j), s_(s) {}
161 if (is_zero(s_))
return s_;
163 m_->addscalar(iter_,i_,j_,s_);
180 m_->removescalar(iter_,i_);
184 m_->addscalar(iter_,i_,j_,s_);
191 m_->removescalar(iter_,i_);
192 m_->addscalar (iter_,i_,j_,s_);
199 m_->removescalar(iter_,i_);
200 m_->addscalar(iter_,i_,j_,s_);
203 operator NumericT(
void) {
return s_; }
208 template<
typename InternalT>
213 typedef typename InternalT::mapped_type ScalarType;
215 InternalT & internal_vec_;
216 typename InternalT::iterator iter_;
227 iter_ = internal_vec_.begin();
229 iter_ = internal_vec_.end();
234 if (iter_ == other.iter_)
241 if (iter_ != other.iter_)
251 ScalarType
const &
operator * ()
const {
return (*iter_).second; }
253 unsigned int index()
const {
return (*iter_).first; }
254 unsigned int index() {
return (*iter_).first; }
259 template<
typename NumericT>
267 typedef std::map<unsigned int, NumericT> InternalType;
273 InternalType internal_vector_;
275 template <
typename T>
276 bool is_zero(T value)
const {
return value <= 0 && value >= 0; }
278 template <
typename T>
279 bool is_zero(T * value)
const {
return value == NULL; }
292 unsigned int size()
const {
return size_;}
295 unsigned int internal_size()
const {
return static_cast<unsigned int>(internal_vector_.size()); }
297 void clear() { internal_vector_.clear(); }
299 void remove(
unsigned int i) { internal_vector_.erase(i); }
302 void add(
unsigned int i, NumericT s)
304 typename InternalType::iterator iter = internal_vector_.find(i);
306 if (iter == internal_vector_.end())
315 internal_vector_.erase(iter);
320 template<
typename IteratorT>
321 void addscalar(IteratorT & iter,
unsigned int i,
unsigned int , NumericT s)
328 if (iter != internal_vector_.end())
331 internal_vector_[i] = s;
335 template<
typename IteratorT>
336 void removescalar(IteratorT & iter,
unsigned int ) { internal_vector_.erase(iter); }
341 typename InternalType::iterator it = internal_vector_.find(i);
343 if (it != internal_vector_.end())
354 if (it != internal_vector_.end())
367 bool isnonzero(
unsigned int i)
const {
return internal_vector_.find(i) != internal_vector_.end(); }
370 operator boost::numeric::ublas::vector<NumericT>(void)
372 boost::numeric::ublas::vector<NumericT> vec (size_);
374 vec [iter.index()] = *iter;
384 template<
typename NumericT>
390 typedef std::map<unsigned int,NumericT> RowType;
391 typedef std::vector<RowType> InternalType;
402 InternalType internal_mat_;
405 InternalType internal_mat_trans_;
410 bool transposed_mode_;
423 transposed_mode_ =
false;
436 a_trans.
resize(j,i,
false);
441 transposed_mode_ =
false;
451 AdapterType a (internal_mat_, mat.size(), mat.size());
452 AdapterType a_trans (internal_mat_trans_, mat.size(), mat.size());
453 a.
resize(mat.size(), mat.size());
454 a_trans.resize(mat.size(), mat.size());
457 s1_ = s2_ = mat.size();
459 transposed_mode_ =
false;
467 template<
typename MatrixT>
470 AdapterType a(internal_mat_, mat.size1(), mat.size2());
471 AdapterType a_trans(internal_mat_trans_, mat.size2(), mat.size1());
472 a.
resize(mat.size1(), mat.size2());
473 a_trans.resize(mat.size2(), mat.size1());
479 for (
typename MatrixT::const_iterator1 row_iter = mat.begin1(); row_iter != mat.end1(); ++row_iter)
481 for (
typename MatrixT::const_iterator2 col_iter = row_iter.begin(); col_iter != row_iter.end(); ++col_iter)
483 if (std::fabs(*col_iter) > 0)
485 unsigned int x =
static_cast<unsigned int>(col_iter.index1());
486 unsigned int y =
static_cast<unsigned int>(col_iter.index2());
488 a_trans(y,x) = *col_iter;
492 transposed_mode_ =
false;
500 #ifdef VIENNACL_WITH_OPENMP
508 bool save_mode = transposed_mode_;
509 transposed_mode_ =
false;
512 for (
iterator2 col_iter = row_iter.
begin(); col_iter != row_iter.end(); ++col_iter)
513 internal_mat_trans_[col_iter.index2()][
static_cast<unsigned int>(col_iter.index1())] = *col_iter;
515 transposed_mode_ = save_mode;
524 transposed_mode_ = mode;
534 if (!transposed_mode_)
536 if (internal_mat_[i].find(j) != internal_mat_[i].end())
543 if (internal_mat_[j].find(i) != internal_mat_[j].end())
551 void add(
unsigned int i,
unsigned int j, NumericT s)
554 if (s <= 0 && s >= 0)
557 typename RowType::iterator col_iter = internal_mat_[i].find(j);
559 if (col_iter == internal_mat_[i].end())
563 s += (*col_iter).second;
566 (*col_iter).second = s;
568 internal_mat_[i].erase(col_iter);
574 template<
typename IteratorT>
575 void addscalar(IteratorT & iter,
unsigned int i,
unsigned int j, NumericT s)
578 if (s >= 0 && s <= 0)
581 if (iter != internal_mat_[i].end())
584 internal_mat_[i][j] = s;
590 template<
typename IteratorT>
593 internal_mat_[i].erase(iter);
600 typename RowType::iterator iter;
602 if (!transposed_mode_)
604 iter = internal_mat_[i].find(j);
605 if (iter != internal_mat_[i].end())
612 iter = internal_mat_[j].find(i);
613 if (iter != internal_mat_[j].end())
623 typename RowType::const_iterator iter;
625 if (!transposed_mode_)
627 iter = internal_mat_[i].find(j);
628 if (iter != internal_mat_[i].end())
629 return (*iter).second;
635 iter = internal_mat_[j].find(i);
636 if (iter != internal_mat_[j].end())
637 return (*iter).second;
643 void resize(
unsigned int i,
unsigned int j,
bool preserve =
true)
648 a_trans.
resize(j,i,preserve);
657 AdapterType a_trans(internal_mat_trans_, s2_, s1_);
664 if (!transposed_mode_)
672 if (!transposed_mode_)
681 if (!transposed_mode_)
689 if (!transposed_mode_)
697 if (!
trans && !transposed_mode_)
705 AdapterType a_trans(internal_mat_trans_, s2_, s1_);
712 if (!
trans && !transposed_mode_)
720 AdapterType a_trans(internal_mat_trans_, s2_, s1_);
721 return a_trans.
end1();
727 if (!
trans && !transposed_mode_)
735 AdapterType a_trans(internal_mat_trans_, s2_, s1_);
742 if (!
trans && !transposed_mode_)
750 AdapterType a_trans(internal_mat_trans_, s2_, s1_);
751 return a_trans.
end2();
758 assert((!transposed_mode_ || (transposed_mode_ && transposed_)) &&
bool(
"Error: Cannot build const_iterator when transposed has not been built yet!"));
765 assert((!transposed_mode_ || (transposed_mode_ && transposed_)) &&
bool(
"Error: Cannot build const_iterator when transposed has not been built yet!"));
767 return a_const.
end1();
772 assert((!transposed_mode_ || (transposed_mode_ && transposed_)) &&
bool(
"Error: Cannot build const_iterator when transposed has not been built yet!"));
779 assert((!transposed_mode_ || (transposed_mode_ && transposed_)) &&
bool(
"Error: Cannot build const_iterator when transposed has not been built yet!"));
781 return a_const.
end2();
787 if (!transposed_mode_)
788 return &internal_mat_;
792 return &internal_mat_trans_;
795 operator boost::numeric::ublas::compressed_matrix<NumericT>(void)
797 boost::numeric::ublas::compressed_matrix<NumericT> mat;
802 for (
iterator2 col_iter = row_iter.
begin(); col_iter != row_iter.end(); ++col_iter)
803 mat(col_iter.index1(), col_iter.index2()) = *col_iter;
808 operator boost::numeric::ublas::matrix<NumericT>(void)
810 boost::numeric::ublas::matrix<NumericT> mat;
815 for (
iterator2 col_iter = row_iter.
begin(); col_iter != row_iter.end(); ++col_iter)
816 mat(col_iter.index1(), col_iter.index2()) = *col_iter;
833 unsigned int influence_;
838 unsigned int coarse_index_;
840 unsigned int offset_;
842 unsigned int aggregate_;
855 amg_point (
unsigned int index,
unsigned int size): index_(index), influence_(0), undecided_(true), cpoint_(false), coarse_index_(0), offset_(0), aggregate_(0)
857 influencing_points_ =
ListType(size);
858 influenced_points_ =
ListType(size);
863 void set_index(
unsigned int index) { index_ = index+offset_; }
864 unsigned int get_index()
const {
return index_-offset_; }
869 bool is_cpoint()
const {
return cpoint_ && !undecided_; }
870 bool is_fpoint()
const {
return !cpoint_ && !undecided_; }
950 typedef std::set<amg_point*,classcomp> ListType;
952 typedef std::vector<amg_point*> VectorType;
954 VectorType pointvector_;
957 unsigned int c_points_, f_points_;
968 pointvector_ = VectorType(
size);
969 c_points_ = f_points_ = 0;
975 for (
unsigned int i=0; i<
size(); ++i)
981 for (
unsigned int i=0; i<
size(); ++i)
982 delete pointvector_[i];
987 pointvector_[point->
get_index()] = point;
989 else if (point->
is_fpoint()) f_points_++;
997 else if (point->
is_fpoint()) f_points_++;
1005 for (
iterator iter = pointvector_.begin(); iter != pointvector_.end(); ++iter)
1007 (*iter)->clear_influencing();
1008 (*iter)->clear_influenced();
1021 pointvector_ = VectorType(size);
1023 unsigned int size()
const {
return size_; }
1034 pointlist_.insert(*iter);
1040 if (pointlist_.size() == 0)
1043 if ((*(--pointlist_.end()))->get_influence() == 0)
1047 return *(--pointlist_.end());
1052 ListType::iterator iter = pointlist_.find(point);
1054 if (iter == pointlist_.end())
return;
1057 pointlist_.erase(iter);
1061 pointlist_.insert(point);
1066 pointlist_.erase(point);
1073 pointlist_.erase(point);
1088 unsigned int count = 0;
1090 for (
iterator iter = pointvector_.begin(); iter != pointvector_.end(); ++iter)
1093 if ((*iter)->is_cpoint())
1095 (*iter)->set_coarse_index(count);
1102 template<
typename MatrixT>
1109 for (
amg_point::iterator col_iter = (*row_iter)->begin_influencing(); col_iter != (*row_iter)->end_influencing(); ++col_iter)
1110 mat((*row_iter)->get_index(),(*col_iter)->get_index()) =
true;
1112 template<
typename VectorT>
1115 vec = VectorT(size_);
1119 vec[(*iter)->get_index()] = (*iter)->get_influence();
1121 template<
typename VectorT>
1124 vec = VectorT(pointlist_.size());
1128 for (ListType::const_iterator iter = pointlist_.begin(); iter != pointlist_.end(); ++iter)
1130 vec[i] = (*iter)->get_index();
1134 template<
typename VectorT>
1137 vec = VectorT(size_);
1142 if ((*iter)->is_cpoint())
1143 vec[(*iter)->get_index()] =
true;
1146 template<
typename VectorT>
1149 vec = VectorT(size_);
1154 if ((*iter)->is_fpoint())
1155 vec[(*iter)->get_index()] =
true;
1158 template<
typename MatrixT>
1161 mat = MatrixT(size_,size_);
1166 if (!(*iter)->is_undecided())
1167 mat((*iter)->get_aggregate(),(*iter)->get_index()) =
true;
1175 template<
typename InternalT1,
typename InternalT2>
1178 typedef typename InternalT1::value_type SparseMatrixType;
1179 typedef typename InternalT2::value_type PointVectorType;
1186 boost::numeric::ublas::vector<boost::numeric::ublas::vector<unsigned int> >
offset_;
1191 void init(
unsigned int levels,
unsigned int threads = 0)
1195 #ifdef VIENNACL_WITH_OPENMP
1210 for (
unsigned int i=0; i<
threads_; ++i)
1221 void slice(
unsigned int level, InternalT1
const & A, InternalT2
const & pointvector)
1225 slice_new(level, A);
1230 slice_build(level, A, pointvector);
1234 void join(
unsigned int level, InternalT2 & pointvector)
const
1236 typedef typename InternalT2::value_type PointVectorType;
1239 pointvector[level].clear_cf();
1240 for (
typename PointVectorType::iterator iter = pointvector[level].begin(); iter != pointvector[level].end(); ++iter)
1242 (*iter)->set_offset(0);
1243 pointvector[level].update_cf(*iter);
1252 void slice_new(
unsigned int level, InternalT1
const & A)
1255 #ifdef VIENNACL_WITH_OPENMP
1256 #pragma omp parallel for
1258 for (
long i2=0; i2<=static_cast<long>(
threads_); ++i2)
1260 std::size_t i =
static_cast<std::size_t
>(i2);
1263 if (i == 0)
offset_[i][level] = 0;
1264 else if (i ==
threads_)
offset_[i][level] =
static_cast<unsigned int>(A[level].size1());
1265 else offset_[i][level] =
static_cast<unsigned int>(i*(A[level].size1()/
threads_));
1274 void slice_build(
unsigned int level, InternalT1
const & A, InternalT2
const & pointvector)
1276 typedef typename SparseMatrixType::const_iterator1 ConstRowIterator;
1277 typedef typename SparseMatrixType::const_iterator2 ConstColIterator;
1279 #ifdef VIENNACL_WITH_OPENMP
1280 #pragma omp parallel for
1282 for (
long i2=0; i2<static_cast<long>(
threads_); ++i2)
1284 std::size_t i =
static_cast<std::size_t
>(i2);
1293 ConstRowIterator row_iter = A[level].begin1();
1294 row_iter +=
offset_[i][level];
1295 unsigned int x =
static_cast<unsigned int>(row_iter.index1());
1297 while (x <
offset_[i+1][level] && row_iter != A[level].end1())
1300 point = pointvector[level][x];
1301 point->set_offset(
offset_[i][level]);
1304 ConstColIterator col_iter = row_iter.begin();
1305 unsigned int y =
static_cast<unsigned int>(col_iter.index2());
1308 while (y <
offset_[i+1][level] && col_iter != row_iter.end())
1311 A_slice_[i][level](x-
offset_[i][level], y-offset_[i][level]) = *col_iter;
1314 y =
static_cast<unsigned int>(col_iter.index2());
1318 x =
static_cast<unsigned int>(row_iter.index1());
1329 template<
typename SparseMatrixT>
1330 void amg_mat_prod (SparseMatrixT & A, SparseMatrixT & B, SparseMatrixT & RES)
1332 typedef typename SparseMatrixT::value_type
ScalarType;
1333 typedef typename SparseMatrixT::iterator1 InternalRowIterator;
1334 typedef typename SparseMatrixT::iterator2 InternalColIterator;
1336 RES = SparseMatrixT(static_cast<unsigned int>(A.size1()), static_cast<unsigned int>(B.size2()));
1339 #ifdef VIENNACL_WITH_OPENMP
1340 #pragma omp parallel for
1342 for (
long x=0; x<static_cast<long>(A.size1()); ++x)
1344 InternalRowIterator row_iter = A.begin1();
1346 for (InternalColIterator col_iter = row_iter.begin(); col_iter != row_iter.end(); ++col_iter)
1348 unsigned int y =
static_cast<unsigned int>(col_iter.index2());
1349 InternalRowIterator row_iter2 = B.begin1();
1352 for (InternalColIterator col_iter2 = row_iter2.begin(); col_iter2 != row_iter2.end(); ++col_iter2)
1354 unsigned int z =
static_cast<unsigned int>(col_iter2.index2());
1355 ScalarType
prod = *col_iter * *col_iter2;
1356 RES.add(static_cast<unsigned int>(x),static_cast<unsigned int>(z),prod);
1367 template<
typename SparseMatrixT>
1370 typedef typename SparseMatrixT::value_type
ScalarType;
1371 typedef typename SparseMatrixT::iterator1 InternalRowIterator;
1372 typedef typename SparseMatrixT::iterator2 InternalColIterator;
1374 RES = SparseMatrixT(static_cast<unsigned int>(P.size2()), static_cast<unsigned int>(P.size2()));
1377 #ifdef VIENNACL_WITH_OPENMP
1378 #pragma omp parallel for
1380 for (
long x=0; x<static_cast<long>(P.size2()); ++x)
1383 InternalRowIterator row_iter = P.begin1(
true);
1386 for (InternalColIterator col_iter = row_iter.begin(); col_iter != row_iter.end(); ++col_iter)
1388 long y1 =
static_cast<long>(col_iter.index2());
1389 InternalRowIterator row_iter2 = A.begin1();
1392 for (InternalColIterator col_iter2 = row_iter2.begin(); col_iter2 != row_iter2.end(); ++col_iter2)
1394 long y2 =
static_cast<long>(col_iter2.index2());
1395 row.
add (static_cast<unsigned int>(y2), *col_iter * *col_iter2);
1400 long y2 = iter.index();
1401 InternalRowIterator row_iter3 = P.begin1();
1404 for (InternalColIterator col_iter3 = row_iter3.begin(); col_iter3 != row_iter3.end(); ++col_iter3)
1406 long z =
static_cast<long>(col_iter3.index2());
1407 RES.add (static_cast<unsigned int>(x), static_cast<unsigned int>(z), *col_iter3 * *iter);
1412 #ifdef VIENNACL_AMG_DEBUG
1413 std::cout <<
"Galerkin Operator: " << std::endl;
1423 template<
typename SparseMatrixT>
1426 typedef typename SparseMatrixT::value_type
ScalarType;
1428 boost::numeric::ublas::compressed_matrix<ScalarType> A_temp (A.size1(), A.size2());
1430 boost::numeric::ublas::compressed_matrix<ScalarType> P_temp (P.size1(), P.size2());
1433 boost::numeric::ublas::compressed_matrix<ScalarType> R_temp (P.size1(), P.size2());
1437 boost::numeric::ublas::compressed_matrix<ScalarType> RA (R_temp.size1(),A_temp.size2());
1439 boost::numeric::ublas::compressed_matrix<ScalarType> RAP (RA.size1(),P_temp.size2());
1442 for (
unsigned int x=0; x<RAP.size1(); ++x)
1444 for (
unsigned int y=0; y<RAP.size2(); ++y)
1446 if (std::fabs(static_cast<ScalarType>(RAP(x,y)) - static_cast<ScalarType>(A_i1(x,y))) > 0.0001)
1447 std::cout << x <<
" " << y <<
" " << RAP(x,y) <<
" " << A_i1(x,y) << std::endl;
1457 template<
typename SparseMatrixT,
typename Po
intVectorT>
1460 for (
unsigned int i=0; i<P.size1(); ++i)
1462 if (Pointvector.is_cpoint(i))
1465 for (
unsigned int j=0; j<P.size2(); ++j)
1467 if (P.isnonzero(i,j))
1470 std::cout <<
"Error 1 in row " << i << std::endl;
1471 if (P(i,j) == 1 && set)
1472 std::cout <<
"Error 2 in row " << i << std::endl;
1473 if (P(i,j) == 1 && !set)
1479 if (Pointvector.is_fpoint(i))
1480 for (
unsigned int j=0; j<P.size2(); ++j)
1482 if (P.isnonzero(i,j) && j> Pointvector.get_cpoints()-1)
1483 std::cout <<
"Error 3 in row " << i << std::endl;
1484 if (P.isnonzero(i,j))
1487 for (
unsigned int k=0; k<P.size1(); ++k)
1489 if (P.isnonzero(k,j))
1491 if (Pointvector.is_cpoint(k) && P(k,j) == 1 && A.isnonzero(i,k))
1496 std::cout <<
"Error 4 in row " << i << std::endl;
NumericT operator+=(const NumericT value)
Addition operator. Adds a constant.
amg_sparsematrix(unsigned int i, unsigned int j)
Constructor. Builds matrix of size (i,j).
void addscalar(IteratorT &iter, unsigned int i, unsigned int j, NumericT s)
void get_Aggregates(MatrixT &mat) const
void set_offset(unsigned int offset)
bool isnonzero(unsigned int i) const
void update_cf(amg_point *point)
iterator1 end1(bool trans=false)
AdapterType::iterator2 iterator2
Debug functionality for AMG. To be removed.
void set_aggregate(unsigned int aggregate)
unsigned int get_coarselevels() const
double get_jacobiweight() const
double get_threshold() const
const_iterator end_influencing() const
amg_sparsevector_iterator(InternalT &vec, bool begin=true)
The constructor.
void get_F(VectorT &vec) const
A class for the AMG points. Saves point index and influence measure Holds information whether point i...
void slice(unsigned int level, InternalT1 const &A, InternalT2 const &pointvector)
bool isnonzero(unsigned int i, unsigned int j) const
boost::numeric::ublas::vector< InternalT2 > pointvector_slice_
void removescalar(IteratorT &iter, unsigned int i)
unsigned int number_influencing() const
void switch_ftoc(amg_point *point)
void set_index(unsigned int index)
unsigned int get_cpoints() const
NumericT operator=(const NumericT value)
Assignment operator. Writes value into matrix at the given position.
unsigned int get_aggregate()
A class for the sparse vector type.
unsigned int get_influence() const
void set_postsmooth(unsigned int postsmooth)
unsigned int get_postsmooth() const
unsigned int get_coarse_index() const
const_iterator2 end2(bool trans=false) const
void add(unsigned int i, NumericT s)
void set_as(double jacobiweight)
const_iterator2 begin2(bool trans=false) const
AdapterType::iterator1 iterator1
amg_point(unsigned int index, unsigned int size)
The constructor.
const_iterator begin_influenced() const
unsigned int internal_size() const
std::vector< std::map< unsigned int, NumericT > > * get_internal_pointer()
unsigned int size() const
const_iterator end() const
ConstAdapterType::const_iterator1 const_iterator1
void resize(unsigned int i, unsigned int j, bool preserve=true)
ConstAdapterType::const_iterator2 const_iterator2
iterator begin_influenced()
void removescalar(IteratorT &iter, unsigned int)
bool is_influencing(amg_point *point) const
void make_fpoint(amg_point *point)
amg_point * get_nextpoint()
VectorT prod(std::vector< std::vector< T, A1 >, A2 > const &matrix, VectorT const &vector)
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
void set_interpol(unsigned int interpol)
unsigned int add_influence(unsigned int add)
A tag for algebraic multigrid (AMG). Used to transport information from the user to the implementatio...
unsigned int get_offset()
amg_pointvector(unsigned int size=0)
The constructor.
void get_C(VectorT &vec) const
ListType::iterator iterator
void set_coarse_index(unsigned int index)
boost::numeric::ublas::vector< InternalT1 > A_slice_
NonzeroScalarType operator[](unsigned int i)
unsigned int size() const
amg_sparsematrix()
Standard constructor.
void set_coarse(unsigned int coarse)
amg_sparsevector(unsigned int size=0)
The constructor.
bool operator==(self_type other)
void get_sorting(VectorT &vec) const
void init(unsigned int levels, unsigned int threads=0)
unsigned int get_presmooth() const
const_iterator begin() const
void get_influence(VectorT &vec) const
const_iterator begin_influencing() const
void test_interpolation(SparseMatrixT &A, SparseMatrixT &P, PointVectorT &Pointvector)
Test if interpolation matrix makes sense. Only vanilla test though! Only checks if basic requirements...
unsigned int get_interpol() const
VectorType::const_iterator const_iterator
void join(unsigned int level, InternalT2 &pointvector) const
void addscalar(IteratorT &iter, unsigned int i, unsigned int, NumericT s)
iterator begin_influencing()
void add_influencing_point(amg_point *point)
self_type const & operator--() const
iterator1 begin1(bool trans=false)
ListType::const_iterator const_iterator
void amg_galerkin_prod(SparseMatrixT &A, SparseMatrixT &P, SparseMatrixT &RES)
Sparse Galerkin product: Calculates RES = trans(P)*A*P.
void trans(const matrix_expression< const matrix_base< NumericT, SizeT, DistanceT >, const matrix_base< NumericT, SizeT, DistanceT >, op_trans > &proxy, matrix_base< NumericT > &temp_trans)
void prod(const MatrixT1 &A, bool transposed_A, const MatrixT2 &B, bool transposed_B, MatrixT3 &C, ScalarT alpha, ScalarT beta)
amg_sparsematrix(MatrixT const &mat)
Constructor. Builds matrix via another matrix type. (Only necessary feature of this other matrix type...
const_iterator end_influenced() const
unsigned int get_fpoints() const
A class for the sparse matrix type. Uses vector of maps as data structure for higher performance and ...
unsigned int index() const
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_row > row(const matrix_base< NumericT, F > &A, unsigned int i)
void test_triplematprod(SparseMatrixT &A, SparseMatrixT &P, SparseMatrixT &A_i1)
Test triple-matrix product by comparing it to ublas functions. Very slow for large matrices! ...
amg_point * operator[](unsigned int i) const
bool is_undecided() const
bool operator!=(self_type other)
unsigned int get_coarse() const
NumericT operator()(unsigned int i, unsigned int j) const
void make_cpoint(amg_point *point)
VectorType::iterator iterator
void add(unsigned int i, unsigned int j, NumericT s)
A class for a scalar that can be written to the sparse matrix or sparse vector datatypes.
void add_influence(amg_point *point, unsigned int add)
void resize(unsigned int size)
void clear_influencelists()
double get_interpolweight() const
amg_nonzero_scalar(InternalT *m, IteratorT &iter, unsigned int i, unsigned int j, NumericT s=0)
The constructor.
void add_point(amg_point *point)
void set_threshold(double threshold)
const_iterator end() const
Defines an iterator for the sparse vector type.
void set_presmooth(unsigned int presmooth)
NonzeroScalarType operator()(unsigned int i, unsigned int j)
iterator end_influenced()
unsigned int get_index() const
const_iterator1 begin1() const
void amg_mat_prod(SparseMatrixT &A, SparseMatrixT &B, SparseMatrixT &RES)
Sparse matrix product. Calculates RES = A*B.
iterator end_influencing()
void printmatrix(MatrixT &, int)
const_iterator begin() const
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.
iterator2 begin2(bool trans=false)
void add_influenced_point(amg_point *point)
bool operator()(amg_point *l, amg_point *r) const
void resize(unsigned int size)
const_iterator1 end1(bool trans=false) const
InternalType::const_iterator const_iterator
void set_interpolweight(double interpolweight)
Comparison class for the sorted set of points in amg_pointvector. Set is sorted by influence measure ...
amg_sparsevector_iterator< InternalType > iterator
amg_sparsematrix(std::vector< std::map< unsigned int, NumericT > > const &mat)
Constructor. Builds matrix via std::vector by copying memory (Only necessary feature of thi...
void set_trans(bool mode)
boost::numeric::ublas::vector< boost::numeric::ublas::vector< unsigned int > > offset_
void set_coarselevels(unsigned int coarselevels)
void get_influence_matrix(MatrixT &mat) const
A class for the matrix slicing for parallel coarsening schemes (RS0/RS3).
self_type const & operator++() const
iterator2 end2(bool trans=false)
ScalarType const & operator*() const
A class for the AMG points. Holds pointers of type amg_point in a vector that can be accessed using [...