/* test_nuderiv3d.c test nuderiv3d with 35 points */ /* order 1 minimum 4 independent points */ /* order 2 minimum 10 independent points */ /* order 3 minimum 20 independent points */ /* order 4 minimum 35 independent points */ #include #include #include "nuderiv3d.h" #undef abs #define abs(x) ((x)<0.0?(-(x)):(x)) #undef max #define max(x,y) ((x)>(y)?(x):(y)) static double f1(double x, double y, double z) { return x + 2.0*y + 3.0*z + 4.0; } static double fx1(double x, double y, double z) { return 1.0; } static double fy1(double x, double y, double z) { return 2.0; } static double fz1(double x, double y, double z) { return 3.0; } static double f2(double x, double y, double z) { return x*x + 2.0*x*y + 3.0*x*z + 4.0*y*y + 5.0*y*z + 6.0*z*z + 7.0*x + 8.0*y + 9.0*z + 10.0; } static double fx2(double x, double y, double z) { return 2.0*x + 2.0*y + 3.0*z + 7.0; } static double fy2(double x, double y, double z) { return 2.0*x + 8.0*y + 5.0*z + 8.0; } static double fz2(double x, double y, double z) { return 3.0*x + 5.0*y + 12.0*z + 9.0; } static double fxx2(double x, double y, double z) { return 2.0; } static double fxy2(double x, double y, double z) { return 2.0; } static double fxz2(double x, double y, double z) { return 3.0; } static double fyy2(double x, double y, double z) { return 8.0; } static double fyz2(double x, double y, double z) { return 5.0; } static double fzz2(double x, double y, double z) { return 12.0; } static double f3(double x, double y, double z) { return x*x*x + 2.0*x*x*y + 3.0*x*x*z + 4.0*x*y*y + 5.0*x*y*z + 6.0*x*z*z + 7.0*y*y*y + 8.0*y*y*z + 9.0*y*z*z + 10.0*z*z*z + 11.0*x*x + 12.0*x*y + 13.0*x*z + 14.0*y*y + 15.0*y*z + 16.0*z*z + 17.0*x + 18.0*y + 19.0*z + 20.0; } static double fx3(double x, double y, double z) { return 3.0*x*x + 4.0*x*y + 6.0*x*z + 4.0*y*y + 5.0*y*z + 6.0*z*z + 22.0*x + 12.0*y + 13.0*z + 17.0; } static double fy3(double x, double y, double z) { return 2.0*x*x + 8.0*x*y + 5.0*x*z + 21.0*y*y + 16.0*y*z + 9.0*z*z + 12.0*x + 28.0*y + 15.0*z + 18.0; } static double fz3(double x, double y, double z) { return 3.0*x*x + 5.0*x*y + 12.0*x*z + 8.0*y*y + 18.0*y*z + 30*z*z + 13.0*x + 15.0*y + 32.0*z + 19.0; } static double fxx3(double x, double y, double z) { return 6.0*x + 4.0*y + 6.0*z + 22.0; } static double fxy3(double x, double y, double z) { return 4.0*x + 8.0*y + 5.0*z + 12.0 ; } static double fxz3(double x, double y, double z) { return 6.0*x + 5.0*y + 12.0*z + 13.0; } static double fyy3(double x, double y, double z) { return 8.0*x + 42.0*y + 16.0*z + 28.0; } static double fyz3(double x, double y, double z) { return 5.0*x + 16.0*y + 18.0*z + 15.0; } static double fzz3(double x, double y, double z) { return 12.0*x + 18.0*y + 60.0*z + 32.0; } static double fxxx3(double x, double y, double z) { return 6.0; } static double fxxy3(double x, double y, double z) { return 4.0; } static double fxxz3(double x, double y, double z) { return 6.0; } static double fxyy3(double x, double y, double z) { return 8.0; } static double fxyz3(double x, double y, double z) { return 5.0; } static double fxzz3(double x, double y, double z) { return 12.0; } static double fyyy3(double x, double y, double z) { return 42.0; } static double fyyz3(double x, double y, double z) { return 16.0; } static double fyzz3(double x, double y, double z) { return 18.0; } static double fzzz3(double x, double y, double z) { return 60.0; } int main(int argc, char *argb[]) { int i, j; int debug = 0; int n; int order; double x[35] = {0.05, 0.14, 0.27, 0.42, 0.57, 0.71, 0.86, 0.04, 0.18, 0.31, 0.43, 0.63, 0.82, 0.95, 0.07, 0.16, 0.33, 0.41, 0.59, 0.82, 0.99, 0.11, 0.21, 0.35, 0.45, 0.65, 0.75, 0.97, 0.06, 0.17, 0.32, 0.46, 0.61, 0.79, 0.98}; double y[35] = {0.06, 0.05, 0.07, 0.10, 0.13, 0.15, 0.17, 0.30, 0.33, 0.36, 0.39, 0.31, 0.32, 0.37, 0.48, 0.49, 0.52, 0.51, 0.47, 0.50, 0.53, 0.65, 0.77, 0.71, 0.67, 0.67, 0.75, 0.76, 0.92, 0.97, 0.93, 0.98, 0.87, 0.91, 0.99}; double z[35] = {0.07, 0.28, 0.47, 0.69, 0.91, 0.15, 0.45, 0.68, 0.93, 0.05, 0.26, 0.50, 0.97, 0.08, 0.14, 0.39, 0.65, 0.76, 0.93, 0.27, 0.56, 0.82, 0.99, 0.11, 0.33, 0.72, 0.94, 0.09, 0.22, 0.65, 0.95, 0.10, 0.24, 0.42, 0.82}; double U[35]; double est, actual, dx, dy, dz; double cx[35], cy[35], cz[35], cxx[35], cxy[35], cxz[35]; double cyy[35], cyz[35], czz[35], cxxx[35], cxxy[35]; double cxxz[35], cxyy[35], cxyz[35], cxzz[35], cyyy[35], cyyz[35]; double cyzz[35], czzz[35]; double error, maxerr; int point; printf("test_nuderiv3d.c running \n"); printf("test f1 for dx, dy, dz \n"); n = 4; order = 1; for(i=0; i