/* check_test_4d.c check every derivative function */ #include #include #include #include "deriv.h" #include "test_4d.h" #undef abs #define abs(x) ((x)<0.0?(-(x)):(x)) #undef max #define max(x,y) ((x)>(y)?(x):(y)) static double xg[10]; static double yg[10]; static double zg[10]; static double tg[10]; static double hx, hy, hz, ht; static int nx, ny, nz, nt; static double xmin, xmax, ymin, ymax, zmin, zmax, tmin, tmax; static double maxerror, gmaxerror; void check(char name[], double(* deriv)(double x, double y, double z, double t), int points, int xord, int yord, int zord, int tord) { double cx[10], cy[10], cz[10], ct[10]; double p1[10], p2[10], p3[10]; double analytic, discrete; double error, sum_error; int i, ii, iii, iiii; int j, jj, jjj, jjjj; double x, y, z, t, xx; maxerror = 0.0; for(i=0; i0.001 && i==0 && ii==0 && iii==0 && iiii==0) printf("analytic=%f, discrete=%f, error=%g \n", analytic, discrete, error); } /* end iiii for t */ } /* end iii for z */ } /* end ii for y */ } /* end i for x */ printf(" %s maxerror=%g\n", name, maxerror); gmaxerror = max(maxerror,gmaxerror); } /* end check */ int main(int argc, char *argv[]) { int i; xmin = -1.0; xmax = 1.0; ymin = -1.0; ymax = 1.0; zmin = -1.0; zmax = 1.0; tmin = -1.0; tmax = 1.0; nx = 5; ny = 5; nz = 5; nt = 5; hx = (xmax-xmin)/(double)(nx-1); hy = (ymax-ymin)/(double)(ny-1); hz = (zmax-zmin)/(double)(nz-1); ht = (tmax-tmin)/(double)(nt-1); for(i=0; i