From: Rene Gassmoeller Date: Fri, 19 Aug 2016 17:57:27 +0000 (-0600) Subject: Address comments X-Git-Tag: v8.5.0-rc1~753^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d3621e277c42151452c495525b2faecd50f7ae6;p=dealii.git Address comments --- diff --git a/include/deal.II/base/quadrature_lib.h b/include/deal.II/base/quadrature_lib.h index e3e530ba63..eeb491d347 100644 --- a/include/deal.II/base/quadrature_lib.h +++ b/include/deal.II/base/quadrature_lib.h @@ -436,15 +436,19 @@ class QSorted : public Quadrature { public: /** - * The constructor takes an arbitrary quadrature formula. + * The constructor takes an arbitrary quadrature formula @p quad and sorts + * its points and weights according to ascending weights. */ QSorted (const Quadrature &quad); +private: /** - * A rule to reorder pairs of points and weights. + * A rule for std::sort to reorder pairs of points and weights. + * @p a and @p b are indices into the weights array and the result will + * be determined by comparing the weights. */ - bool operator()(const std::size_t &a, - const std::size_t &b) const; + bool compare_weights(const unsigned int a, + const unsigned int b) const; }; /** diff --git a/source/base/quadrature_lib.cc b/source/base/quadrature_lib.cc index e9c961c1b2..107f851fbb 100644 --- a/source/base/quadrature_lib.cc +++ b/source/base/quadrature_lib.cc @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -935,9 +936,16 @@ template QSorted::QSorted(const Quadrature &quad) : Quadrature(quad) { - std::vector permutation(quad.size()); - std::iota(permutation.begin(), permutation.end(), 0); - std::sort(permutation.begin(), permutation.end(), *this); + std::vector permutation(quad.size()); + for (unsigned int i=0; i::compare_weights, + std_cxx11::ref(*this), + std_cxx11::_1, + std_cxx11::_2)); for (unsigned int i=0; i::QSorted(const Quadrature &quad) : template -bool QSorted::operator()(const std::size_t &a, - const std::size_t &b) const +bool QSorted::compare_weights(const unsigned int a, + const unsigned int b) const { return (this->weights[a] < this->weights[b]); }