From 715357b3698c89bc4b238131dba1d4f2aba4328c Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 21 Dec 2017 15:28:19 +0100 Subject: Use GSL_NAN instead of infinity to indicate failed function evaluation This is what the GSL manual says should be done. --- src/post-refinement.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/post-refinement.c b/src/post-refinement.c index be69b36e..cf508cdb 100644 --- a/src/post-refinement.c +++ b/src/post-refinement.c @@ -93,7 +93,7 @@ double residual(Crystal *cr, const RefList *full, int free, UnitCell *cell = crystal_get_cell(cr); if ( linear_scale(full, crystal_get_reflections(cr), &G, complain) ) { - return INFINITY; + return GSL_NAN; } for ( refl = first_refl(crystal_get_reflections(cr), &iter); @@ -290,7 +290,7 @@ static double residual_f(const gsl_vector *v, void *pp) int i; for ( i=0; isize; i++ ) { - if ( gsl_vector_get(v, i) > 100.0 ) return INFINITY; + if ( gsl_vector_get(v, i) > 100.0 ) return GSL_NAN; } cr = crystal_copy(pv->cr); @@ -300,7 +300,7 @@ static double residual_f(const gsl_vector *v, void *pp) if ( crystal_get_profile_radius(cr) <= 0.0 ) { crystal_free(cr); - return INFINITY; + return GSL_NAN; } list = copy_reflist(crystal_get_reflections(cr)); @@ -311,13 +311,6 @@ static double residual_f(const gsl_vector *v, void *pp) res = residual(cr, pv->full, 0, NULL, NULL, 0); - if ( isnan(res) ) { - ERROR("NaN residual\n"); - ERROR("G=%e, B=%e\n", crystal_get_osf(cr), crystal_get_Bfac(cr)); - residual(cr, pv->full, 0, NULL, "nan-residual.dat", 1); - abort(); - } - cell_free(crystal_get_cell(cr)); reflist_free(crystal_get_reflections(cr)); crystal_free(cr); -- cgit v1.2.3