#include <twod_intp.h>
This class implements two-dimensional interpolation. Derivatives and integrals along both x- and y-directions can be computed. The function set_data(), does not copy the data but rather stores pointers to the data. If the data is modified, then the function reset_interp() can be called to reset the interpolation information with the original pointer information.
The storage for the data, including the arrays x_fun
and y_fun
are all managed by the user. If the data is changed without calling reset_interp(), then interp() will return incorrect results.
By default, cubic spline interpolation with natural boundary conditions is used. This can be changed with the set_interp() function.
Definition at line 58 of file twod_intp.h.
Public Member Functions | |
int | set_data (int n_x, int n_y, ovector &x_fun, ovector &y_fun, omatrix &u_data, bool x_first=true) |
Initialize the data for the 2-dimensional interpolation. | |
int | reset_interp () |
Reset the stored interpolation since the data has changed. | |
double | interp (double x, double y) |
Perform the 2-d interpolation. | |
double | deriv_x (double x, double y) |
Compute the partial derivative in the x-direction. | |
double | deriv2_x (double x, double y) |
Compute the partial second derivative in the x-direction. | |
double | integ_x (double x0, double x1, double y) |
Compute the integral in the x-direction between x=x0 and x=x1. | |
double | deriv_y (double x, double y) |
Compute the partial derivative in the y-direction. | |
double | deriv2_y (double x, double y) |
Compute the partial second derivative in the y-direction. | |
double | integ_y (double x, double y0, double y1) |
Compute the integral in the y-direction between y=y0 and y=y1. | |
double | deriv_xy (double x, double y) |
Compute the mixed partial derivative ![]() | |
int | set_interp (size_t ni, base_interp< ovector_view > *it, base_interp< ovector_const_subvector > *it_sub, base_interp< ovector_view > &it2, base_interp< ovector_const_subvector > &it2_sub) |
Specify the base interpolation objects to use. |
int set_data | ( | int | n_x, | |
int | n_y, | |||
ovector & | x_fun, | |||
ovector & | y_fun, | |||
omatrix & | u_data, | |||
bool | x_first = true | |||
) |
Initialize the data for the 2-dimensional interpolation.
The interpolation type (passed directly to int_type) is specified in int_type
and the data is specified in data
. The data should be arranged so that the first array index is the y-value (the "row") and the second array index is the x-value (the "column"). The arrays xfun
and yfun
specify the two independent variables. xfun
should be an array of length nx
, and should be an array of length ny
. The array data
should be a two-dimensional array of size [ny][nx].
If x_first
is true, then set_data() creates interpolation objects for each of the rows. Calls to interp() then uses these to create a column at the specified value of x
. An interpolation object is created at this column to find the value of the function at the specified value y
. If x_first
is false, the opposite strategy is employed. These two options may give slightly different results. In general, if the data is "more accurate" in the x direction than in the y direction, it is probably better to choose x_first=true
.
int reset_interp | ( | ) |
Reset the stored interpolation since the data has changed.
This will return an error if the set_data() has not been called
int set_interp | ( | size_t | ni, | |
base_interp< ovector_view > * | it, | |||
base_interp< ovector_const_subvector > * | it_sub, | |||
base_interp< ovector_view > & | it2, | |||
base_interp< ovector_const_subvector > & | it2_sub | |||
) | [inline] |
Specify the base interpolation objects to use.
Definition at line 140 of file twod_intp.h.
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page