Skip to content
Snippets Groups Projects

ENH: Allow `Splinterpolator` instances to be created from an existing set of spline coefficients, and extend extrapolation options

Merged Paul McCarthy requested to merge enh/splinterpolator into master
Compare and Show latest version
1 file
+ 16
13
Compare changes
  • Side-by-side
  • Inline
+ 16
13
@@ -812,18 +812,10 @@ unsigned int Splinterpolator<T>::get_start_indicies(const double *coord, int *si
{
unsigned int ni = _order+1;
if (odd(ni)) {
for (unsigned int i=0; i<_ndim; i++) {
sinds[i] = static_cast<int>(coord[i]+0.5) - ni/2;
}
}
else {
for (unsigned int i=0; i<_ndim; i++) {
int ix = static_cast<int>(coord[i]+0.5);
if (ix < coord[i]) sinds[i] = ix - (ni-1)/2;
else sinds[i] = ix -ni/2;
}
for (unsigned int i=0; i<_ndim; i++) {
sinds[i] = std::ceil(coord[i]) - ni/2;
}
for (unsigned int i=_ndim; i<5; i++) sinds[i] = 0;
return(ni);
@@ -1646,11 +1638,17 @@ double Splinterpolator<T>::SplineColumn::init_fwd_sweep(double z, ExtrapolationT
double z2i=z;
for (unsigned int i=1; i<n; i++, ptr--, z2i*=z) iv += z2i * *ptr;
}
else {
else if (et == Mirror) {
double *ptr=&_col[1];
double z2i=z;
for (unsigned int i=1; i<n; i++, ptr++, z2i*=z) iv += z2i * *ptr;
}
// et == Constant || et == Zeros
else {
double *ptr=&_col[0];
double z2i=z;
for (unsigned int i=0; i<n; i++, ptr++, z2i*=z) iv += z2i * *ptr;
}
return(iv);
}
@@ -1677,9 +1675,14 @@ double Splinterpolator<T>::SplineColumn::init_bwd_sweep(double z, double lv, Ext
}
iv /= (z2i-1.0);
}
else {
else if (et == Mirror) {
iv = -z/(1.0-z*z) * (2.0*_col[_sz-1] - lv);
}
// et == Constant || et == Zeros
else {
iv = z / (z - 1) * _col[_sz-1];
}
return(iv);
}
Loading