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

BF: Fix extrapolation indexing bug in Splinterpolator::coef(). I think this

code was added in an early commit, but was then replaced with indx2indx, and
never updated / used.
parent 576da60c
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
...@@ -1350,16 +1350,8 @@ T Splinterpolator<T>::coef(int *indx) const ...@@ -1350,16 +1350,8 @@ T Splinterpolator<T>::coef(int *indx) const
case SoftZeros: case SoftZeros:
case Zeros: case Zeros:
return(static_cast<T>(0)); return(static_cast<T>(0));
case Constant:
indx[i] = 0;
break;
case Mirror:
indx[i] = 1-indx[i];
break;
case Periodic:
indx[i] = _dim[i]+indx[i];
break;
default: default:
indx[i] = indx2indx(indx[i], i);
break; break;
} }
} }
...@@ -1368,23 +1360,17 @@ T Splinterpolator<T>::coef(int *indx) const ...@@ -1368,23 +1360,17 @@ T Splinterpolator<T>::coef(int *indx) const
case SoftZeros: case SoftZeros:
case Zeros: case Zeros:
return(static_cast<T>(0)); return(static_cast<T>(0));
case Constant:
indx[i] = _dim[i]-1;
break;
case Mirror:
indx[i] = 2*_dim[i]-indx[i]-1;
break;
case Periodic:
indx[i] = indx[i]-_dim[i];
break;
default: default:
indx[i] = indx2indx(indx[i], i);
break; break;
} }
} }
} }
// Now make linear index // Now make linear index
unsigned int lindx=indx[_ndim-1]; unsigned int lindx=indx[_ndim-1];
for (int i=_ndim-2; i>=0; i--) lindx = _dim[i]*lindx + indx[i]; for (int i=_ndim-2; i>=0; i--) lindx = _dim[i]*lindx + indx[i];
return(coef_ptr()[lindx]); return(coef_ptr()[lindx]);
} }
......
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