-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Precompute annuities #1965
Precompute annuities #1965
Conversation
Thanks for opening this pull request! It might take a while before we look at it, so don't worry if there seems to be no feedback. We'll get to it. |
for (Size k=0; k<numberOfFactors_; ++k) { | ||
// taken care in the constructor | ||
// wkpj1_[k][numberOfRates_-1]= 0.0; | ||
// wkaj_[k][numberOfRates_-1] = 0.0; | ||
for (Integer j=numberOfRates_-2; j>=static_cast<Integer>(alive_)-1; --j) { | ||
// < W(k) | P(j+1)/P(n) > = | ||
// = SR(j+1) a(j+1,k) A(j+1) / P(n) + SR(j+1) < W(k) | A(j+1)/P(n) > | ||
Real annuity = cs.coterminalSwapAnnuity(numberOfRates_,j+1); | ||
Real annuity = annuities[j+1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the same vector annuities
be used also in the other loop ~20 lines below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I'll make that change too, thanks for pointing it out. In fact the quantitative results stated above were including this change, but I forgot to add it when making the final PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks.
5f3b8e0
to
3dabf86
Compare
Congratulations on your first merged pull request! |
Pre-computation of Annuities: The updated code introduces a pre-computation of annuities for all rates and stores them in a vector. This avoids repeated calls to
cs.coterminalSwapAnnuity()
within the nested loops, potentially reducing computational overhead and improving performance.Corresponding unit test runs ~30% faster on a single processor (standard build, g++ 11.4.0)