If \((c_i)_{0\le i\le n-1}\) denotes the coefficients of the polynomial by increasing power order, the Tchebsum scheme evaluates : \(\qquad\displaystyle p(x) = c_0/2+\sum_1^n c_n T_n(x))\)
{
constexpr auto tchebsum[kahan]()
noexcept;
constexpr auto tchebsum[increasing]()
noexcept;
constexpr auto tchebsum[decreasing]()
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 widen
Computes the result in the upgraded element type.
Definition core.hpp:106
constexpr auto pedantic
Follows the corner cases of the corresponding standard function.
Definition core.hpp:91
constexpr auto tchebsum
Implement the evaluation of tchebytchev polynomials with coefficients in increasing or decreasing pow...
Definition tchebsum.hpp:120
EVE Main Namespace.
Definition abi.hpp:19
If \((c_i)_{0\le i\le n-1}\) denotes the Tchebytchev coefficients of the polynomial The Tchebsum scheme evaluates : \(\qquad\displaystyle p(x) = c_0/2+\sum_1^n c_n T_n(x))\)
#include <eve/module/math.hpp>
#include <eve/module/polynomial.hpp>
#include <iostream>
#include <array>
double tch1(auto t, auto c)
{
double u0 = 0;
double u1 = 0;
double u2 = 0;
auto tt = t+t;
for(int i=c.size()-1; i >= 0 ; --i)
{
u2=u1;
u1=u0;
u0=tt*u1+c[i]-u2;
}
return (u0-u2)/2;
}
double tch2(auto t, auto ... c)
{
double u0 = 0;
double u1 = 0;
double u2 = 0;
auto tt = t+t;
auto clemshaw_step = [&](auto ci){
u2=u1;
u1=u0;
return u0;
};
((u0 = clemshaw_step(c)), ...);
return (u0-u2)/2;
}
int main()
{
std::array<double, 4> c{1, 2, 3, 4};
std::array<double, 4> d{4.0, 3.0, 2.0, 1.0};
std::cout << tch1(-2.0, c) << std::endl;
std::cout << tch2(2.0, 4.0, 3.0, 2.0, 1.0)<< std::endl;
std::cout <<
eve::tchebsum[eve::decreasing](2.0, 4.0, 3.0, 2.0, 1.0)<< std::endl;
}
constexpr auto fma
strict_elementwise_callable computing the fused multiply add of its three parameters.
Definition fma.hpp:100
Wrapper for SIMD registers.
Definition wide.hpp:94