From da5f0c5d32db135e9bf18fdea2238e0ce715ce4c Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 30 Apr 2001 16:59:17 +0000 Subject: [PATCH] Fix bug: if we take values and derivatives of functions that are low order polynomials, we get into situations where all higher derivatives are zero. Don't read beyond the end of the array in that case. git-svn-id: https://svn.dealii.org/trunk@4511 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/source/polynomial.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/deal.II/base/source/polynomial.cc b/deal.II/base/source/polynomial.cc index 7b4396b588..df160e3161 100644 --- a/deal.II/base/source/polynomial.cc +++ b/deal.II/base/source/polynomial.cc @@ -75,14 +75,26 @@ Polynomial::value (const number x, const unsigned int m=coefficients.size(); std::vector a(coefficients); unsigned int j_faculty=1; - for (unsigned int j=0; jm} are + // necessarily zero, as they + // differentiate the polynomial + // more often than the highest + // power is + for (unsigned int j=0; j=static_cast(j); --k) a[k]+=x*a[k+1]; values[j]=j_faculty*a[j]; j_faculty*=j+1; } + + // fill higher derivatives by zero + for (unsigned int j=std::min(values_size,m); j