Here are links to the implemented code. The 2 dimensional code calls the 1 dimensional code. We use la.solve in the method now.

1 dimensional interpolation code

2 dimensional interpolation code

These files below are for testing the code. It gives you an example of how you could implement it. (Obviously you won't know the functions beforehand, but if you have x and y, or x y and z in this form it should work.) The current test for 2 dimensional spline is calculating it over a 100x100 grid. This means it is solving for 10,000 points and so it takes a little bit, but solving for any one point that is needed is much faster.

The 1d takes a vector of x values and takes a vector of y values such that y = sin(x) for all of the x's we are given. It then interpolates to solve for estimation coefficients. Then feval calculates the value for any x such that x in range(x)

The 2d takes 2 vectors x and y and a matrix of zs such that f(x_i, y_j) = z_i,j. In a similar fashion it implement interpolation on the grid created by the Cartesian product. Then for any pair of x,y in the domain of x and domain of y we can calculate its value, z, for f(x,y). feval2 implements this solution

testspline1d

testspline2d

It can be made even more accurate using a rescaling method presented in the paper. Below are the surfaces obtained by the true values of the function f(x,y) = sin(x) - cos(y^2) and the surface obtained by evaluating our spline function on a 100x100 grid.

If you have questions let us know. We recently updated the spline code so that it is a class. The documentation should be sufficient. Interp_Class.

## No comments:

## Post a Comment