◆ horner
Callable object computing the horner operation. Required header: Members Functions
auto operator()(value auto x, std::inputiterator auto first, std::inputiterator auto sentinel) const noexcept;
auto operator()(value auto x, callable_one_ const & o, std::inputiterator auto first, std::inputiterator auto sentinel) const noexcept;
Definition: value.hpp:31 Parameters
Return value Returns elementwise the value of polynomial function(s) represented by the coefficients in decreasing power order at The result type is of the compatibility type of the coefficients and the evaluation value
auto operator[]( conditional_expression auto cond ) const noexcept;
Higher-order function generating a masked version of eve::horner Parameters
Return value A Callable object so that the expression Supported decorators
ExampleSee it live on Compiler Explorer #include <eve/function/horner.hpp>
#include <eve/wide.hpp>
#include <eve/constant/one.hpp>
#include <iostream>
#include <list>
#include <vector>
using wide_ft = eve::wide<float, eve::fixed<4>>;
using wide_it = eve::wide<int , eve::fixed<8>>;
int main()
{
wide_ft xd = {-0.3, 0.5, 0.0, 2.0};
wide_ft b = {-2, 10.5, -4, 0.1};
wide_ft x(0.5);
std::vector<float> v {1, -2, 3, -4};
std::list<float> l {1, -2, 3, -4};
float ca[4] = {1, -2, 3, -4};
std::vector<wide_ft> wv { {0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11} };
std::cout << "---- simd" << '\n'
<< "<- xd = " << xd << '\n'
<< "<- x = " << x << '\n'
<< "<- l and v contain {1, -2, 3, -4} "<< '\n'
<< "<- wv contains { {0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11} }"<< '\n'
<< "-> horner(xd, std::begin(ca), std::end(ca)) = " << eve::horner(xd, std::begin(ca), std::end(ca) ) << '\n'
;
double xs = 0.1;
std::cout << "---- scalar" << '\n'
<< "<- xs = " << xs << '\n'
return 0;
}
constexpr callable_horner_ horner Callable object computing the horner operation. Definition: horner.hpp:107 |