9 #include "../utils/interp.h"
11 #define DMAX(x,y) ((x) > (y) ? (x) : (y))
12 #define DMIN(x,y) ((x) < (y) ? (x) : (y))
19 return fmod(x+mod,mod);
34 for(i = 0; i <
DSIZE; i++) {
35 for(j = 0; j <
DSIZE; j++) {
36 ydata[i][j] = fabs((1. - j) * (1. - i));
37 ydata_sum[i][j] = i+j;
44 for(i = -0.4; i <=
DSIZE; i += 0.4) {
45 for(j = -0.4; j <=
DSIZE; j += 0.4) {
47 double y =
interp_eval(&ip, x, (
double*) ydata, status);
48 assert_true(status[0] == -1*(i < 0) + (i >
DSIZE-1));
49 assert_true(status[1] == -1*(j < 0) + (j >
DSIZE-1));
57 assert_true(fabs(y - y_truth) <= 1e-5*y);
58 assert_true(fabs(yp - y_truth) <= 1e-5*yp);
62 for(i = -0.4; i <= 3.0; i += 0.4) {
63 for(j = -0.4; j <= 3.0; j += 0.4) {
65 double y =
interp_eval(&ip, x, (
double*) ydata_sum, status);
71 if(i >= 0 && j >= 0 && i <=
DSIZE-1 && j <=
DSIZE-1)
72 assert_true(fabs(yp - yp_truth) <= 1e-5*yp);
73 assert_true(fabs(y - y_truth) <= 1e-5*y);
80 const struct CMUnitTest tests[] = {
83 return cmocka_run_group_tests_mpi(tests, NULL, NULL);
double interp_eval(Interp *obj, double *x, double *ydata, int *status)
void interp_init(Interp *obj, int Ndim, int64_t *dims)
void interp_destroy(Interp *obj)
void interp_init_dim(Interp *obj, int d, double Min, double Max)
double interp_eval_periodic(Interp *obj, double *x, double *ydata)
double modulus(double x, double mod)
static void test_interp(void **state)