commit df84d920ce36685da27be3057378f5f5fa92133f
parent c97cb074257507fb1fc001790b6dd9cee31d7270
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 14 Mar 2016 16:27:36 +0100
Return an error if the phase function cannot be inversed
Diffstat:
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/sschiff_estimator.c b/src/sschiff_estimator.c
@@ -989,11 +989,13 @@ inverse_cumulative_phase_function
nsmall_angles = estimator->limit_angles[iwlen];
if(cumulative < cumulative_small_angles[nsmall_angles-1]) {
- /* Look for the the cumulative in the filtered small angles array */
+ /* Look for the cumulative in the filtered small angles array */
double* found = search_lower_bound(&cumulative, cumulative_small_angles,
nsmall_angles, sizeof(double), cmp_double);
if(!found) {
- FATAL("Error in inverting the phase function cumulative for small angles.\n");
+ log_error(estimator->dev,
+ "Error in inverting the phase function cumulative for small angles.\n");
+ return RES_BAD_OP;
}
iangle = (size_t)(found - cumulative_small_angles);
upper = cumulative_small_angles[iangle];
@@ -1012,7 +1014,9 @@ inverse_cumulative_phase_function
nangles - nsmall_angles,
sizeof(struct sschiff_state), cmp_schiff_state);
if(!found) {
- FATAL("Error in inverting the phase function cumulative for wide angles.\n");
+ log_error(estimator->dev,
+ "Error in inverting the phase function cumulative for wide angles.\n");
+ return RES_BAD_OP;
}
iangle = (size_t)(found - estimator->phase_functions[iwlen].cumulative);
ASSERT(iangle >= nsmall_angles);
@@ -1794,8 +1798,9 @@ sschiff_estimator_inverse_cumulative_phase_function
/* TODO since the submitted cumulative are strictly increasing, one can
* speed up the inversion by using the previous search result to reduce the
* search domain in the cumulative arrays */
- inverse_cumulative_phase_function
+ res = inverse_cumulative_phase_function
(estimator, cumulative_small_angles, iwlen, cumulative, &thetas[itheta]);
+ if(res != RES_OK) goto error;
cumulative += step;
}