Skip to content
Snippets Groups Projects
Commit 0b7ca0db authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

ENH: New function to copy spline coefficients

parent 34d41608
No related branches found
No related tags found
1 merge request!17ENH: Allow `Splinterpolator` instances to be created from an existing set of spline coefficients, and extend extrapolation options
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment