Skip to content
Snippets Groups Projects
Commit 878d7e19 authored by Matthew Webster's avatar Matthew Webster
Browse files

fixes for interp_1d

parent 569da575
No related branches found
No related tags found
No related merge requests found
...@@ -195,20 +195,14 @@ namespace MISCMATHS { ...@@ -195,20 +195,14 @@ namespace MISCMATHS {
{ {
int widthx = (width - 1)/2; int widthx = (width - 1)/2;
// kernel half-width (i.e. range is +/- w) // kernel half-width (i.e. range is +/- w)
int ix0; int ix0;
ix0 = (int) floor(index); ix0 = (int) floor(index);
static int wx=0; int wx(widthx);
static float *storex = 0; vector<float> storex(2*wx+1);
if ( (wx!=widthx) || (storex==0) ) { for (int d=-wx; d<=wx; d++)
wx=widthx; storex[d+wx] = kernelval((index-ix0+d),wx,userkernel);
storex = new float[2*wx+1];
for (int d=-wx; d<=wx; d++) {
storex[d+wx] = kernelval((index-ix0+d),wx,userkernel);
}
}
float convsum=0.0, interpval=0.0, kersum=0.0; float convsum=0.0, interpval=0.0, kersum=0.0;
int xj; int xj;
...@@ -216,8 +210,6 @@ namespace MISCMATHS { ...@@ -216,8 +210,6 @@ namespace MISCMATHS {
if (in_bounds(data, x1)) { if (in_bounds(data, x1)) {
xj=ix0-x1+wx; xj=ix0-x1+wx;
float kerfac = storex[xj]; float kerfac = storex[xj];
// cerr << "x1 = " << x1 << endl;
// cerr << "data(x1) = " << data(x1) << endl;
convsum += data(x1) * kerfac; convsum += data(x1) * kerfac;
kersum += kerfac; kersum += kerfac;
} }
...@@ -228,9 +220,6 @@ namespace MISCMATHS { ...@@ -228,9 +220,6 @@ namespace MISCMATHS {
} else { } else {
interpval = (float) extrapolate_1d(data, ix0); interpval = (float) extrapolate_1d(data, ix0);
} }
// cerr << "interpval = " << interpval << endl;
return interpval; return interpval;
} }
......
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