1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
/* Library libcerf:
* Compute complex error functions, based on a new implementation of
* Faddeeva's w_of_z. Also provide Dawson and Voigt functions.
*
* File imwofx.c:
* Test the function imwofx.
*
* Copyright:
* (C) 2025 Forschungszentrum Jülich GmbH
*
* Licence:
* ../LICENSE
*
* Authors:
* Joachim Wuttke, Forschungszentrum Jülich, 2013
*
* Website:
* http://apps.jcns.fz-juelich.de/libcerf
*
* Revision history:
* ../CHANGELOG
*/
#ifdef __cplusplus
#include <cassert>
#else
#include <assert.h>
#endif
#include <math.h>
#include <stdio.h>
#include "cerf.h"
#include "auto_test_imwofx.c" // Generated by the PPAPP code generator.
int test_one(double x, double fref)
{
double fappr = im_w_of_x(x);
double relerr = fabs((fappr-fref) / fref) / pow(2.,-53);
if (relerr > ppapp_maxrelerr) {
printf("x=%23.16e -> fref=%23.16e fappr=%23.16e relerr/eps=%8g tol=%8g\n",
x, fref, fappr, relerr, ppapp_maxrelerr);
return 1;
}
return 0;
}
//! Program run_computation.
//! Writes a table of some representative x and f(x), the latter computed in polynomial approximation.
int main() {
int failed = run_tests();
if (failed) {
printf("test_computation: %d test cases failed\n", failed);
return 1;
}
return 0;
}
|