R PNX(bessel_i0)(R x) { /* forward to GSL implementation */ return (R)gsl_sf_bessel_I0((double)x); if (x < 0) { /* even function */ x = -x; } if (x < PNFFT_EPSILON) return K(1.0); if (x <= K(15.0)) { /* x in (0, 15] */ // const R y = x*x/K(112.5) - K(1.0); /* use this if the Chebyshev approximation was computed on [0,225] */ const R y = x * x; /* use this if the Chebyshev approximation was computed on [-1,1] */ return evaluate_chebyshev(N1, P1, y) / evaluate_chebyshev(M1, Q1, y); } else { /* x in (15, \infty) */ const R y = (K(30.0) - x) / x; /* use this if the Chebyshev approximation was computed on [0,15] */ // const R y = K(1.0) / x; /* use this if the Chebyshev approximation was computed on [-1,1] */ return (pnfft_exp(x) / pnfft_sqrt(x)) * (evaluate_chebyshev(N2, P2, y) / evaluate_chebyshev(M2, Q2, y)); } }
fcs_float ifcs_p2nfft_gamma_ln( fcs_float x ) { /* Use a Chebyshev approximation on the interval [0,1] to * avoid numerical difficulties due to the opposite singularities * of Gamma[0,x] and Log[x]. */ if(x<1) return evaluate_chebyshev(N, P, x); return }