E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches

◆ fibonacci

auto eve::fibonacci = functor<fibonacci_t>
inlineconstexpr

The sequence is defined by the recurrence relations :

  • \(f_0 = x\)
  • \(f_1 = y\)
  • \(f_{n+2} = f_{n+1} + f_{n}, n > 0\)

but is computed using the Binet formula.

Header file

#include <eve/module/combinatorial.hpp>

Callable Signatures

namespace eve
{
// Regular overload
template <floating_value T0, floating_value T1, unsigned_value N>
constexpr as_wide_as_t<common_value_t<T0, T1>, N> fibonacci(unsigned_value n,
floating_value x, floating_value y) noexcept; //1
// Lanes masking
constexpr auto fibonacci[conditional_expr auto c](/*any of the above overloads*/) noexcept; // 2
constexpr auto fibonacci[logical_value auto m](/*any of the above overloads*/) noexcept; // 2
}
Specifies that a type is a Conditional Expression.
Definition conditional.hpp:28
The concept floating_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:116
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition value.hpp:132
The concept unsigned_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:84
constexpr auto fibonacci
Computes the nth element of the Fibonacci sequence .
Definition fibonacci.hpp:86
EVE Main Namespace.
Definition abi.hpp:18

Parameters

Return value

  1. The value of the nth element of the Fibonacci sequence beginning by x and y is returned.
  2. The operation is performed conditionnaly.

External references

Example

// revision 1
#include <eve/module/combinatorial.hpp>
#include <iostream>
eve::wide<std::uint32_t> n([](auto i, auto )->std::uint32_t{ return i+2;});
eve::wide m{13u, 25u, 32u, 80u, 1u, 2u, 3u, 4u};
eve::wide a{1.0f, 2.0f, 3.0f, 4.0f, 0.5f, 0.33f, -4.5f, 0.0f};
eve::wide b{2.0f, 3.0f, 4.0f, 0.5f, 0.33f, -4.5f, 0.0f, 1.0f};
int main(){
std::cout << "<- n = " << n << "\n";
std::cout << "<- m = " << m << "\n";
std::cout << "<- a = " << a << "\n";
std::cout << "<- b = " << b << "\n";
std::cout << "-> fibonacci(n, 1.0f, 1.0f)= " << eve::fibonacci(n, 1.0f, 1.0f) << "\n";
std::cout << "-> fibonacci(m, a, b) = " << eve::fibonacci(m, a, b) << "\n";
}
Wrapper for SIMD registers.
Definition wide.hpp:86