If \((c_i)_{0\le i\le n-1}\) denotes the coefficients of the polynomial by decreasing power order, the Horner scheme evaluates the polynom \(p\) at \(x\) by :
\(\qquad\displaystyle p(x) = (((c_0x+c_1)x+ ... )x + c_{n-1})\)
{
constexpr auto horner[pedantic]()
noexcept;
constexpr auto horner[kahan]()
noexcept;
constexpr auto horner[widen]()
noexcept;
}
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:134
The concept value<T> is satisfied if and only if T satisfies either eve::scalar_value or eve::simd_va...
Definition value.hpp:34
constexpr auto any
Computes a bool value which is true if and only if one or more elements of x evaluates to true.
Definition any.hpp:96
constexpr auto horner
Implement the horner scheme to evaluate polynomials with coefficients in decreasing power order.
Definition horner.hpp:120
typename decltype(detail::as_translated_type(as< T >{}))::type translate_t
Returns the final translated type of T.
Definition translation.hpp:107
EVE Main Namespace.
Definition abi.hpp:19
If \((c_i)_{0\le i\le n-1}\) denotes the coefficients of the polynomial by decreasing power order, the Horner scheme evaluates the polynom \(p\) at \(x\) by : \(\qquad\qquad\displaystyle p(x) = (((c_0x+c_1)x+ ... )x + c_{n-1})\)
#include <eve/module/math.hpp>
#include <iostream>
#include <iomanip>
{
kumi::tuple v {1.0, -2.0, 3.0, -4.0};
using w_t =
decltype(
xd);
kumi::tuple
wv{
w_t{1.5, 1, 2, 3},
w_t{4, 5, 6, 7},
w_t{8, 9, 10, 11} };
auto t =kumi::tuple{1.5,4.0,8.0};
std::cout <<
"<- xd = " <<
xd <<
'\n';
std::cout <<
"<- x = " <<
x <<
'\n';
std::cout << "<- v = " << v << '\n';
std::cout <<
"<- wv = " <<
wv <<
'\n';
std::cout <<
"<- b = " <<
b <<
'\n';
std::cout <<
"-> horner(xd, 1.0, -2.0, 3.0, -4.0) = " <<
eve::horner(
xd, 1.0, -2.0, 3.0, -4.0) <<
'\n';
std::cout <<
"-> horner(0.5, 1, b, 3, -4) = " <<
eve::horner(0.5, 1,
b, 3, -4) <<
'\n';
std::cout <<
"-> horner(xd, 1, -2, 3, -4) = " <<
eve::horner(
xd, 1, -2, 3, -4) <<
'\n';
std::cout <<
"-> horner(xd, eve::coefficients(v)) = " <<
eve::horner(
xd, eve::coefficients(v)) <<
'\n';
std::cout <<
"-> horner(xd, eve::coefficients(t)) = " <<
eve::horner(
xd, eve::coefficients(
t)) <<
'\n';
std::cout <<
"-> horner(x, eve::coefficients(t)) = " <<
eve::horner(
x, eve::coefficients(
t)) <<
'\n';
std::cout <<
"-> horner(w_t(x), eve::coefficients(t)) = " <<
eve::horner(
w_t(
x), eve::coefficients(
t)) <<
'\n';
std::cout <<
"-> horner(x, eve::coefficients(wv)) = " <<
eve::horner(
x, eve::coefficients(
wv)) <<
'\n';
std::cout <<
"-> horner(0.5f, eve::coefficients(wv)) = " <<
eve::horner(0.5, eve::coefficients(
wv)) <<
'\n';
std::cout <<
"-> horner(xd, eve::coefficients(wv)) = " <<
eve::horner(
xd, eve::coefficients(
wv)) <<
'\n';
std::cout <<
"-> horner(2.0, eve::coefficients(t)) = " <<
eve::horner(2.0, eve::coefficients(
t)) <<
'\n';
std::cout <<
"-> horner(2.0,1.5,4.0,8.0) = " <<
eve::horner(2.0, 1.5,4.0,8.0) <<
'\n';
std::cout <<
"-> horner(w_t(2.0),1.5,4.0,8.0) = " <<
eve::horner(
w_t(2.0), 1.5,4.0,8.0) <<
'\n';
}
Wrapper for SIMD registers.
Definition wide.hpp:94