# Maple code to compute 2-D Lagrange interpolation coefficients (orders 1-4) # $Id$ ################################################################################ # # interpolating functions # fn_2d_order1 := proc(x,y) + c01*y + c00 + c10*x end proc; fn_2d_order2 := proc(x,y) + c02*y^2 + c01*y + c11*x*y + c00 + c10*x + c20*x^2 end proc; fn_2d_order3 := proc(x,y) + c03*y^3 + c02*y^2 + c12*x*y^2 + c01*y + c11*x*y + c21*x^2*y + c00 + c10*x + c20*x^2 + c30*x^3 end proc; fn_2d_order4 := proc(x,y) + c04*y^4 + c03*y^3 + c13*x*y^3 + c02*y^2 + c12*x*y^2 + c22*x^2*y^2 + c01*y + c11*x*y + c21*x^2*y + c31*x^3*y + c00 + c10*x + c20*x^2 + c30*x^3 + c40*x^4 end; ######################################## # # coefficients in interpolating functions # coeff_list_2d_order1 := [ c01, c00, c10 ]; coeff_list_2d_order2 := [ c02, c01, c11, c00, c10, c20 ]; coeff_list_2d_order3 := [ c03, c02, c12, c01, c11, c21, c00, c10, c20, c30 ]; coeff_list_2d_order4 := [ c04, c03, c13, c02, c12, c22, c01, c11, c21, c31, c00, c10, c20, c30, c40 ]; ######################################## # # coordinates and interpolation points # coord_list_2d := [x,y]; # generate points in Fortran ordering posn_list_2d_size2 := map(ListTools[Reverse], hypercube_points([ 0, 0], [+1,+1])); posn_list_2d_size3 := map(ListTools[Reverse], hypercube_points([-1,-1], [+1,+1])); posn_list_2d_size4 := map(ListTools[Reverse], hypercube_points([-1,-1], [+2,+2])); posn_list_2d_size5 := map(ListTools[Reverse], hypercube_points([-2,-2], [+2,+2])); ################################################################################ # # generic stuff for 2d, cube, size=2 # data_var_list_2d_size2 := map(data_var_name, posn_list_2d_size2, "data_"); print_name_list_dcl(data_var_list_2d_size2, "fp", "2d.coeffs/2d.cube.size2/data-var.dcl.c"); print_data_var_assign(posn_list_2d_size2, "data_", "2d.coeffs/2d.cube.size2/data-var.assign.c"); print_interp_coeff_var_store(posn_list_2d_size2, "coeff_I_", "2d.coeffs/2d.cube.size2/coeff-I.store.c"); print_interp_coeff_var_store(posn_list_2d_size2, "coeff_dx_", "2d.coeffs/2d.cube.size2/coeff-dx.store.c"); print_interp_coeff_var_store(posn_list_2d_size2, "coeff_dy_", "2d.coeffs/2d.cube.size2/coeff-dy.store.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size2, "coeff_I_"), "fp", "2d.coeffs/2d.cube.size2/coeff-I.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size2, "coeff_dx_"), "fp", "2d.coeffs/2d.cube.size2/coeff-dx.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size2, "coeff_dy_"), "fp", "2d.coeffs/2d.cube.size2/coeff-dy.dcl.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size2, "result", "coeff_I_", "data_", "2d.coeffs/2d.cube.size2/interp-I.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size2, "result", "coeff_dx_", "data_", "2d.coeffs/2d.cube.size2/interp-dx.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size2, "result", "coeff_dy_", "data_", "2d.coeffs/2d.cube.size2/interp-dy.compute.c"); ######################################## # # generic stuff for 2d, cube, size=3 # data_var_list_2d_size3 := map(data_var_name, posn_list_2d_size3, "data_"); print_name_list_dcl(data_var_list_2d_size3, "fp", "2d.coeffs/2d.cube.size3/data-var.dcl.c"); print_data_var_assign(posn_list_2d_size3, "data_", "2d.coeffs/2d.cube.size3/data-var.assign.c"); print_interp_coeff_var_store(posn_list_2d_size3, "coeff_I_", "2d.coeffs/2d.cube.size3/coeff-I.store.c"); print_interp_coeff_var_store(posn_list_2d_size3, "coeff_dx_", "2d.coeffs/2d.cube.size3/coeff-dx.store.c"); print_interp_coeff_var_store(posn_list_2d_size3, "coeff_dy_", "2d.coeffs/2d.cube.size3/coeff-dy.store.c"); print_interp_coeff_var_store(posn_list_2d_size3, "coeff_dxx_", "2d.coeffs/2d.cube.size3/coeff-dxx.store.c"); print_interp_coeff_var_store(posn_list_2d_size3, "coeff_dxy_", "2d.coeffs/2d.cube.size3/coeff-dxy.store.c"); print_interp_coeff_var_store(posn_list_2d_size3, "coeff_dyy_", "2d.coeffs/2d.cube.size3/coeff-dyy.store.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size3, "coeff_I_"), "fp", "2d.coeffs/2d.cube.size3/coeff-I.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size3, "coeff_dx_"), "fp", "2d.coeffs/2d.cube.size3/coeff-dx.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size3, "coeff_dy_"), "fp", "2d.coeffs/2d.cube.size3/coeff-dy.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size3, "coeff_dxx_"), "fp", "2d.coeffs/2d.cube.size3/coeff-dxx.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size3, "coeff_dxy_"), "fp", "2d.coeffs/2d.cube.size3/coeff-dxy.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size3, "coeff_dyy_"), "fp", "2d.coeffs/2d.cube.size3/coeff-dyy.dcl.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size3, "result", "coeff_I_", "data_", "2d.coeffs/2d.cube.size3/interp-I.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size3, "result", "coeff_dx_", "data_", "2d.coeffs/2d.cube.size3/interp-dx.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size3, "result", "coeff_dy_", "data_", "2d.coeffs/2d.cube.size3/interp-dy.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size3, "result", "coeff_dxx_", "data_", "2d.coeffs/2d.cube.size3/interp-dxx.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size3, "result", "coeff_dxy_", "data_", "2d.coeffs/2d.cube.size3/interp-dxy.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size3, "result", "coeff_dyy_", "data_", "2d.coeffs/2d.cube.size3/interp-dyy.compute.c"); ######################################## # # generic stuff for 2d, cube, size=4 # data_var_list_2d_size4 := map(data_var_name, posn_list_2d_size4, "data_"); print_name_list_dcl(data_var_list_2d_size4, "fp", "2d.coeffs/2d.cube.size4/data-var.dcl.c"); print_data_var_assign(posn_list_2d_size4, "data_", "2d.coeffs/2d.cube.size4/data-var.assign.c"); print_interp_coeff_var_store(posn_list_2d_size4, "coeff_I_", "2d.coeffs/2d.cube.size4/coeff-I.store.c"); print_interp_coeff_var_store(posn_list_2d_size4, "coeff_dx_", "2d.coeffs/2d.cube.size4/coeff-dx.store.c"); print_interp_coeff_var_store(posn_list_2d_size4, "coeff_dy_", "2d.coeffs/2d.cube.size4/coeff-dy.store.c"); print_interp_coeff_var_store(posn_list_2d_size4, "coeff_dxx_", "2d.coeffs/2d.cube.size4/coeff-dxx.store.c"); print_interp_coeff_var_store(posn_list_2d_size4, "coeff_dxy_", "2d.coeffs/2d.cube.size4/coeff-dxy.store.c"); print_interp_coeff_var_store(posn_list_2d_size4, "coeff_dyy_", "2d.coeffs/2d.cube.size4/coeff-dyy.store.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size4, "coeff_I_"), "fp", "2d.coeffs/2d.cube.size4/coeff-I.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size4, "coeff_dx_"), "fp", "2d.coeffs/2d.cube.size4/coeff-dx.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size4, "coeff_dy_"), "fp", "2d.coeffs/2d.cube.size4/coeff-dy.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size4, "coeff_dxx_"), "fp", "2d.coeffs/2d.cube.size4/coeff-dxx.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size4, "coeff_dxy_"), "fp", "2d.coeffs/2d.cube.size4/coeff-dxy.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size4, "coeff_dyy_"), "fp", "2d.coeffs/2d.cube.size4/coeff-dyy.dcl.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size4, "result", "coeff_I_", "data_", "2d.coeffs/2d.cube.size4/interp-I.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size4, "result", "coeff_dx_", "data_", "2d.coeffs/2d.cube.size4/interp-dx.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size4, "result", "coeff_dy_", "data_", "2d.coeffs/2d.cube.size4/interp-dy.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size4, "result", "coeff_dxx_", "data_", "2d.coeffs/2d.cube.size4/interp-dxx.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size4, "result", "coeff_dxy_", "data_", "2d.coeffs/2d.cube.size4/interp-dxy.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size4, "result", "coeff_dyy_", "data_", "2d.coeffs/2d.cube.size4/interp-dyy.compute.c"); ######################################## # # generic stuff for 2d, cube, size=5 # data_var_list_2d_size5 := map(data_var_name, posn_list_2d_size5, "data_"); print_name_list_dcl(data_var_list_2d_size5, "fp", "2d.coeffs/2d.cube.size5/data-var.dcl.c"); print_data_var_assign(posn_list_2d_size5, "data_", "2d.coeffs/2d.cube.size5/data-var.assign.c"); print_interp_coeff_var_store(posn_list_2d_size5, "coeff_I_", "2d.coeffs/2d.cube.size5/coeff-I.store.c"); print_interp_coeff_var_store(posn_list_2d_size5, "coeff_dx_", "2d.coeffs/2d.cube.size5/coeff-dx.store.c"); print_interp_coeff_var_store(posn_list_2d_size5, "coeff_dy_", "2d.coeffs/2d.cube.size5/coeff-dy.store.c"); print_interp_coeff_var_store(posn_list_2d_size5, "coeff_dxx_", "2d.coeffs/2d.cube.size5/coeff-dxx.store.c"); print_interp_coeff_var_store(posn_list_2d_size5, "coeff_dxy_", "2d.coeffs/2d.cube.size5/coeff-dxy.store.c"); print_interp_coeff_var_store(posn_list_2d_size5, "coeff_dyy_", "2d.coeffs/2d.cube.size5/coeff-dyy.store.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size5, "coeff_I_"), "fp", "2d.coeffs/2d.cube.size5/coeff-I.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size5, "coeff_dx_"), "fp", "2d.coeffs/2d.cube.size5/coeff-dx.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size5, "coeff_dy_"), "fp", "2d.coeffs/2d.cube.size5/coeff-dy.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size5, "coeff_dxx_"), "fp", "2d.coeffs/2d.cube.size5/coeff-dxx.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size5, "coeff_dxy_"), "fp", "2d.coeffs/2d.cube.size5/coeff-dxy.dcl.c"); print_name_list_dcl(map(coeff_name, posn_list_2d_size5, "coeff_dyy_"), "fp", "2d.coeffs/2d.cube.size5/coeff-dyy.dcl.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size5, "result", "coeff_I_", "data_", "2d.coeffs/2d.cube.size5/interp-I.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size5, "result", "coeff_dx_", "data_", "2d.coeffs/2d.cube.size5/interp-dx.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size5, "result", "coeff_dy_", "data_", "2d.coeffs/2d.cube.size5/interp-dy.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size5, "result", "coeff_dxx_", "data_", "2d.coeffs/2d.cube.size5/interp-dxx.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size5, "result", "coeff_dxy_", "data_", "2d.coeffs/2d.cube.size5/interp-dxy.compute.c"); print_interp_cmpt__lc_of_data(posn_list_2d_size5, "result", "coeff_dyy_", "data_", "2d.coeffs/2d.cube.size5/interp-dyy.compute.c"); ################################################################################ # # 2d, cube, order=1, smoothing=0 (size=2) # # interpolating polynomial interp_2d_cube_order1_smooth0 := polynomial_interpolant(fn_2d_order1, coeff_list_2d_order1, coord_list_2d, posn_list_2d_size2); # I coeff_as_lc_of_data(%, posn_list_2d_size2); print_coeff__lc_of_data(%, "coeff_I_", "fp", "2d.coeffs/2d.cube.order1.smooth0/coeff-I.compute.c"); # d/dx simplify( diff(interp_2d_cube_order1_smooth0,x) ); coeff_as_lc_of_data(%, posn_list_2d_size2); print_coeff__lc_of_data(%, "coeff_dx_", "fp", "2d.coeffs/2d.cube.order1.smooth0/coeff-dx.compute.c"); # d/dy simplify( diff(interp_2d_cube_order1_smooth0,y) ); coeff_as_lc_of_data(%, posn_list_2d_size2); print_coeff__lc_of_data(%, "coeff_dy_", "fp", "2d.coeffs/2d.cube.order1.smooth0/coeff-dy.compute.c"); ######################################## # # 2d, cube, order=2, smoothing=0 (size=3) # # interpolating polynomial interp_2d_cube_order2_smooth0 := polynomial_interpolant(fn_2d_order2, coeff_list_2d_order2, coord_list_2d, posn_list_2d_size3); # I coeff_as_lc_of_data(%, posn_list_2d_size3); print_coeff__lc_of_data(%, "coeff_I_", "fp", "2d.coeffs/2d.cube.order2.smooth0/coeff-I.compute.c"); # d/dx simplify( diff(interp_2d_cube_order2_smooth0,x) ); coeff_as_lc_of_data(%, posn_list_2d_size3); print_coeff__lc_of_data(%, "coeff_dx_", "fp", "2d.coeffs/2d.cube.order2.smooth0/coeff-dx.compute.c"); # d/dy simplify( diff(interp_2d_cube_order2_smooth0,y) ); coeff_as_lc_of_data(%, posn_list_2d_size3); print_coeff__lc_of_data(%, "coeff_dy_", "fp", "2d.coeffs/2d.cube.order2.smooth0/coeff-dy.compute.c"); # d^2/dx^2 simplify( diff(interp_2d_cube_order2_smooth0,x,x) ); coeff_as_lc_of_data(%, posn_list_2d_size3); print_coeff__lc_of_data(%, "coeff_dxx_", "fp", "2d.coeffs/2d.cube.order2.smooth0/coeff-dxx.compute.c"); # d^2/dxdy simplify( diff(interp_2d_cube_order2_smooth0,x,y) ); coeff_as_lc_of_data(%, posn_list_2d_size3); print_coeff__lc_of_data(%, "coeff_dxy_", "fp", "2d.coeffs/2d.cube.order2.smooth0/coeff-dxy.compute.c"); # d^2/dy^2 simplify( diff(interp_2d_cube_order2_smooth0,y,y) ); coeff_as_lc_of_data(%, posn_list_2d_size3); print_coeff__lc_of_data(%, "coeff_dyy_", "fp", "2d.coeffs/2d.cube.order2.smooth0/coeff-dyy.compute.c"); ######################################## # # 2d, cube, order=3, smoothing=0 (size=4) # # interpolating polynomial interp_2d_cube_order3_smooth0 := polynomial_interpolant(fn_2d_order3, coeff_list_2d_order3, coord_list_2d, posn_list_2d_size4); # I coeff_as_lc_of_data(%, posn_list_2d_size4); print_coeff__lc_of_data(%, "coeff_I_", "fp", "2d.coeffs/2d.cube.order3.smooth0/coeff-I.compute.c"); # d/dx simplify( diff(interp_2d_cube_order3_smooth0,x) ); coeff_as_lc_of_data(%, posn_list_2d_size4); print_coeff__lc_of_data(%, "coeff_dx_", "fp", "2d.coeffs/2d.cube.order3.smooth0/coeff-dx.compute.c"); # d/dy simplify( diff(interp_2d_cube_order3_smooth0,y) ); coeff_as_lc_of_data(%, posn_list_2d_size4); print_coeff__lc_of_data(%, "coeff_dy_", "fp", "2d.coeffs/2d.cube.order3.smooth0/coeff-dy.compute.c"); # d^2/dx^2 simplify( diff(interp_2d_cube_order3_smooth0,x,x) ); coeff_as_lc_of_data(%, posn_list_2d_size4); print_coeff__lc_of_data(%, "coeff_dxx_", "fp", "2d.coeffs/2d.cube.order3.smooth0/coeff-dxx.compute.c"); # d^2/dxdy simplify( diff(interp_2d_cube_order3_smooth0,x,y) ); coeff_as_lc_of_data(%, posn_list_2d_size4); print_coeff__lc_of_data(%, "coeff_dxy_", "fp", "2d.coeffs/2d.cube.order3.smooth0/coeff-dxy.compute.c"); # d^2/dy^2 simplify( diff(interp_2d_cube_order3_smooth0,y,y) ); coeff_as_lc_of_data(%, posn_list_2d_size4); print_coeff__lc_of_data(%, "coeff_dyy_", "fp", "2d.coeffs/2d.cube.order3.smooth0/coeff-dyy.compute.c"); ######################################## # # 2d, cube, order=4, smoothing=0 (size=5) # # interpolating polynomial interp_2d_cube_order4_smooth0 := polynomial_interpolant(fn_2d_order4, coeff_list_2d_order4, coord_list_2d, posn_list_2d_size5); # I coeff_as_lc_of_data(%, posn_list_2d_size5); print_coeff__lc_of_data(%, "coeff_I_", "fp", "2d.coeffs/2d.cube.order4.smooth0/coeff-I.compute.c"); # d/dx simplify( diff(interp_2d_cube_order4_smooth0,x) ); coeff_as_lc_of_data(%, posn_list_2d_size5); print_coeff__lc_of_data(%, "coeff_dx_", "fp", "2d.coeffs/2d.cube.order4.smooth0/coeff-dx.compute.c"); # d/dy simplify( diff(interp_2d_cube_order4_smooth0,y) ); coeff_as_lc_of_data(%, posn_list_2d_size5); print_coeff__lc_of_data(%, "coeff_dy_", "fp", "2d.coeffs/2d.cube.order4.smooth0/coeff-dy.compute.c"); # d^2/dx^2 simplify( diff(interp_2d_cube_order4_smooth0,x,x) ); coeff_as_lc_of_data(%, posn_list_2d_size5); print_coeff__lc_of_data(%, "coeff_dxx_", "fp", "2d.coeffs/2d.cube.order4.smooth0/coeff-dxx.compute.c"); # d^2/dxdy simplify( diff(interp_2d_cube_order4_smooth0,x,y) ); coeff_as_lc_of_data(%, posn_list_2d_size5); print_coeff__lc_of_data(%, "coeff_dxy_", "fp", "2d.coeffs/2d.cube.order4.smooth0/coeff-dxy.compute.c"); # d^2/dy^2 simplify( diff(interp_2d_cube_order4_smooth0,y,y) ); coeff_as_lc_of_data(%, posn_list_2d_size5); print_coeff__lc_of_data(%, "coeff_dyy_", "fp", "2d.coeffs/2d.cube.order4.smooth0/coeff-dyy.compute.c"); ################################################################################