◆ fibonacci
Callable object computing the nth value of the fibonacci sequence. Required header: Members Functions
template< floating_value T, floating_value U, unsigned_value N > auto operator()( T x, U y, N n ) const noexcept requires compatible< T, U >;
Parameters
Return value The result type is the common compatible type of the two first parameters, vectorized with the cardinality of the third one if necessary. The recurrence formula defining the fibonacci sequence is: - r(0) = x - r(1) = y - r(i+2) = r(i+1)+r(i), i > 2 The function return elementwise r(n), but the result is computed using the Binet formula. auto operator[]( conditional_expression auto cond ) const noexcept;
Higher-order function generating a masked version of eve::fibonacci Parameters
Return value A Callable object so that the expression Supported decoratorsno decorators are supported ExampleSee it live on Compiler Explorer #include <eve/function/fibonacci.hpp>
#include <eve/wide.hpp>
#include <iomanip>
#include <iostream>
int main()
{
using w32_t = eve::wide<std::uint16_t, eve::fixed<8>>;
w32_t n = {13, 25, 32, 180, 1, 2, 3, 4};
using wf32_t = eve::wide<float, eve::fixed<8>>;
wf32_t a = {1, 2, 3, 4, 0.5, 0.33, -4.5, 0};
wf32_t b = {2, 3, 4, 0.5, 0.33, -4.5, 0, 1};
std::cout << "---- simd" << '\n'
<< " <- n = " << n << '\n'
<< " <- a = " << a << '\n'
<< " <- b = " << b << '\n'
std::uint32_t ns = 10;
float as = 1;
float bs = 1;
std::cout << "---- scalar" << '\n'
<< " ns = " << ns << '\n'
<< " as = " << as << '\n'
<< " bs = " << bs << '\n'
return 0;
}
constexpr callable_fibonacci_ fibonacci Callable object computing the nth value of the fibonacci sequence. Definition: fibonacci.hpp:83 |