• S
    math: bessel cleanup (jn.c and jnf.c) · 5652d700
    Szabolcs Nagy 提交于
    both jn and yn functions had integer overflow issues for large
    and small n
    
    to handle these issues nm1 (== |n|-1) is used instead of n and -n
    in the code and some loops are changed to make sure the iteration
    counter does not overflow
    
    (another solution could be to use larger integer type or even double
    but that has more size and runtime cost, on x87 loading int64_t or
    even uint32_t into an fpu register is more than two times slower than
    loading int32_t, and using double for n slows down iteration logic)
    
    yn(-1,0) now returns inf
    
    posix2008 specifies that on overflow and at +-0 all y0,y1,yn functions
    return -inf, this is not consistent with math when n<0 odd integer in yn
    (eg. when x->0, yn(-1,x)->inf, but historically yn(-1,0) seems to be
    special cased and returned -inf)
    
    some threshold values in jnf and ynf were fixed that seems to be
    incorrectly copy-pasted from the double version
    5652d700
jnf.c 4.4 KB