star-wf

First-passage time of brownian motion
git clone git://git.meso-star.fr/star-wf.git
Log | Files | Refs | README | LICENSE

commit 8803c687c1434fcb67c5d9b508d99fdd93b7bb7f
parent 63b2eb872bc292e637a75e6919a2d8ab3024f295
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed,  6 Mar 2024 16:25:11 +0100

Correction of the swf_tabulation function

The number of function arguments to be tabulated was confused with the
number of tabulation intervals.

Diffstat:
Msrc/swf_H.c | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/swf_H.c b/src/swf_H.c @@ -94,9 +94,10 @@ swf_H3d_tabulate if((res = check_swf_H_tabulate_args(args)) != RES_OK) goto error; if((res = tabulation_create(args->allocator, &tab)) != RES_OK) goto error; - /* Calculate the number of x arguments to be tabulated */ + /* Calculate the number of arguments x to be tabulated. Note that there is one + * more argument than the number of intervals, hence the +1 */ x_range = args->x_max - args->x_min; - nitems = (size_t)((x_range + args->delta_x/*round up*/) / args->delta_x); + nitems = (size_t)ceil(x_range / args->delta_x) + 1; /* Tabulation memory space allocation */ if((res = darray_item_resize(&tab->items, nitems)) != RES_OK) goto error; @@ -107,7 +108,7 @@ swf_H3d_tabulate items[i].x = MMIN(args->x_min + (double)i*args->delta_x, args->x_max); items[i].f_x = swf_H3d_eval(items[i].x); } - ASSERT(items[i].x == args->x_max); + ASSERT(items[nitems-1].x == args->x_max); /* Normalize the tabulation */ norm = items[nitems - 1].f_x;