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

ENH: Adjust logic so that Splinterpolator can be created with pre-calculated coefficeints

parent 3c9651fe
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
...@@ -1436,16 +1436,19 @@ void Splinterpolator<T>::assign(const Splinterpolator<T>& src) ...@@ -1436,16 +1436,19 @@ void Splinterpolator<T>::assign(const Splinterpolator<T>& src)
template<class T> template<class T>
bool Splinterpolator<T>::calc_coef(const T *data_or_coefs, bool copy, bool data_are_coefs) bool Splinterpolator<T>::calc_coef(const T *data_or_coefs, bool copy, bool data_are_coefs)
{ {
if (_order < 2 && !copy) { _cptr = data_or_coefs; return(false); } // No copy, and nearest/interp, or pre-calculated
// coefficients - just take a pointer to the data
if (_order < 2 && !copy) { _cptr = data_or_coefs; return(false); }
if (data_are_coefs && !copy) { _cptr = data_or_coefs; return(false); }
// Allocate memory and put the original data into _coef // Allocate memory and put the original data into _coef
//
unsigned int ts=1; unsigned int ts=1;
for (unsigned int i=0; i<_dim.size(); i++) ts *= _dim[i]; for (unsigned int i=0; i<_dim.size(); i++) ts *= _dim[i];
_coef = new T[ts]; _coef = new T[ts];
memcpy(_coef,data_or_coefs,ts*sizeof(T)); memcpy(_coef,data_or_coefs,ts*sizeof(T));
if (_order < 2) return(true); // If nearest neighbour or linear, that's all we need if (_order < 2) return(true); // If nearest neighbour or linear, that's all we need
if (data_are_coefs) return(true); // User has given us pre-calculated coefficients
// Loop over all non-singleton dimensions and deconvolve along them // Loop over all non-singleton dimensions and deconvolve along them
// //
......
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