commit b2e13a041398e7fdcd893840b2bac40d4c865f0f
parent dd387233f1c7799df72085899d823b91f25d69c3
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 8 Nov 2022 12:03:00 +0100
Small improvement in component sampling accuracy
Diffstat:
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/rnatm_properties.c b/src/rnatm_properties.c
@@ -1067,7 +1067,7 @@ rnatm_sample_component
size_t* cpnt)
{
cumulative_T cumul;
- double rcp_norm;
+ double norm;
size_t cumul_sz;
size_t i;
res_T res = RES_OK;
@@ -1082,15 +1082,15 @@ rnatm_sample_component
goto exit;
}
- res = compute_unnormalized_cumulative_radcoef
- (atm, args->radcoef, args->pos, args->iband, args->iquad, cumul, &cumul_sz);
+ res = compute_unnormalized_cumulative_radcoef(atm, args->radcoef, args->pos,
+ args->iband, args->iquad, cumul, &cumul_sz, -DBL_MAX, DBL_MAX);
if(res != RES_OK) goto error;
ASSERT(cumul_sz >= 1);
/* Normalize the cumulative */
- rcp_norm = 1.0/cumul[cumul_sz-1];
- FOR_EACH(i, 0, cumul_sz) cumul[i] *= rcp_norm;
- cumul[cumul_sz-1] = 1.0; /* Handle precision issues */
+ norm = cumul[cumul_sz-1];
+ FOR_EACH(i, 0, cumul_sz) cumul[i] /= norm;
+ cumul[cumul_sz-1] = 1.f; /* Handle precision issues */
/* Use a simple linear search to sample the component since there are
* usually very few aerosols to consider */