[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gsl] Chebyshev series derivatives
From: |
Brian Gough |
Subject: |
Re: [Bug-gsl] Chebyshev series derivatives |
Date: |
Tue, 09 Mar 2010 20:28:08 +0000 |
User-agent: |
Wanderlust/2.14.0 (Africa) Emacs/22.2 Mule/5.0 (SAKAKI) |
At Wed, 3 Mar 2010 10:03:27 +0100,
Jerry Gagelman wrote:
> I have found that the function gsl_cheb_calc_deriv() issues a segmentation
> fault when both the Chebyshev series and the series for its derivative are
> allocated for order N=1. No other value of N seems to effect the same error.
> There are two different installations of the GSL that I use at home versus
> at work: GSL 1.11 on Linux OpenSUSE 11.0, and GSL 1.12 on OS X 10.6
> (installed via macports). The test code that I have included below produces
> the same error on both systems.
Thanks for the bug report and example program. I've confirmed the
problem and logged it at https://savannah.gnu.org/bugs/index.php?29139
There is a loop which does not handle the case n=1 properly. A patch
is below and will be committed to the repository.
--
Brian Gough
GNU Scientific Library -
http://www.gnu.org/software/gsl/
diff --git a/cheb/deriv.c b/cheb/deriv.c
index 757d09f..8f7c223 100644
--- a/cheb/deriv.c
+++ b/cheb/deriv.c
@@ -49,10 +49,8 @@ int gsl_cheb_calc_deriv(gsl_cheb_series * deriv, const
gsl_cheb_series * f)
if(n > 1) {
deriv->c[n-2] = 2.0 *(n-1.0) * f->c[n-1];
- for(i = n-3; i>0; i--)
- deriv->c[i] = deriv->c[i+2] + 2.0 *(i+1.0) * f->c[i+1];
-
- deriv->c[0] = deriv->c[2] + 2.0 * f->c[1];
+ for(i = n; i>=3; i--)
+ deriv->c[i-3] = deriv->c[i-1] + 2.0 *(i-2.0) * f->c[i-2];
for(i = 0 ; i<n ; i++)
deriv->c[i] *= con;