<commit_before>"""
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 <NAME>
# Distributed under the same license as Scipy.
#

#------------------------------------------------------------------------------
# Direct evaluation of polynomials
#------------------------------------------------------------------------------

cdef extern from "math.h":
    double sqrt(double x)

cdef double eval_poly_chebyt(long k, double x):
    # 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, 0, -1):
        b2 = b1
        b1 = b0
        b0 = x*b1 - b2
    return (b0 - b2)/2.0

#------------------------------------------------------------------------------
# Ufunc boilerplate
#------------------------------------------------------------------------------

cdef extern from "numpy/arrayobject.h":
    void import_array()
    ctypedef int npy_intp
    cdef enum NPY_TYPES:
        NPY_LONG
        NPY_DOUBLE

cdef extern from "numpy/ufuncobject.h":
    void import_ufunc()
    ctypedef void (*PyUFuncGenericFunction)(char**, npy_intp*, npy_intp*, void*)
    object PyUFunc_FromFuncAndData(PyUFuncGenericFunction* func, void** data,
                                   char* types, int ntypes, int nin, int nout,
                                   int identity, char* name, char* doc, int c)

cdef void _loop_id_d(char **args, npy_intp *dimensions, npy_intp *steps,
                     void *func):
    cdef int i
    cdef double x
    cdef char *ip1=args[0], *ip2=args[1], *op=args[2]
    for i in range(0, dimensions[0]):
        (<double*>op)[0] = (<double(*)(int,double)>func)(
            (<int*>ip1)[0], (<double*>ip2)[0])
        ip1 += steps[0]; ip2 += steps[1]; op += steps[2]

cdef char _id_d_types[3]<commit_msg>BUG: special: fix int vs. long issue in orthogonal_eval.pyx<commit_after>"""
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 <NAME>
# Distributed under the same license as Scipy.
#

#------------------------------------------------------------------------------
# Direct evaluation of polynomials
#------------------------------------------------------------------------------

cdef extern from "math.h":
    double sqrt(double x)

cdef double eval_poly_chebyt(long k, double x):
    # 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, 0, -1):
        b2 = b1
        b1 = b0
        b0 = x*b1 - b2
    return (b0 - b2)/2.0

#------------------------------------------------------------------------------
# Ufunc boilerplate
#------------------------------------------------------------------------------

cdef extern from "numpy/arrayobject.h":
    void import_array()
    ctypedef int npy_intp
    cdef enum NPY_TYPES:
        NPY_LONG
        NPY_DOUBLE

cdef extern from "numpy/ufuncobject.h":
    void import_ufunc()
    ctypedef void (*PyUFuncGenericFunction)(char**, npy_intp*, npy_intp*, void*)
    object PyUFunc_FromFuncAndData(PyUFuncGenericFunction* func, void** data,
                                   char* types, int ntypes, int nin, int nout,
                                   int identity, char* name, char* doc, int c)

cdef void _loop_id_d(char **args, npy_intp *dimensions, npy_intp *steps,
                     void *func):
    cdef int i
    cdef double x
    cdef char *ip1=args[0], *ip2=args[1], *op=args[2]
    for i in range(0, dimensions[0]):
        (<double*>op)[0] = (<double(*)(long,double)>func)(
            (<long*>ip1)[0], (<double*>ip2)[0])
        ip1 += steps[0]; ip2 += steps[1]; op += steps[2]

cdef char _id_d_types[3]
{'fraction_non_alphanumeric': 0.2621741269060502, 'fraction_numerical': 0.02705361534677816, 'mean_word_length': 1.5245189323401613, 'pattern_counts': {'":': 6, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4102694', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1235, 'n_words': 361}