23 #ifndef O2SCL_INTERP2_NEIGH_H
24 #define O2SCL_INTERP2_NEIGH_H
34 #include <o2scl/err_hnd.h>
36 #ifndef DOXYGEN_NO_O2NS
102 double minx=(*ux)[0], maxx=(*ux)[0];
103 for(
size_t i=1;i<
np;i++) {
104 if ((*
ux)[i]<minx) minx=(*ux)[i];
105 if ((*
ux)[i]>maxx) maxx=(*ux)[i];
112 double miny=(*uy)[0], maxy=(*uy)[0];
113 for(
size_t i=1;i<
np;i++) {
114 if ((*
uy)[i]<miny) miny=(*uy)[i];
115 if ((*
uy)[i]>maxy) maxy=(*uy)[i];
122 if (
dx<=0.0 ||
dy<=0.0) {
134 void set_data(
size_t n_points, vec_t &x, vec_t &y, vec_t &f) {
136 O2SCL_ERR2(
"Must provide at least one point in ",
152 double eval(
double x,
double y)
const {
169 return eval(v[0],v[1]);
179 size_t &i1,
double &
x1,
double &y1)
const {
182 O2SCL_ERR(
"Data not set in interp_planar::eval_points().",
188 double dist_min=pow((x-(*
ux)[i1])/
dx,2.0)+pow((y-(*
uy)[i1])/
dy,2.0);
189 for(
size_t index=1;index<
np;index++) {
190 double dist=pow((x-(*
ux)[index])/
dx,2.0)+pow((y-(*
uy)[index])/
dy,2.0);
204 #ifndef DOXYGEN_INTERNAL
223 #ifndef DOXYGEN_NO_O2NS
Nearest-neighbor interpolation in two dimensions.
double y_scale
The user-specified y scale (default -1)
double x_scale
The user-specified x scale (default -1)
bool data_set
True if the data has been specified.
invalid argument supplied by user
double dx
The scale in the x direction.
double eval(double x, double y) const
Perform the interpolation.
void eval_point(double x, double y, double &f, size_t &i1, double &x1, double &y1) const
Interpolation returning the closest point.
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
double operator()(double x, double y) const
Perform the interpolation.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
size_t np
The number of points.
double operator()(vec2_t &v) const
Perform the planar interpolation using the first two elements of v as input.
void set_data(size_t n_points, vec_t &x, vec_t &y, vec_t &f)
Initialize the data for the neigh interpolation.
double dy
The scale in the y direction.
static const double x1[5]
void compute_scale()
Find scaling.