Finish translation for InterpolatedDiscountCurve
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
JQuantLib |
In Progress
|
High
|
Richard Gomes |
Bug Description
A potential user wrote a test case for class InterpolatedDis
We need to write a similar test case and make the needed fixes.
Below we can see the user report:
-------
Hi, I have written a simple example to use InterpolatedDis
It gives me an ArrayBoundExcep
jdate is 2008-09-04 // settle date
jdate is 2008-10-06
jdate is 2009-10-07
jdate is 2010-10-01
jdate is 2011-10-02
rate[0]=1.0 // reference rate
rate[1]
rate[2]
rate[3]=4.1
rate[4]=5.1
// COnstructor
InterpolatedDis
new InterpolatedDis
discounts,
dct,
(org.jquantlib.
UnitedStates.
(Linear)ipol);
// trying to interpolate for date 2009-07-31:
curve.getDiscou
// exception:
Exception:-4 java.lang.
java.lang.
at org.jquantlib.
at org.jquantlib.
at org.jquantlib.
at org.jquantlib.
at org.jquantlib.
at com.knight.
at com.knight.
I think its in the locate() method that is trying to locate the point to interpolate for but I don't see why it should be as the
date I am trying to interpolate for is WITHIN bounds of the dates I have passed.
Please help, I really would like to use JQuantLib for a project but so far I haven't been able to get a simple example as above to
work.
Thanks a lot,
-Sid.
=============
Relationships
=============
related to http://
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