ENH: Allow `Splinterpolator` instances to be created from an existing set of spline coefficients, and extend extrapolation options
Compare changes
- Paul McCarthy authored
existing set of spline coefficients
+ 68
− 24
@@ -45,35 +45,67 @@ class Splinterpolator
@@ -45,35 +45,67 @@ class Splinterpolator
Splinterpolator(const T *data, const std::vector<unsigned int>& dim, const std::vector<ExtrapolationType>& et, unsigned int order=3, bool copy_low_order=true, Utilities::NoOfThreads nthr=Utilities::NoOfThreads(1), double prec=1e-8) : _valid(false), _own_coef(false), _coef(0), _cptr(0), _ndim(0), _nthr(nthr._n)
Splinterpolator(const T *data, const std::vector<unsigned int>& dim, ExtrapolationType et=Zeros, unsigned int order=3, bool copy_low_order=true, Utilities::NoOfThreads nthr=Utilities::NoOfThreads(1), double prec=1e-8) : _valid(false), _own_coef(false), _coef(0), _cptr(0), _ndim(0), _nthr(nthr._n)
Splinterpolator(const Splinterpolator<T>& src) : _valid(false), _own_coef(false), _coef(0), _cptr(0), _ndim(0) { assign(src); }
Splinterpolator& operator=(const Splinterpolator& src) { if(_own_coef) delete [] _coef; assign(src); return(*this); }
void Set(const T *data, const std::vector<unsigned int>& dim, const std::vector<ExtrapolationType>& et, unsigned int order=3, bool copy_low_order=true, double prec=1e-8)
void Set(const T *data, const std::vector<unsigned int>& dim, ExtrapolationType et, unsigned int order=3, bool copy_low_order=true, double prec=1e-8)
@@ -204,12 +236,18 @@ private:
@@ -204,12 +236,18 @@ private:
void common_construction(const T *data, const std::vector<unsigned int>& dim, unsigned int order, double prec, const std::vector<ExtrapolationType>& et, bool copy);
void deconv_along_mt_helper(unsigned int dim, unsigned int mdim, unsigned int mstep, unsigned int offset, unsigned int step,
@@ -1329,14 +1367,21 @@ unsigned int Splinterpolator<T>::n_nonzero(const unsigned int *vec) const
@@ -1329,14 +1367,21 @@ unsigned int Splinterpolator<T>::n_nonzero(const unsigned int *vec) const
void Splinterpolator<T>::common_construction(const T *data, const std::vector<unsigned int>& dim, unsigned int order, double prec, const std::vector<ExtrapolationType>& et, bool copy)
if (dim.size() > 5) throw SplinterpolatorException("common_construction: data cannot have more than 5 dimensions");
if (dim.size() != et.size()) throw SplinterpolatorException("common_construction: dim and et must have the same size");
for (unsigned int i=0; i<dim.size(); i++) if (!dim[i]) throw SplinterpolatorException("common_construction: data cannot have zeros size in any direction");
if (order > 7) throw SplinterpolatorException("common_construction: spline order must be lesst than 7");
@@ -1345,8 +1390,7 @@ void Splinterpolator<T>::common_construction(const T *data, const std::vector<un
@@ -1345,8 +1390,7 @@ void Splinterpolator<T>::common_construction(const T *data, const std::vector<un
@@ -1385,16 +1429,16 @@ void Splinterpolator<T>::assign(const Splinterpolator<T>& src)
@@ -1385,16 +1429,16 @@ void Splinterpolator<T>::assign(const Splinterpolator<T>& src)
@@ -1464,8 +1508,8 @@ void Splinterpolator<T>::deconv_along(unsigned int dim)
@@ -1464,8 +1508,8 @@ void Splinterpolator<T>::deconv_along(unsigned int dim)