USML
|
Implements fast calculations for data_grids using a non-recursive engine on interpolation.
Takes an existing data_grid and wraps it into a new data_grid_fast and overrides the interpolate function to implement the non-recursive algorithm.
Assumes that both axes of the passed data_grid both have the same interp_type.
WARNING: This wrapper is specific to 2-dimensional grids only. For 3-dimensional grids, the user should implement the data_grid_svp wrapper instead.
Since the data is passed in and referenced by this wrapper, the data is taken control of and destroyed at the end of its use cycle.
|
inline |
Constructor - Creates a fast interpolation grid from an existing data_grid.
Also constructs the inverse bicubic coefficient matrix to be used at a later time during pchip calculations.
grid | The data_grid that is to be wrapped. |
copy_data | If true, copies the data grids data fields as well as the axises. |
|
inlineprivate |
Utility accessor function for data grid values.
|
inlineprivate |
A non-recursive version of the Piecewise Cubic Hermite polynomial (PCHIP) specific to the 2-dimensional grid of data.
This algorithm was generated from the below formula and by performing a linear transformation from the data set to the interval [0,1] x [0,1]:
g(x,y) = sum [i,0,3] ( sum [j,0,3] ( a_ij * x^i * y^j ) )
where (x,y) is the point of interpolation and a_ij are known as the bicubic interpolation coefficients. An inverse matrix is then constructed from the 16 equations that are generated. Using this inverse matrix and the 4 surround data points, their respective derivatives with respect to x and y, and mixed xy xy derivatives, we can construct each a_ij.
The partial and mixed derivates are computed using a centered differencing approximation, so that,
f_x(i,j) = [ f(i+1,j) - f(i-1,j) ] / [ x_(i+1) - x(i-1) ] f_y(i,j) = [ f(i,j+1) - f(i,j-1) ] / [ y_(i+1) - y(i-1) ] f_xy(i,j) = { f(i+1,j+1) - f(i+1,j-1) - f(i-1,j+1) + f(i-1,j-1) } / [ x_(i+1) - x(i-1) ] * [ y_(i+1) - y(i-1) ]
Below is a representation of the data extracted from the field and how it is stored within the matrix:
* field(1,0) * field(3,0) * (interp point) * field(0,0) * field(2,0)
field(0,0) to field(3,0) are the data points that surrounding the interpolation point. field(4,0) to field(7,0) are the derivatives with respect to x of the extracted data points. field(8,0) to field(11,0) are the derivatives with respect to y of the extracted data points. field(12,0) to field(15,0) are the derivatives with respect to x and y of the extracted data points.
interp_index | index on the grid for the closest data point |
location | Location of the field calculation |
derivative | Generate the derivative at the location (output) |
|
inline |
Overrides the interpolate function within data_grid using the non-recursive formula.
Determines which interpolate function to based on the interp_type enumeral stored within the 0th dimensional axis.
Interpolate at a single location.
location | Location to do the interpolation at |
derivative | Derivative at the location (output) |
|
inline |
Overrides the interpolate function within data_grid using the non-recursive formula.
Interpolate at a series of locations.
x | First dimension of location. |
y | Second dimension of location. |
result | Interpolated values at each location (output). |
dx | First dimension of derivative (output). |
dy | Second dimension of derivative (output). |
|
private |
Create variables that are used multiple times through out the course of multiple calls per instance.
Thus allowing these variables to be created once and used as many times as needed and save memory and time.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Matrix that is the inverse of the bicubic coefficients This matrix will be used to construct the bicubic coefficients.
The result will be a 16x1 matrix.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |