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

Use Dijkstra identities for 0(0th) Fibonacci convention #1001

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/boost/math/special_functions/fibonacci.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ inline BOOST_CXX14_CONSTEXPR T unchecked_fibonacci(unsigned long long n) noexcep
if (n <= 2) return n == 0 ? 0 : 1;
/*
* This is based on the following identities by Dijkstra:
* F(2*n) = F(n)^2 + F(n+1)^2
* F(2*n+1) = (2 * F(n) + F(n+1)) * F(n+1)
* F(2*n-1) = F(n-1)^2 + F(n)^2
* F(2*n) = (2*F(n-1) + F(n)) * F(n)
* The implementation is iterative and is unrolled version of trivial recursive implementation.
*/
unsigned long long mask = 1;
Expand Down