E.V.E
v2022.03.00

◆ tchebeval

eve::tchebeval = {}
inlineconstexpr

Evaluates a polynomial on the Tchebytchev polynomial basis.

If \((a_i)_{0\le i\le n-1}\) denotes the coefficients of the polynomial, the Tchebeval scheme evaluates the polynom \(\sum_0^{n-1} a_i T_{i}(x)\), where \(T_{i}\) is the \(i^{th}\) Tchebytchev polynomial of the first kind.

Defined in header

#include <eve/module/polynomial.hpp>

Callable Signatures

namespace eve
{
T tchebeval(T x, Cs ... cs) noexcept; // 1
template< eve::floating_real_value T, eve::range R>
T tchebeval(T x, R r) noexcept; // 2
, eve::floating_real_value V, eve::range R>
T tchebeval(T x, U a, V b, R r) noexcept; // 3
}
Definition: value.hpp:103
constexpr callable_tchebeval_ tchebeval
Evaluates a polynomial on the Tchebytchev polynomial basis.
Definition: tchebeval.hpp:80
Definition: all_of.hpp:22
  1. Evaluates the Tchebytchev polynomial using a variadic list of coefficients.
  2. Evaluates the Tchebytchev polynomial using a range of coefficients.
  3. Evaluates the Tchebytchev polynomial using a range of coefficients in interval [a,b].

Parameters

  • x : real floating argument.
  • a, b : real floating arguments. If present, they are the bounds of the interval for which the Tchebytchev polynomial must be evaluated ( -1 and 1 by default). A change of variable \( x -> \frac{2x-a-b}{b-a}\) is internally performed.
  • cs: values expansion pack associated to the coefficients \((a_i)_{0\le i \lt n}\).
  • r : range containing The polynomial coefficients.

Return value

the value of the polynom at x is returned.

Notes If the coefficients are simd values of cardinal N, this means you simultaneously compute the values of N polynomials.

  • If x is scalar, the polynomials are all computed at the same point
  • If x is simd, the nth polynomial is computed on the nth value of x

Example

#include <eve/module/polynomial.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <list>
#include <vector>
int main()
{
wide_ft xd = {-0.3, 0.5, 0.0, 2.0};
wide_ft x(0.5);
std::vector<float> v {1, -2, 3, -4};
std::list<float> l {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'
<< "-> tchebeval(xd, 1, -2, 3, -4) = " << eve::tchebeval(xd, 1.0f, -2.0f, 3.0f, -4.0f) << '\n'
<< "-> tchebeval(xd, l) = " << eve::tchebeval(xd, l) << '\n'
<< "-> tchebeval(xd, v) = " << eve::tchebeval(xd, v) << '\n'
<< "-> tchebeval(xd, wv) = " << eve::tchebeval(xd, wv) << '\n'
<< "-> tchebeval(xd, 0.0f, 1.0f, wv) = " << eve::tchebeval(xd, 0.0f, 1.0f, wv) << '\n';
double xs = 0.1;
std::cout << "---- scalar" << '\n'
<< "<- xs = " << xs << '\n'
<< "-> tchebeval(xs, 1.5, 2.0, 4.0) = " << eve::tchebeval(xs, 1.5, 2.0, 4.0) << '\n';
return 0;
}
Wrapper for SIMD registers.
Definition: wide.hpp:65