star-wf

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

commit 6bf96511daec4f6f485dbc8e31c8ed8e778260c1
parent c1f7ca86fad7b1f0fa562ffe54873b0589c80acc
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed,  6 Mar 2024 18:59:34 +0100

H-function inversion test based on tabulation

In fact, this is just a basic but wicked test that checks the relative
error of inversion in the most difficult part for tabulation, i.e. very
close to 0 (i.e. 1e-12).

Diffstat:
Msrc/test_swf_H3d.c | 18++++++++++++++++++
1 file changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/test_swf_H3d.c b/src/test_swf_H3d.c @@ -58,6 +58,23 @@ check_tabulation_creation(void) CHK(swf_tabulation_ref_put(tab) == RES_OK); } +static void +check_tabulation_inversion(void) +{ + struct swf_tabulation* tab = NULL; + double x, y, ref, err; + + CHK(swf_H3d_tabulate(&SWF_H_TABULATE_ARGS_DEFAULT, &tab) == RES_OK); + + y = 1e-12; + x = swf_tabulation_inverse(tab, y); + ref = swf_H3d_eval(x); + err = fabs((ref - y) / ref); + CHK(err < 1.e-4); + + CHK(swf_tabulation_ref_put(tab) == RES_OK); +} + /******************************************************************************* * The test ******************************************************************************/ @@ -66,6 +83,7 @@ main(int argc, char** argv) { (void)argc, (void)argv; check_tabulation_creation(); + check_tabulation_inversion(); CHK(mem_allocated_size() == 0); return 0; }