Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cubic Interpolation Spline #2008

Open
tony21248772 opened this issue Jul 3, 2024 · 3 comments
Open

Cubic Interpolation Spline #2008

tony21248772 opened this issue Jul 3, 2024 · 3 comments
Labels

Comments

@tony21248772
Copy link

Hi,

I have a question on the setup of the tridiagonal system in the cubic
interpolation (under the choice 'Spline' for derivative approximation. The
tridiagonal system looks a bit different from the one suggested in the
literature. In particular, the middle components of the vector tmp_, the
right hand side vector of tridiagonal system, are caculated as:

            std::vector<Real> dx(n_-1), S(n_-1);

            for (Size

<http://quantlib.sourcearchive.com/documentation/1.1-1/namespaceQuantLib_af4cc4ef40b52c17cc455ead2a97aedb3.html#af4cc4ef40b52c17cc455ead2a97aedb3>
i=0; i<n_-1; ++i) {
dx[i] = this->xBegin_[i+1] - this->xBegin_[i];
S[i] = (this->yBegin_[i+1] - this->yBegin_[i])/dx[i];
}

            // first derivative approximation
            if (da_==CubicInterpolation::Spline

{
TridiagonalOperator
for (Size
=1; i<n_-1; ++i) {
L.setMidRow(i, dx[i], 2.0*(dx[i]+dx[i-1]), dx[i-1]);
tmp[i] = 3.0*(dx[i]*S[i-1] + dx[i-1]*S[i]);
}

Following the literature
L.setMidRow(i, dx[i-1], 2.0*(dx[i]+dx[i-1]), dx[i]);
tmp[i] = 3.0*(S[i] - S[i-1]);

Am I missing something here? Or any reference you can point me to
which derive what Quantlib implements?

Thanks,

Copy link
Contributor

github-actions bot commented Sep 2, 2024

This issue was automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment, or this will be closed in two weeks.

@github-actions github-actions bot added the stale label Sep 2, 2024
@lballabio lballabio removed the stale label Sep 2, 2024
@lballabio
Copy link
Owner

I'm no longer sure, but it might be based on Numerical Recipes in C++?

Copy link
Contributor

github-actions bot commented Nov 3, 2024

This issue was automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment, or this will be closed in two weeks.

@github-actions github-actions bot added the stale label Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants