Symbolic library for C++

I was working on a curve fitting exercise with my Binomial Lattice application. I used Neville's algorithm and used SymbolicC++ library, but it hasn't been well kept.

So something like this:

Code:
void neville(BinomialLattice<Symbolic> &lat, curve curve, Symbolic x)
{

    for (int i = 0; i < 5; ++i)
    {
        lat(4, i) = curve[i][0];
    }

    for (int i = 3; i != -1; --i)
    {
        for (int j = 0; j <= i; ++j)
        {
            lat(i, j) = ((lat(4, j) - x) * lat(i + 1, j) + (x - lat(4, j)) * lat(i + 2, j)) / (lat(4, j) - lat(4, i));
        }
    }
}
 
I think Neville can be done in 'normal' C++?

The underlying BinomialLattice can be used but the backwards induction algo to update its node values uses the array of x_i and y_i values I = 0,...n. As in here

Neville's algorithm - Wikipedia, the free encyclopedia

You can create a class with x,y member data that has a function

double getValue(double x) const;
 
Last edited:
Back
Top Bottom