E.V.E
v2023.02.15

◆ tchebytchev

eve::tchebytchev = {}
inlineconstexpr

Computes the value of the Tchebytchev polynomial of order n at x:

  • The Tchebytchev polynomial of order n is given by \( \displaystyle \mbox{T}_{n}(x) = \cos(n\arccos(x))\) on \([-1, +1]\)

Defined in header

#include <eve/module/polynomial.hpp>

Callable Signatures

namespace eve
{
template< eve::integral_value N, eve::floating_ordered_value T >
eve::as_wide_as<T, N> tchebytchev(N n, T x) noexcept;
}
constexpr callable_tchebytchev_ tchebytchev
Computes the value of the Tchebytchev polynomial of order n at x:
Definition: tchebytchev.hpp:79
Definition: abi.hpp:18

Parameters

Return value

The value of the polynomial at x is returned.

Example

#include <eve/module/polynomial.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft xd = {0.5, -1.5, 0.1, -1.0, 19.0, 25.0, 21.5, 10000.0};
wide_it n = {0, 1, 2, 3, 4, 5, 6, 7};
wide_ft x(0.5);
std::cout << "---- simd" << '\n'
<< "<- xd = " << xd << '\n'
<< "<- n = " << n << '\n'
<< "<- x = " << x << '\n'
<< "-> tchebytchev(n, xd) = " << eve::tchebytchev(n, xd) << '\n'
<< "-> tchebytchev(3, xd) = " << eve::tchebytchev(3, xd) << '\n'
<< "-> tchebytchev(n, 2.0) = " << eve::tchebytchev(n, 2.0) << '\n'
<< "-> tchebytchev(n, x) = " << eve::tchebytchev(n, x) << '\n'
;
double xs = 3.0;
std::cout << "---- scalar" << '\n'
<< "<- xs = " << xs << '\n'
<< "-> tchebytchev(4, xs) = " << eve::tchebytchev(4.0, xs) << '\n';
return 0;
}
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • eve::kind_1, eve::kind_2

    The expression kind_1(tchebytchev)(n,x) is identical to tchebytchev(n,x). The expression kind_2(tchebytchev)(n,x) evaluates the nth polynomial of tchebytchev of second kind \( \displaystyle U_n(x) = \frac{\sin(n\arccos x)}{\sin(\arccos x)}\) at x on \([-1, +1]\).

    Example

    #include <eve/module/polynomial.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_ft xd = {0.5, -1.5, 0.1, -1.0, 19.0, 25.0, 21.5, 10000.0};
    wide_it n = {0, 1, 2, 3, 4, 5, 6, 7};
    wide_ft x(0.5);
    std::cout << "---- simd" << '\n'
    << "<- xd = " << xd << '\n'
    << "<- n = " << n << '\n'
    << "<- x = " << x << '\n'
    << "-> kind_2(tchebytchev)(n, xd) = " << eve::kind_2(eve::tchebytchev)(n, xd) << '\n'
    << "-> kind_2(tchebytchev)(3, xd) = " << eve::kind_2(eve::tchebytchev)(3, xd) << '\n'
    << "-> kind_2(tchebytchev)(n, 2.0) = " << eve::kind_2(eve::tchebytchev)(n, 2.0) << '\n'
    << "-> kind_2(tchebytchev)(n, x) = " << eve::kind_2(eve::tchebytchev)(n, x) << '\n'
    ;
    double xs = 3.0;
    std::cout << "---- scalar" << '\n'
    << "<- xs = " << xs << '\n'
    << "-> kind_2(tchebytchev)(4, xs) = " << eve::kind_2(eve::tchebytchev)(4, xs) << '\n';
    return 0;
    }
    constexpr kind_2_type const kind_2
    Higher-order Callable Object imbuing kind_2 behaviour onto other Callable Objects.
    Definition: kind.hpp:130
  • eve::successor

    The expression successor(tchebytchev)( x, tn, tnm1) computes the value of \(T_{n+1}(x)\) knowing the values tn = \(T_n(x)\) and tnm1 = \(T_{n-1}(x)\),

    This function can be used to create a sequence of values evaluated at the same x and for rising n.

    Example

    #include <eve/module/polynomial.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_ft xd = {0.5, -1.5, 0.1, -1.0, 19.0, 25.0, 21.5, 10000.0};
    wide_it n = {0, 1, 2, 3, 4, 5, 6, 7};
    std::cout << "---- simd" << '\n'
    << "<- xd = " << xd << '\n'
    << "<- n = " << n << '\n';
    std::array<wide_ft, 8> t;
    t[0] = eve::tchebytchev(0, xd);
    std::cout << "-> t[0] = " << t[0] << '\n';
    std::cout << "-> tchebytchev(" << 0 << ", xd) = " << eve::tchebytchev(0, xd) << '\n';
    t[1] = eve::tchebytchev(1, xd);
    std::cout << "-> tchebytchev(" << 1 << ", xd) = " << eve::tchebytchev(1, xd) << '\n';
    std::cout << "-> t[1] = " << t[1] << '\n';
    for(int i = 2; i <= 7; ++i)
    {
    t[i] = eve::successor(eve::tchebytchev)(xd, t[i-1], t[i-2]);
    std::cout << "-> t[" << i << "] = " << t[i] << '\n';
    std::cout << "-> tchebytchev(" << i << ", xd) = " << eve::tchebytchev(i, xd) << '\n';
    }
    return 0;
    }
    constexpr callable_i_ i
    Callable object computing the pure imaginary ( ) value.
    Definition: i.hpp:52
    constexpr successor_type const successor
    Higher-order Callable Object imbuing incrementation behaviour onto other Callable Objects.
    Definition: successor.hpp:42