From: Martin Kronbichler Date: Sat, 30 May 2009 09:53:57 +0000 (+0000) Subject: Put polynomial evaluation with Horner scheme to h file in order to let compilers... X-Git-Tag: v8.0.0~7649 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c824ecd85cfccea84e868865008f18a0ac9f5006;p=dealii.git Put polynomial evaluation with Horner scheme to h file in order to let compilers inline it. git-svn-id: https://svn.dealii.org/trunk@18888 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/polynomial.h b/deal.II/base/include/base/polynomial.h index ce83e871c8..0dfaf086c6 100644 --- a/deal.II/base/include/base/polynomial.h +++ b/deal.II/base/include/base/polynomial.h @@ -562,6 +562,24 @@ namespace Polynomials Assert (coefficients.size()>0, ExcEmptyObject()); return coefficients.size() - 1; } + + + + template + inline + number + Polynomial::value (const number x) const + { + Assert (coefficients.size() > 0, ExcEmptyObject()); + const unsigned int m=coefficients.size(); + + // Horner scheme + number value = coefficients.back(); + for (int k=m-2; k>=0; --k) + value = value*x + coefficients[k]; + + return value; + } } DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/base/source/polynomial.cc b/deal.II/base/source/polynomial.cc index 7dca20bafd..a460dc75be 100644 --- a/deal.II/base/source/polynomial.cc +++ b/deal.II/base/source/polynomial.cc @@ -52,23 +52,6 @@ namespace Polynomials - template - number - Polynomial::value (const number x) const - { - Assert (coefficients.size() > 0, ExcEmptyObject()); - const unsigned int m=coefficients.size(); - - // Horner scheme - number value = coefficients.back(); - for (int k=m-2; k>=0; --k) - value = value*x + coefficients[k]; - - return value; - } - - - template void Polynomial::value (const number x, diff --git a/deal.II/base/source/tensor_product_polynomials.cc b/deal.II/base/source/tensor_product_polynomials.cc index 4fee35a7b5..0d9155fbc5 100644 --- a/deal.II/base/source/tensor_product_polynomials.cc +++ b/deal.II/base/source/tensor_product_polynomials.cc @@ -23,6 +23,7 @@ DEAL_II_NAMESPACE_OPEN /* ------------------- TensorProductPolynomials -------------- */ template <> +inline void TensorProductPolynomials<1>:: compute_index (const unsigned int i, @@ -35,6 +36,7 @@ compute_index (const unsigned int i, template <> +inline void TensorProductPolynomials<2>:: compute_index (const unsigned int i, @@ -51,6 +53,7 @@ compute_index (const unsigned int i, template <> +inline void TensorProductPolynomials<3>:: compute_index (const unsigned int i,