pv/scipy-work forked from scipy/scipy

Subversion checkout URL

You can clone with
or
.

MAINT: special: move also orthogonal_eval ufuncs to the new ufunc system

commit e76714514a06009e99690bd6962e5c821a3abc45 1 parent 401e69d
authored
1  .gitattributes
 @@ -19,6 +19,5 @@ scipy/spatial/ckdtree.c binary scipy/spatial/qhull.c binary scipy/special/_ufuncs.c binary scipy/special/_ufuncs_cxx.c binary -scipy/special/orthogonal_eval.c binary scipy/stats/_rank.c binary scipy/stats/vonmises_cython.c binary
 @@ -0,0 +1,36 @@ +""" +Evaluate orthogonal polynomial values using recurrence relations. + +References +---------- + +.. [AMS55] Abramowitz & Stegun, Section 22.5. + +.. [MH] Mason & Handscombe, Chebyshev Polynomials, CRC Press (2003). + +""" +# +# Copyright (C) 2009 Pauli Virtanen +# Distributed under the same license as Scipy. +# + +#------------------------------------------------------------------------------ +# Direct evaluation of polynomials +#------------------------------------------------------------------------------ + +from libc.math import sqrt + +cdef inline double eval_poly_chebyt(long k, double x) nogil: charris added a note Oct 10, 2012 I'm curious as to why the Chebyshev functions of the first kind are computed using Chebyshev functions of the second kind and the identity `T_n = (U_n - U_{n-2})/2`. I would think it would be less accurate as you can end up differencing large numbers. Am I missing something? charris added a note Oct 10, 2012 Nevermind, I got it figured out. to join this conversation on GitHub. Already have an account? Sign in to comment + # Use Chebyshev T recurrence directly, see [MH] + cdef long m + cdef double b2, b1, b0 + + b2 = 0 + b1 = -1 + b0 = 0 + x = 2*x + for m in range(k+1): + b2 = b1 + b1 = b0 + b0 = x*b1 - b2 + return (b0 - b2)/2.0