23 #ifndef O2SCL_INTERPM_NEIGH_H 24 #define O2SCL_INTERPM_NEIGH_H 34 #include <o2scl/err_hnd.h> 36 #ifndef DOXYGEN_NO_O2NS 73 template<
class vec_vec_t>
74 void set_data(
size_t dim,
size_t n_points, vec_vec_t &vecs) {
77 O2SCL_ERR2(
"Must provide at least one point in ",
84 for(
size_t i=0;i<dim+1;i++) {
94 template<
class vec2_t>
double operator()(vec2_t &x)
const {
100 template<
class vec2_t>
double eval(vec2_t &x)
const {
103 O2SCL_ERR(
"Data not set in interp_planar::eval_points().",
108 size_t nscales=scales.size();
116 for(
size_t i=0;i<
nd;i++) {
117 dist_min+=pow((x[i]-(*(
ptrs[i]))[index_min])/scales[i%nscales],2.0);
119 for(
size_t index=1;index<
np;index++) {
121 for(
size_t i=0;i<
nd;i++) {
122 dist+=pow((x[i]-(*(
ptrs[i]))[index])/scales[i%nscales],2.0);
131 return (*(
ptrs[nd]))[index_min];
134 #ifndef DOXYGEN_INTERNAL 151 #ifndef DOXYGEN_NO_O2NS The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
double eval(vec2_t &x) const
Perform the interpolation.
Nearest-neighbor interpolation in arbitrary number of dimensions.
size_t np
The number of points.
invalid argument supplied by user
bool data_set
True if the data has been specified.
double operator()(vec2_t &x) const
Perform the interpolation.
ubvector scales
Distance scales for each coordinate.
#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 nd
The number of dimensions.
void set_data(size_t dim, size_t n_points, vec_vec_t &vecs)
Initialize the data for the interpolation.
std::vector< vec_t * > ptrs
A vector of pointers holding the data.