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>
146 NumericT s = 0): m_(m), iter_(iter), i_(i), j_(j), s_(s) {}
155 if (s_ <= 0 && s_ >= 0)
return s_;
157 m_->addscalar(iter_,i_,j_,s_);
167 if (value <= 0 && value >= 0)
172 if (s_ <= 0 && s_ >= 0)
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 NumericT(
void) {
return s_; }
202 template<
typename InternalT>
207 typedef typename InternalT::mapped_type ScalarType;
209 InternalT & internal_vec_;
210 typename InternalT::iterator iter_;
221 iter_ = internal_vec_.begin();
223 iter_ = internal_vec_.end();
228 if (iter_ == other.iter_)
235 if (iter_ != other.iter_)
245 ScalarType
const &
operator * ()
const {
return (*iter_).second; }
247 unsigned int index()
const {
return (*iter_).first; }
248 unsigned int index() {
return (*iter_).first; }
253 template<
typename NumericT>
261 typedef std::map<unsigned int, NumericT> InternalType;
267 InternalType internal_vector_;
280 unsigned int size()
const {
return size_;}
283 unsigned int internal_size()
const {
return static_cast<unsigned int>(internal_vector_.size()); }
285 void clear() { internal_vector_.clear(); }
287 void remove(
unsigned int i) { internal_vector_.erase(i); }
290 void add(
unsigned int i, NumericT s)
292 typename InternalType::iterator iter = internal_vector_.find(i);
294 if (iter == internal_vector_.end())
303 internal_vector_.erase(iter);
308 template<
typename IteratorT>
309 void addscalar(IteratorT & iter,
unsigned int i,
unsigned int , NumericT s)
312 if (s <= 0 && s >= 0)
316 if (iter != internal_vector_.end())
319 internal_vector_[i] = s;
323 template<
typename IteratorT>
324 void removescalar(IteratorT & iter,
unsigned int ) { internal_vector_.erase(iter); }
329 typename InternalType::iterator it = internal_vector_.find(i);
331 if (it != internal_vector_.end())
342 if (it != internal_vector_.end())
355 bool isnonzero(
unsigned int i)
const {
return internal_vector_.find(i) != internal_vector_.end(); }
358 operator boost::numeric::ublas::vector<NumericT>(void)
360 boost::numeric::ublas::vector<NumericT> vec (size_);
362 vec [iter.index()] = *iter;
372 template<
typename NumericT>
378 typedef std::map<unsigned int,NumericT> RowType;
379 typedef std::vector<RowType> InternalType;
390 InternalType internal_mat_;
393 InternalType internal_mat_trans_;
398 bool transposed_mode_;
411 transposed_mode_ =
false;
424 a_trans.
resize(j,i,
false);
429 transposed_mode_ =
false;
439 AdapterType a (internal_mat_, mat.size(), mat.size());
440 AdapterType a_trans (internal_mat_trans_, mat.size(), mat.size());
441 a.
resize(mat.size(), mat.size());
442 a_trans.resize(mat.size(), mat.size());
445 s1_ = s2_ = mat.size();
447 transposed_mode_ =
false;
455 template<
typename MatrixT>
458 AdapterType a(internal_mat_, mat.size1(), mat.size2());
459 AdapterType a_trans(internal_mat_trans_, mat.size2(), mat.size1());
460 a.
resize(mat.size1(), mat.size2());
461 a_trans.resize(mat.size2(), mat.size1());
467 for (
typename MatrixT::const_iterator1 row_iter = mat.begin1(); row_iter != mat.end1(); ++row_iter)
469 for (
typename MatrixT::const_iterator2 col_iter = row_iter.begin(); col_iter != row_iter.end(); ++col_iter)
471 if (std::fabs(*col_iter) > 0)
473 unsigned int x =
static_cast<unsigned int>(col_iter.index1());
474 unsigned int y =
static_cast<unsigned int>(col_iter.index2());
476 a_trans(y,x) = *col_iter;
480 transposed_mode_ =
false;
488 #ifdef VIENNACL_WITH_OPENMP
496 bool save_mode = transposed_mode_;
497 transposed_mode_ =
false;
500 for (
iterator2 col_iter = row_iter.
begin(); col_iter != row_iter.end(); ++col_iter)
501 internal_mat_trans_[col_iter.index2()][
static_cast<unsigned int>(col_iter.index1())] = *col_iter;
503 transposed_mode_ = save_mode;
512 transposed_mode_ = mode;
522 if (!transposed_mode_)
524 if (internal_mat_[i].find(j) != internal_mat_[i].end())
531 if (internal_mat_[j].find(i) != internal_mat_[j].end())
539 void add(
unsigned int i,
unsigned int j, NumericT s)
542 if (s <= 0 && s >= 0)
545 typename RowType::iterator col_iter = internal_mat_[i].find(j);
547 if (col_iter == internal_mat_[i].end())
551 s += (*col_iter).second;
554 (*col_iter).second = s;
556 internal_mat_[i].erase(col_iter);
562 template<
typename IteratorT>
563 void addscalar(IteratorT & iter,
unsigned int i,
unsigned int j, NumericT s)
566 if (s >= 0 && s <= 0)
569 if (iter != internal_mat_[i].end())
572 internal_mat_[i][j] = s;
578 template<
typename IteratorT>
581 internal_mat_[i].erase(iter);
588 typename RowType::iterator iter;
590 if (!transposed_mode_)
592 iter = internal_mat_[i].find(j);
593 if (iter != internal_mat_[i].end())
600 iter = internal_mat_[j].find(i);
601 if (iter != internal_mat_[j].end())
611 typename RowType::const_iterator iter;
613 if (!transposed_mode_)
615 iter = internal_mat_[i].find(j);
616 if (iter != internal_mat_[i].end())
617 return (*iter).second;
623 iter = internal_mat_[j].find(i);
624 if (iter != internal_mat_[j].end())
625 return (*iter).second;
631 void resize(
unsigned int i,
unsigned int j,
bool preserve =
true)
636 a_trans.
resize(j,i,preserve);
645 AdapterType a_trans(internal_mat_trans_, s2_, s1_);
652 if (!transposed_mode_)
660 if (!transposed_mode_)
669 if (!transposed_mode_)
677 if (!transposed_mode_)
685 if (!
trans && !transposed_mode_)
693 AdapterType a_trans(internal_mat_trans_, s2_, s1_);
700 if (!
trans && !transposed_mode_)
708 AdapterType a_trans(internal_mat_trans_, s2_, s1_);
709 return a_trans.
end1();
715 if (!
trans && !transposed_mode_)
723 AdapterType a_trans(internal_mat_trans_, s2_, s1_);
730 if (!
trans && !transposed_mode_)
738 AdapterType a_trans(internal_mat_trans_, s2_, s1_);
739 return a_trans.
end2();
746 assert((!transposed_mode_ || (transposed_mode_ && transposed_)) &&
bool(
"Error: Cannot build const_iterator when transposed has not been built yet!"));
753 assert((!transposed_mode_ || (transposed_mode_ && transposed_)) &&
bool(
"Error: Cannot build const_iterator when transposed has not been built yet!"));
755 return a_const.
end1();
760 assert((!transposed_mode_ || (transposed_mode_ && transposed_)) &&
bool(
"Error: Cannot build const_iterator when transposed has not been built yet!"));
767 assert((!transposed_mode_ || (transposed_mode_ && transposed_)) &&
bool(
"Error: Cannot build const_iterator when transposed has not been built yet!"));
769 return a_const.
end2();
775 if (!transposed_mode_)
776 return &internal_mat_;
780 return &internal_mat_trans_;
783 operator boost::numeric::ublas::compressed_matrix<NumericT>(void)
785 boost::numeric::ublas::compressed_matrix<NumericT> mat;
790 for (
iterator2 col_iter = row_iter.
begin(); col_iter != row_iter.end(); ++col_iter)
791 mat(col_iter.index1(), col_iter.index2()) = *col_iter;
796 operator boost::numeric::ublas::matrix<NumericT>(void)
798 boost::numeric::ublas::matrix<NumericT> mat;
803 for (
iterator2 col_iter = row_iter.
begin(); col_iter != row_iter.end(); ++col_iter)
804 mat(col_iter.index1(), col_iter.index2()) = *col_iter;
821 unsigned int influence_;
826 unsigned int coarse_index_;
828 unsigned int offset_;
830 unsigned int aggregate_;
843 amg_point (
unsigned int index,
unsigned int size): index_(index), influence_(0), undecided_(true), cpoint_(false), coarse_index_(0), offset_(0), aggregate_(0)
845 influencing_points_ =
ListType(size);
846 influenced_points_ =
ListType(size);
851 void set_index(
unsigned int index) { index_ = index+offset_; }
852 unsigned int get_index()
const {
return index_-offset_; }
857 bool is_cpoint()
const {
return cpoint_ && !undecided_; }
858 bool is_fpoint()
const {
return !cpoint_ && !undecided_; }
938 typedef std::set<amg_point*,classcomp> ListType;
940 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];
975 pointvector_[point->
get_index()] = point;
977 else if (point->
is_fpoint()) f_points_++;
985 else if (point->
is_fpoint()) f_points_++;
993 for (
iterator iter = pointvector_.begin(); iter != pointvector_.end(); ++iter)
995 (*iter)->clear_influencing();
996 (*iter)->clear_influenced();
1009 pointvector_ = VectorType(size);
1011 unsigned int size()
const {
return size_; }
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 pointlist_.erase(iter);
1049 pointlist_.insert(point);
1054 pointlist_.erase(point);
1061 pointlist_.erase(point);
1076 unsigned int count = 0;
1078 for (
iterator iter = pointvector_.begin(); iter != pointvector_.end(); ++iter)
1081 if ((*iter)->is_cpoint())
1083 (*iter)->set_coarse_index(count);
1090 template<
typename MatrixT>
1097 for (
amg_point::iterator col_iter = (*row_iter)->begin_influencing(); col_iter != (*row_iter)->end_influencing(); ++col_iter)
1098 mat((*row_iter)->get_index(),(*col_iter)->get_index()) =
true;
1100 template<
typename VectorT>
1103 vec = VectorT(size_);
1107 vec[(*iter)->get_index()] = (*iter)->get_influence();
1109 template<
typename VectorT>
1112 vec = VectorT(pointlist_.size());
1116 for (ListType::const_iterator iter = pointlist_.begin(); iter != pointlist_.end(); ++iter)
1118 vec[i] = (*iter)->get_index();
1122 template<
typename VectorT>
1125 vec = VectorT(size_);
1130 if ((*iter)->is_cpoint())
1131 vec[(*iter)->get_index()] =
true;
1134 template<
typename VectorT>
1137 vec = VectorT(size_);
1142 if ((*iter)->is_fpoint())
1143 vec[(*iter)->get_index()] =
true;
1146 template<
typename MatrixT>
1149 mat = MatrixT(size_,size_);
1154 if (!(*iter)->is_undecided())
1155 mat((*iter)->get_aggregate(),(*iter)->get_index()) =
true;
1163 template<
typename InternalT1,
typename InternalT2>
1166 typedef typename InternalT1::value_type SparseMatrixType;
1167 typedef typename InternalT2::value_type PointVectorType;
1174 boost::numeric::ublas::vector<boost::numeric::ublas::vector<unsigned int> >
offset_;
1179 void init(
unsigned int levels,
unsigned int threads = 0)
1183 #ifdef VIENNACL_WITH_OPENMP
1198 for (
unsigned int i=0; i<
threads_; ++i)
1209 void slice(
unsigned int level, InternalT1
const & A, InternalT2
const & pointvector)
1213 slice_new(level, A);
1218 slice_build(level, A, pointvector);
1222 void join(
unsigned int level, InternalT2 & pointvector)
const
1224 typedef typename InternalT2::value_type PointVectorType;
1227 pointvector[level].clear_cf();
1228 for (
typename PointVectorType::iterator iter = pointvector[level].begin(); iter != pointvector[level].end(); ++iter)
1230 (*iter)->set_offset(0);
1231 pointvector[level].update_cf(*iter);
1240 void slice_new(
unsigned int level, InternalT1
const & A)
1243 #ifdef VIENNACL_WITH_OPENMP
1244 #pragma omp parallel for
1246 for (
long i2=0; i2<=static_cast<long>(
threads_); ++i2)
1248 std::size_t i =
static_cast<std::size_t
>(i2);
1251 if (i == 0)
offset_[i][level] = 0;
1252 else if (i ==
threads_)
offset_[i][level] =
static_cast<unsigned int>(A[level].size1());
1253 else offset_[i][level] =
static_cast<unsigned int>(i*(A[level].size1()/
threads_));
1262 void slice_build(
unsigned int level, InternalT1
const & A, InternalT2
const & pointvector)
1264 typedef typename SparseMatrixType::const_iterator1 ConstRowIterator;
1265 typedef typename SparseMatrixType::const_iterator2 ConstColIterator;
1270 #ifdef VIENNACL_WITH_OPENMP
1271 #pragma omp parallel for private (x,y,point)
1273 for (
long i2=0; i2<static_cast<long>(
threads_); ++i2)
1275 std::size_t i =
static_cast<std::size_t
>(i2);
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]);
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())
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 SparseMatrixT>
1319 void amg_mat_prod (SparseMatrixT & A, SparseMatrixT & B, SparseMatrixT & RES)
1321 typedef typename SparseMatrixT::value_type
ScalarType;
1322 typedef typename SparseMatrixT::iterator1 InternalRowIterator;
1323 typedef typename SparseMatrixT::iterator2 InternalColIterator;
1327 RES = SparseMatrixT(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;
1347 RES.add(static_cast<unsigned int>(x),static_cast<unsigned int>(z),prod);
1358 template<
typename SparseMatrixT>
1361 typedef typename SparseMatrixT::value_type
ScalarType;
1362 typedef typename SparseMatrixT::iterator1 InternalRowIterator;
1363 typedef typename SparseMatrixT::iterator2 InternalColIterator;
1367 RES = SparseMatrixT(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 (static_cast<unsigned int>(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 (static_cast<unsigned int>(x), static_cast<unsigned int>(z), *col_iter3 * *iter);
1405 #ifdef VIENNACL_AMG_DEBUG
1406 std::cout <<
"Galerkin Operator: " << std::endl;
1416 template<
typename SparseMatrixT>
1419 typedef typename SparseMatrixT::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 SparseMatrixT,
typename Po
intVectorT>
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;
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 [...