This is the C++ code for locate() in interpolation.hpp:
protected:
Size locate(Real x) const {
if (x < *xBegin_) return 0; else if (x > *(xEnd_-1)) return xEnd_-xBegin_-2; else return std::upper_bound(xBegin_,xEnd_-1,x)-xBegin_-1;
}
This is our code of locate() in JQuantLib (AbstractInterpolation.java):
protected int locate(double x) /* @ReadOnly */ {
if (x <= vx[0])
return 0;
else if (x > vx[vx.length-1])
return vx.length-2;
else
return Sorting.binarySearchFromTo(vx, x, 0, vx.length-1)-1;
}
Question:
We have to change the line 'if (x <= vx[0])' to 'if(x < vx[0]', right?
This is the C++ code for locate() in interpolation.hpp:
return 0;
else if (x > *(xEnd_-1))
return xEnd_-xBegin_-2;
else
return std::upper_ bound(xBegin_ ,xEnd_- 1,x)-xBegin_ -1;
protected:
Size locate(Real x) const {
if (x < *xBegin_)
}
This is our code of locate() in JQuantLib (AbstractInterp olation. java): binarySearchFro mTo(vx, x, 0, vx.length-1)-1;
protected int locate(double x) /* @ReadOnly */ {
if (x <= vx[0])
return 0;
else if (x > vx[vx.length-1])
return vx.length-2;
else
return Sorting.
}
Question:
We have to change the line 'if (x <= vx[0])' to 'if(x < vx[0]', right?
Dominik