RE: Docs - requesting peer review

Posted by Luigi Ballabio-4 on
URL: http://quantlib.414.s1.nabble.com/Docs-requesting-peer-review-tp1768p1769.html

Jonathan,
         I'm cc'ing this to the QuantLib users list as well, so that I can
get the proper blame for this blunder.

At 06:42 PM 10/8/01 -0700, Jonathan Knight wrote:
>I have taken a look at the example, and I cannot
>get the interest rate part of the model to work.
>There does not seem to be a way to multiply the
>rate by the identity array in the header files. Am
>  There also seems to be no way to take the
>resulting array and add it to the tridiagonal
>arrays for the rest of the model. Am I missign
>something about how the Identity array works ?

First of all, thanks, This is exactly the reason why I asked for peer
review---I could have looked at that code for hours without seeing this.

You are right: I've been thinking of the Identity as a degenerate
tridiagonal operator and I forgot that it isn't implemented as one. Or
maybe I've been thinking of how it is exported towards Python. Argh!

Well, while I think of a clever way of including the actual Identity class
into the operator algebra---and you are all welcome to contribute
ideas---you can fix the thing as follows:

class TridiagonalIdentity : public TridiagonalOperator {
   public:
     TridiagonalIdentity(int points)
     : TridiagonalOperator(Array(points-1,0.0), // lower diagonal
                           Array(points,1.0),   // diagonal
                           Array(points-1,0.0)) // upper diagonal
     {}
};

class BlackScholesOperator : public TridiagonalOperator {
   as in the docs, replacing Identity<Array>(points) which doesn't work with
   TridiagonalIdentity(points) which does.
};

Apologies,
                 Luigi