1 #ifndef VIENNACL_LINALG_DETAIL_AMG_AMG_COARSE_HPP
2 #define VIENNACL_LINALG_DETAIL_AMG_AMG_COARSE_HPP
29 #ifdef VIENNACL_WITH_OPENMP
51 template <
typename InternalType1,
typename InternalType2,
typename InternalType3>
52 void amg_coarse(
unsigned int level, InternalType1 & A, InternalType2 & Pointvector, InternalType3 & Slicing,
amg_tag & tag)
70 template <
typename InternalType1,
typename InternalType2>
71 void amg_influence(
unsigned int level, InternalType1
const & A, InternalType2 & Pointvector,
amg_tag & tag)
73 typedef typename InternalType1::value_type SparseMatrixType;
74 typedef typename InternalType2::value_type PointVectorType;
75 typedef typename SparseMatrixType::value_type ScalarType;
76 typedef typename SparseMatrixType::value_type ScalarType;
77 typedef typename SparseMatrixType::const_iterator1 ConstRowIterator;
78 typedef typename SparseMatrixType::const_iterator2 ConstColIterator;
84 #ifdef VIENNACL_WITH_OPENMP
85 #pragma omp parallel for private (max,diag_sign)
87 for (
long i=0; i<static_cast<long>(A[level].size1()); ++i)
90 if (A[level](i,i) < 0)
93 ConstRowIterator row_iter = A[level].begin1();
97 for (ConstColIterator col_iter = row_iter.begin(); col_iter != row_iter.end(); ++col_iter)
99 if (i == (
unsigned int) col_iter.index2())
continue;
101 if (max > *col_iter) max = *col_iter;
103 if (max < *col_iter) max = *col_iter;
111 for (ConstColIterator col_iter = row_iter.begin(); col_iter != row_iter.end(); ++col_iter)
113 unsigned int j =
static_cast<unsigned int>(col_iter.index2());
114 if (i == j)
continue;
115 if (diag_sign * (-*col_iter) >= tag.
get_threshold() * (diag_sign * (-max)))
118 Pointvector[level][i]->add_influencing_point(Pointvector[level][j]);
123 #ifdef VIENNACL_AMG_DEBUG
124 std::cout <<
"Influence Matrix: " << std::endl;
125 boost::numeric::ublas::matrix<bool> mat;
126 Pointvector[level].get_influence_matrix(mat);
131 for (
typename PointVectorType::iterator iter = Pointvector[level].begin(); iter != Pointvector[level].end(); ++iter)
133 for (
typename amg_point::iterator iter2 = (*iter)->begin_influencing(); iter2 != (*iter)->end_influencing(); ++iter2)
135 (*iter2)->add_influenced_point(*iter);
139 #ifdef VIENNACL_AMG_DEBUG
140 std::cout <<
"Influence Measures: " << std::endl;
141 boost::numeric::ublas::vector<unsigned int> temp;
142 Pointvector[level].get_influence(temp);
144 std::cout <<
"Point Sorting: " << std::endl;
145 Pointvector[level].get_sorting(temp);
156 template <
typename InternalType1,
typename InternalType2>
166 #ifdef VIENNACL_WITH_OPENMP
167 #pragma omp parallel for private (i)
169 for (i=0; i<static_cast<long>(Pointvector[level].size()); ++i)
170 Pointvector[level][i]->calc_influence();
173 Pointvector[level].sort();
176 while ((c_point = Pointvector[level].get_nextpoint()) != NULL)
179 Pointvector[level].make_cpoint(c_point);