diff options
author | Thomas White <taw@physics.org> | 2017-12-21 15:28:19 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2018-02-27 17:12:42 +0100 |
commit | 715357b3698c89bc4b238131dba1d4f2aba4328c (patch) | |
tree | 19dad7cb28e0c894131b5ce4a1797f25df698b66 | |
parent | 27fa902d7b7875de89e8eb1536812000f0a45889 (diff) |
Use GSL_NAN instead of infinity to indicate failed function evaluation
This is what the GSL manual says should be done.
-rw-r--r-- | src/post-refinement.c | 13 |
1 files 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; i<v->size; 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); |