[bug-gsl] gsl_sf_bessel_Jn_e performance (2008-06-11)
|
From: |
Jonny Taylor <j.m.taylor@............> |
|
Subject: |
gsl_sf_bessel_Jn_e performance |
|
Date: |
Wed, 11 Jun 2008 12:31:39 +0100 |
|
To: |
bug-gsl@gnu.org |
Hi All,
I don't know what the policy is regarding optimizations which
(slightly) decrease code readability, but there's a simple change to
the downward recurrence in gsl_sf_bessel_Jn_e which doubles the speed
of the function (almost all the remaining time is spent in
gsl_sf_bessel_J_CF1) for n of order 10-40.
The modified code is listed below.
Cheers
Jonny
double twoInvX = 2.0 / x;
double kf;
for(k=n, kf=n; k>0; k--, kf--) {
Jkm1 = kf*twoInvX * Jk - Jkp1;
Jkp1 = Jk;
Jk = Jkm1;
}