Re: Linear Interpolation

Posted by Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/DiscretizedDiscountBond-and-Tree-tp1230p1233.html

On Wed, 2007-08-01 at 10:24 +0200, [hidden email]
wrote:

> I was performing some debug and I fell in the linearinterpolation.hpp
> file.
> There is something puzzling me:
> If I understood it right, the class LinearInterpolationImpl takes a
> vector of abscissas "x" and a vector of corresponding values "y"
> They have obviously the same size
> But there is also a vector "s_" which seems to be the vector of slopes
> necessary for the interpolation: it is set of the same size of "x" and
> "y" but the last value is never fixed and is left equal to zero.
> So if I should need to extrapolate outside the last abscissa it would
> be done in a flat way

Ciao Marco,
        I had a look at the file. It seems that a problem slipped in---once you
create a LinearInterpolation object, you need to call its update()
method manually before it can be used.

Once you do this, the extrapolation is performed linearly. I think that
the last value of s_ is never used. Even though for some reason s_ is
created the same size as x and y, we need one fewer value; there are
only N-1 slopes between N points.

Later,
        Luigi


--

Brady's First Law of Problem Solving:
When confronted by a difficult problem, you can solve it more
easily by reducing it to the question, "How would the Lone
Ranger have handled this?"



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users