Silent NAN (with warning) instead of crash for singular Bessel at zero

This commit is contained in:
Marek Nečada 2020-11-17 10:30:56 +02:00
parent 3479721455
commit cf2aca7f03
1 changed files with 5 additions and 0 deletions

View File

@ -52,6 +52,11 @@ static inline complex double spherical_yn(qpms_l_t l, complex double z) {
qpms_errno_t qpms_sph_bessel_realx_fill(qpms_bessel_t typ, qpms_l_t lmax, double x, complex double *result_array) { qpms_errno_t qpms_sph_bessel_realx_fill(qpms_bessel_t typ, qpms_l_t lmax, double x, complex double *result_array) {
int retval; int retval;
double tmparr[lmax+1]; double tmparr[lmax+1];
if (typ != QPMS_BESSEL_REGULAR && x == 0) {
for (int l = 0; l <= lmax; ++l) result_array[l] = NAN + I*NAN;
QPMS_WARN("Evaluating singular Bessel functions at zero!");
return QPMS_SUCCESS; // Really?
}
switch(typ) { switch(typ) {
case QPMS_BESSEL_REGULAR: case QPMS_BESSEL_REGULAR:
retval = gsl_sf_bessel_jl_steed_array(lmax, x, tmparr); retval = gsl_sf_bessel_jl_steed_array(lmax, x, tmparr);