23 #ifndef O2SCL_INTERP2_NEIGH_H 24 #define O2SCL_INTERP2_NEIGH_H 34 #include <o2scl/err_hnd.h> 36 #ifndef DOXYGEN_NO_O2NS 106 double minx=(*ux)[0], maxx=(*ux)[0];
107 for(
size_t i=1;i<
np;i++) {
108 if ((*
ux)[i]<minx) minx=(*ux)[i];
109 if ((*
ux)[i]>maxx) maxx=(*ux)[i];
116 double miny=(*uy)[0], maxy=(*uy)[0];
117 for(
size_t i=1;i<
np;i++) {
118 if ((*
uy)[i]<miny) miny=(*uy)[i];
119 if ((*
uy)[i]>maxy) maxy=(*uy)[i];
126 if (dx<=0.0 || dy<=0.0) {
138 void set_data(
size_t n_points, vec_t &x, vec_t &y, vec_t &f) {
140 O2SCL_ERR2(
"Must provide at least one point in ",
156 double eval(
double x,
double y)
const {
173 return eval(v[0],v[1]);
183 size_t &i1,
double &
x1,
double &y1)
const {
186 O2SCL_ERR(
"Data not set in interp_planar::eval_points().",
192 double dist_min=pow((x-(*
ux)[i1])/dx,2.0)+pow((y-(*
uy)[i1])/dy,2.0);
193 for(
size_t index=1;index<
np;index++) {
194 double dist=pow((x-(*
ux)[index])/dx,2.0)+pow((y-(*
uy)[index])/dy,2.0);
208 #ifndef DOXYGEN_INTERNAL 227 #ifndef DOXYGEN_NO_O2NS Nearest-neighbor interpolation in two dimensions.
double y_scale
The user-specified y scale (default -1)
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
double x_scale
The user-specified x scale (default -1)
double operator()(double x, double y) const
Perform the interpolation.
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.
double operator()(vec2_t &v) const
Perform the planar interpolation using the first two elements of v as input.
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
size_t np
The number of points.
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.
void eval_point(double x, double y, double &f, size_t &i1, double &x1, double &y1) const
Interpolation returning the closest point.