diff --git a/splinterpolator.h b/splinterpolator.h index fbfd6a43a0b619a73eb99feb10b9c2c821935c15..094a0aaf9d4f2ab28db400398e48dcf02a181ea9 100644 --- a/splinterpolator.h +++ b/splinterpolator.h @@ -64,8 +64,7 @@ public: ExtrapolationType et=Zeros, unsigned int order=3, bool copy_low_order=true, - Utilities::NoOfThreads - nthr=Utilities::NoOfThreads(1), + Utilities::NoOfThreads nthr=Utilities::NoOfThreads(1), double prec=1e-8, bool data_are_coefs=false) : _valid(false), _own_coef(false), _coef(0), _cptr(0), _ndim(0), _nthr(nthr._n) @@ -84,6 +83,22 @@ public: Splinterpolator& operator=(const Splinterpolator& src) { if(_own_coef) delete [] _coef; assign(src); return(*this); } + // Copy the spline coefficients into dest. + void Copy(std::vector<T>& dest) + { + unsigned int N = 1; + for (auto d : _dim) { + N *= d; + } + dest.resize(N); + + auto coefs = coef_ptr(); + + for (unsigned int i = 0; i < N; i++) { + dest[i] = coefs[i]; + } + } + // Set new data in Splinterpolator. void Set(const T *data_or_coefs, const std::vector<unsigned int>& dim,