diff --git a/jplephem/__init__.py b/jplephem/__init__.py index f2b1a8c..0e2e6a1 100644 --- a/jplephem/__init__.py +++ b/jplephem/__init__.py @@ -353,8 +353,10 @@ Changelog **2019 December 13 — Version 2.11** -* Reverse the order in which the PCK Chebyshev polynomial is computed to - gain a partial digit of extra precision. +* Reverse the order in which Chebyshev polynomials are computed to + slightly increase speed, to simplify the code, and in one case + (comparing PCK output to NASA) to gain a partial digit of extra + precision. **2019 December 11 — Version 2.10** diff --git a/jplephem/pck.py b/jplephem/pck.py index 8c1d75c..e1d5894 100644 --- a/jplephem/pck.py +++ b/jplephem/pck.py @@ -150,8 +150,7 @@ class Segment(object): coefficients = coefficients[:,:,index] - # Chebyshev polynomial. We accumulate results starting with the - # final coefficient to retain accuracy for as long as possible. + # Chebyshev polynomial. s = 2.0 * offset / intlen - 1.0 s2 = 2.0 * s @@ -162,7 +161,7 @@ class Segment(object): w2 = w1 w1 = w0 w0 = coefficient + (s2 * w1 - w2) - if derivative: + if derivative: # TODO: defer to a second loop dw2 = dw1 dw1 = dw0 dw0 = 2.0 * w1 + dw1 * s2 - dw2 diff --git a/jplephem/spk.py b/jplephem/spk.py index 8ee7d78..f3ca73b 100644 --- a/jplephem/spk.py +++ b/jplephem/spk.py @@ -236,13 +236,12 @@ class Segment(BaseSegment): coefficients = coefficients[:,:,index] - # Chebyshev polynomial. We accumulate results starting with the - # final coefficient to retain accuracy for as long as possible. + # Chebyshev polynomial. s = 2.0 * offset / intlen - 1.0 s2 = 2.0 * s - w0 = w1 = dw0 = dw1 = 0.0 + w0 = w1 = 0.0 wlist = [] for coefficient in coefficients[:-1]: @@ -260,6 +259,8 @@ class Segment(BaseSegment): # Chebyshev differentiation. + dw0 = dw1 = 0.0 + for coefficient, w1 in zip(coefficients[:-1], wlist): dw2 = dw1 dw1 = dw0 diff --git a/setup.py b/setup.py index e098969..d7ed54a 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ import jplephem description, long_description = jplephem.__doc__.split('\n', 1) setup(name = 'jplephem', - version = '2.10', + version = '2.11', description = description, long_description = long_description, license = 'MIT',