// This function contributed by Andrew W. Steiner <*****@*****.**> int test_bicubic_nonlinear_nonsq() { int status; double xarr[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}; double yarr[] = {1.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0}; double zarr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 2, 6, 4, 10, 6, 14, 8, 11, 12, 3, 6, 3, 12, 15, 6, 21, 24, 13, 14, 4, 4, 12, 4, 20, 12, 28, 8, 15, 16, 5, 10, 15, 20, 5, 30, 35, 40, 17, 18, 6, 6, 6, 12, 30, 6, 42, 24, 19, 20, 7, 14, 21, 28, 35, 42, 7, 56, 21, 22, 8, 8, 24, 8, 40, 24, 56, 8, 23, 24}; double xval[] = {1.4, 2.3, 9.7, 3.3, 9.5, 6.6, 5.1}; double yval[] = {1.0, 1.8, 1.9, 2.5, 2.7, 4.1, 3.3}; // results computed using GSL 1D cubic interpolation twice double zval[]={1.4,2.46782030941187003,10.7717721621846465, 4.80725067958096375,11.6747032398627297, 11.2619968682970111,9.00168877916872567}; size_t xsize = sizeof(xarr) / sizeof(xarr[0]); size_t ysize = sizeof(yarr) / sizeof(yarr[0]); size_t test_size = sizeof(xval) / sizeof(xval[0]); status = test_interp2d(xarr, yarr, zarr, xsize, ysize, xval, yval, zval, NULL, NULL, NULL, NULL, NULL, test_size, interp2d_bicubic); gsl_test(status, "bicubic interpolation on nonlinear symmetric function"); return status; }
static int test_bicubic_nonlinear() { int status; double xarr[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}; double yarr[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}; /* least common multiple of x and y */ double zarr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 2, 2, 6, 4, 10, 6, 14, 8, 3, 6, 3, 12, 15, 6, 21, 24, 4, 4, 12, 4, 20, 12, 28, 8, 5, 10, 15, 20, 5, 30, 35, 40, 6, 6, 6, 12, 30, 6, 42, 24, 7, 14, 21, 28, 35, 42, 7, 56, 8, 8, 24, 8, 40, 24, 56, 8}; double xval[] = {1.4, 2.3, 4.7, 3.3, 7.5, 6.6, 5.1}; double yval[] = {1.0, 1.8, 1.9, 2.5, 2.7, 4.1, 3.3}; /* results computed using GSL 1D cubic interpolation twice */ double zval[] = { 1.4, 3.11183531264736, 8.27114315792559, 5.03218982537718, 22.13230634702637, 23.63206834997871, 17.28553080971182 }; size_t xsize = sizeof(xarr) / sizeof(xarr[0]); size_t ysize = sizeof(yarr) / sizeof(yarr[0]); size_t test_size = sizeof(xval) / sizeof(xval[0]); status = test_interp2d(xarr, yarr, zarr, xsize, ysize, xval, yval, zval, NULL, NULL, NULL, NULL, NULL, test_size, gsl_interp2d_bicubic); gsl_test(status, "bicubic interpolation on nonlinear symmetric function"); return status; }
/* * Tests bilinear interpolation with an asymmetric function, f(x,y)!=f(y,x), * and off-diagonal interpolation points (x,y) where x and y may or may not * be equal. */ static int test_bilinear_asymmetric_z() { int status; double xarr[] = {0.0, 1.0, 2.0, 3.0}; double yarr[] = {0.0, 1.0, 2.0, 3.0}; double zarr[] = {1.0, 1.1, 1.2, 1.4, 1.3, 1.4, 1.5, 1.7, 1.5, 1.6, 1.7, 1.9, 1.6, 1.9, 2.2, 2.3}; double xval[] = { 0.0, 0.5, 1.0, 1.5, 2.5, 3.0, 1.3954, 1.6476, 0.824957, 2.41108, 2.98619, 1.36485 }; double yval[] = {0.0, 0.5, 1.0, 1.5, 2.5, 3.0, 0.265371, 2.13849, 1.62114, 1.22198, 0.724681, 0.0596087 }; /* results computed using Mathematica 9.0.1.0 */ double zval[] = {1.0, 1.2, 1.4, 1.55, 2.025, 2.3, 1.2191513, 1.7242442248, 1.5067237, 1.626612, 1.6146423, 1.15436761}; size_t xsize = sizeof(xarr) / sizeof(xarr[0]); size_t ysize = sizeof(yarr) / sizeof(yarr[0]); size_t test_size = sizeof(xval) / sizeof(xval[0]); status = test_interp2d(xarr, yarr, zarr, xsize, ysize, xval, yval, zval, NULL, NULL, NULL, NULL, NULL, test_size, gsl_interp2d_bilinear); gsl_test(status, "bilinear interpolation with asymmetric z values"); return status; }
void test_bicubic() { int status; double xarr[] = {0.0, 1.0, 2.0, 3.0}; double yarr[] = {0.0, 1.0, 2.0, 3.0}; double zarr[] = {1.0, 1.1, 1.2, 1.3, 1.1, 1.2, 1.3, 1.4, 1.2, 1.3, 1.4, 1.5, 1.3, 1.4, 1.5, 1.6}; double xval[] = {1.0, 1.5, 2.0}; double yval[] = {1.0, 1.5, 2.0}; double zval[] = {1.2, 1.3, 1.4}; size_t xsize = sizeof(xarr) / sizeof(xarr[0]); size_t ysize = sizeof(yarr) / sizeof(yarr[0]); size_t test_size = sizeof(xval) / sizeof(xval[0]); status = test_interp2d(xarr, yarr, zarr, xsize, ysize, xval, yval, zval, NULL, NULL, NULL, NULL, NULL, test_size, interp2d_bicubic); gsl_test(status, "bicubic interpolation on linear function"); }
/** * Tests bilinear interpolation using a symmetric function, f(x,y)==f(y,x), * and diagonal interpolation points (x,y) where x==y. If these tests don't pass, * something is seriously broken. */ int test_bilinear_symmetric() { int status; double xarr[] = {0.0, 1.0, 2.0, 3.0}; double yarr[] = {0.0, 1.0, 2.0, 3.0}; double zarr[] = {1.0, 1.1, 1.2, 1.3, 1.1, 1.2, 1.3, 1.4, 1.2, 1.3, 1.4, 1.5, 1.3, 1.4, 1.5, 1.6}; double xval[] = {0.0, 0.5, 1.0, 1.5, 2.5, 3.0}; double yval[] = {0.0, 0.5, 1.0, 1.5, 2.5, 3.0}; double zval[] = {1.0, 1.1, 1.2, 1.3, 1.5, 1.6}; size_t xsize = sizeof(xarr) / sizeof(xarr[0]); size_t ysize = sizeof(yarr) / sizeof(yarr[0]); size_t test_size = sizeof(xval) / sizeof(xval[0]); status = test_interp2d(xarr, yarr, zarr, xsize, ysize, xval, yval, zval, NULL, NULL, NULL, NULL, NULL, test_size, interp2d_bilinear); gsl_test(status, "bilinear interpolation with symmetric values"); return status; }