E.V.E
v2023.02.15
Loading...
Searching...
No Matches
Polynomial functions

Detailed Description

This module provides implementation for scalar and SIMD versions of polynomial evaluation functions.

Convenience header:

#include <eve/module/polynomial.hpp>

Variables

constexpr auto eve::newton = functor<newton_t>
 Implement the Newton scheme to evaluate polynomials.
constexpr auto eve::abel = functor<abel_t>
 Computes the value of the Abel function of order n at x: \(x(x-an)^{n-1}\). for positive integer n it is Abel polynomial.
constexpr auto eve::gegenbauer = functor<gegenbauer_t>
 strict_elementwise_callable object computing the value of a gegenbauer polynomial \( \mathbf{C}_n^\lambda(x)\).
constexpr auto eve::hermite = functor<hermite_t>
 strict_elementwise_callable object computing the value of the 'physicists' Hermite polynomial of order n at x:
constexpr auto eve::jacobi = functor<jacobi_t>
 strict_elementwise_callable object computing the value of the Jacobi polynomials \(P^{\alpha, \beta}_n(x)\).
constexpr auto eve::laguerre = functor<laguerre_t>
 strict_elementwise_callable object computing the value of the Laguerre and associated Laguerre polynomials of order n at x:
constexpr auto eve::legendre = functor<legendre_t>
 Computes the value of the Legendre and associated Legendre polynomials of order n at x:
constexpr auto eve::tchebytchev = functor<tchebytchev_t>
 Computes the value of the Tchebytchev polynomial of order n at x:

Variable Documentation

◆ abel

auto eve::abel = functor<abel_t>
inlineconstexpr

Computes the value of the Abel function of order n at x: \(x(x-an)^{n-1}\). for positive integer n it is Abel polynomial.

Header file

#include <eve/module/polynomial.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto abel(integral_value auto n, floating_value auto x, floating_value auto a) noexcept; // 1
// Lanes masking
constexpr auto abel[conditional_expr auto c](integral_value auto n, floating_value auto x, floating_value auto a) noexcept; // 2
constexpr auto abel[logical_value auto m](integral_value auto n, floating_value auto x, floating_value auto a) noexcept; // 2
}
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 integral_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:51
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition value.hpp:134
constexpr auto abel
Computes the value of the Abel function of order n at x: . for positive integer n it is Abel polynomi...
Definition abel.hpp:74
EVE Main Namespace.
Definition abi.hpp:19

Parameters

Return value

1.The value of the polynomial at x is returned.

  1. The operation is performed conditionally.

External references

Example

// revision 1
#include <eve/module/polynomial.hpp>
#include <iostream>
int main()
{
eve::wide wx = {-1.0f, 0.0f, 1.0f, 2.0f};
eve::wide wa = {0.0f, 1.0f, 2.0f, 3.0f};
eve::wide wn = {0, 1, 2, 3};
std::cout << "<- wx = " << wx << "\n";
std::cout << "<- wa = " << wa<< "\n";
std::cout << "<- wn = " << wn << "\n";
std::cout << "-> abel(wn, wx, wa) = " << eve::abel(wn, wx, wa) << "\n";
std::cout << "-> abel(wa, wx, wa) = " << eve::abel(wa, wx, wa) << "\n";
std::cout << "-> abel[ignore_last(2)](wa, wx, wa) = " << eve::abel[eve::ignore_last(2)](wa, wx, wa) << "\n";
std::cout << "-> abel[wx != 2.0f](wa, wx, wa) = " << eve::abel[wx != 2.0f](wa, wx, wa) << "\n";
}
Conditional expression ignoring the k last lanes from a eve::simd_value.
Definition conditional.hpp:361
Wrapper for SIMD registers.
Definition wide.hpp:94

◆ gegenbauer

auto eve::gegenbauer = functor<gegenbauer_t>
inlineconstexpr

strict_elementwise_callable object computing the value of a gegenbauer polynomial \( \mathbf{C}_n^\lambda(x)\).

Defined in header

#include <eve/module/polynomial.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto gegenbauer(integral_value auto n, floating_value auto lambda,
floating_value auto x) noexcept; //1
// Lanes masking
constexpr auto gegenbauer[conditional_expr auto c](integral_value auto n, floating_value auto lambda,
floating_value auto x) noexcept; // 2
constexpr auto gegenbauer[logical_value auto m](integral_value auto n, floating_value auto lambda,
floating_value auto x) noexcept; // 2
}
constexpr auto gegenbauer
strict_elementwise_callable object computing the value of a gegenbauer polynomial .
Definition gegenbauer.hpp:95

Parameters

Return value

  1. The value of \( \mathbf{C}_n^\lambda(x)\) is returned.

    The Gegenbauer polynomials are a sequence of orthogonal polynomials relative to \((1-x^2)^{\lambda-1/2}\) on the \([-1, +1]\) interval satisfying the following recurrence relation:

    • \( \mathbf{C}_0^\lambda(x) = 1\).
    • \( \mathbf{C}_1^\lambda(x) = 2\lambda x\).
    • \( \mathbf{C}_n^\lambda(x) = \left[(2x+\lambda-1)\mathbf{C}_{n-1}^\lambda(x) - (n+2\lambda-2)\mathbf{C}_{n-2}^\lambda(x)\right]/n\).
  2. The operation is performed conditionally.

External references

Example

// revision 1
#include <eve/module/polynomial.hpp>
#include <iostream>
int main()
{
eve::wide xd{0.5, -1.5, 0.1, -1.0, 19.0, 25.0, 21.5, 10000.0};
eve::wide n{0, 1, 2, 3, 4, 5, 6, 7};
double l(-3.0/8.0);
std::cout << "<- xd = " << xd << "\n";
std::cout << "<- n = " << n << "\n";
std::cout << "<- l = " << l << "\n";
std::cout << "-> gegenbauer(n, l, xd) = " << eve::gegenbauer(n, l, xd) << '\n';
std::cout << "-> gegenbauer[ignore_last(2)](n, l, xd)= " << eve::gegenbauer[eve::ignore_last(2)](n, l, xd) << '\n';
std::cout << "-> gegenbauer[n > 3](n, l, xd) = " << eve::gegenbauer[n > 3](n, l, xd) << '\n';
std::cout << "-> gegenbauer(3, l, xd) = " << eve::gegenbauer(3, l, xd) << '\n';
std::cout << "-> gegenbauer(n, l, 0.3) = " << eve::gegenbauer(n, l, 0.3) << '\n';
}

◆ hermite

auto eve::hermite = functor<hermite_t>
inlineconstexpr

strict_elementwise_callable object computing the value of the 'physicists' Hermite polynomial of order n at x:

The physicists Hermite polynomials are a sequence of orthogonal polynomials relative to \(e^{-x^2}\) on the \([-\infty, +\infty]\) interval satisfying the following recurrence relation:

  • \( \mathbf{H}_0(x) = 1\).
  • \( \mathbf{H}_1(x) = 2x\).
  • \( \mathbf{H}_n(x) = 2x\mathbf{H}_{n-1}(x) -2(n-1)\mathbf{H}_{n-2}x\).

Callable Signatures

#include <eve/module/polynomial.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto hermite(integral_value auto n, floating_value auto x) noexcept; //1
// Lanes masking
constexpr auto hermite[conditional_expr auto c](integral_value auto n, floating_value auto x) noexcept; // 2
constexpr auto hermite[logical_value auto m](integral_value auto n, floating_value auto x) noexcept; // 2
// Semantic option
constexpr auto hermite(integral_value auto n, floating_value auto x,
floating_value auto hn, floating_value auto hnm1) noexcept; // 3
}
constexpr auto hermite
strict_elementwise_callable object computing the value of the 'physicists' Hermite polynomial of orde...
Definition hermite.hpp:108

Parameters

Return value

  1. The value of the 'physicists' hermite polynomial \( \displaystyle \mathbf{H}_n(x) = (-1)^n e^{x^2}\frac{d}{dx^n}e^{-x^2}\) is returned.
  2. The operation is performed conditionally.
  3. implements the three terms recurrence relation for the physicists Hermite polynomials, \(\displaystyle \mbox{H}_{n+1} = (2*x)\mbox{H}_{n}-2*n\mbox{H}_{n-1}\). This call can be used to create a sequence of values evaluated at the same x, and for rising n.

External references

Example

// revision 0
#include <eve/module/polynomial.hpp>
#include <iostream>
#include <array>
int main()
{
eve::wide xd = {0.5, -1.5, 0.1, -1.0, 19.0, 25.0, 21.5, 10000.0};
eve::wide n = {0, 1, 2, 3, 4, 5, 6, 7};
eve::wide x(2.0);
std::cout << "<- xd = " << xd << "\n";
std::cout << "<- n = " << n << "\n";
std::cout << "-> hermite(n, xd) = " << eve::hermite(n, xd) << "\n";
std::cout << "-> hermite[ignore_last(2)](n, xd) = " << eve::hermite[eve::ignore_last(2)](n, xd) << "\n";
std::cout << "-> hermite[n != 4](n, xd) = " << eve::hermite[n != 4](n, xd) << "\n\n";
using wide_ft = decltype(xd);
std::array<wide_ft, 8> h;
h[0] = eve::hermite(0, xd);
std::cout << "-> h[0] = " << h[0] << '\n';
std::cout << "-> hermite(" << 0 << ", xd) = " << eve::hermite(0, xd) << '\n';
h[1] = eve::hermite(1, xd);
std::cout << "-> hermite(" << 1 << ", xd) = " << eve::hermite(1, xd) << '\n';
std::cout << "-> h[1] = " << h[1] << '\n';
for(int i = 2; i <= 7; ++i)
{
h[i] = eve::hermite[eve::successor](i-1, xd, h[i-1], h[i-2]);
std::cout << "-> h[" << i << "] = " << h[i] << '\n';
std::cout << "-> hermite(" << i << ", xd) = " << eve::hermite(i, xd) << '\n';
}
}

◆ jacobi

auto eve::jacobi = functor<jacobi_t>
inlineconstexpr

strict_elementwise_callable object computing the value of the Jacobi polynomials \(P^{\alpha, \beta}_n(x)\).

Defined in header

#include <eve/module/polynomial.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto jacobi(integral_value auto n, floating_value auto x,
floating_value auto alpha, floating_value auto beta) noexcept; // 1
// Lanes masking
constexpr auto jacobi[conditional_expr auto c](integral_value auto n, floating_value auto x,
floating_value auto alpha, floating_value auto beta) noexcept; // 2
constexpr auto jacobi[logical_value auto m](integral_value auto n, floating_value auto x,
floating_value auto alpha, floating_value auto beta) noexcept; // 2
}
constexpr auto jacobi
strict_elementwise_callable object computing the value of the Jacobi polynomials .
Definition jacobi.hpp:92
constexpr auto beta
elementwise_callable object computing the beta function: .
Definition beta.hpp:79

Parameters

Return value

The Jacobi polynomials are a sequence of orthogonal polynomials relative to \((1-x)^{\alpha}(1+x)^{\beta}\), for \(\alpha \) and \(\beta \) greater than -1, on the \([-1, +1]\) interval.

They can be defined via a Rodrigues formula: \(\displaystyle P^{\alpha, \beta}_n(x) = \frac{(-1)^n}{2^n n!}(1-x)^{-\alpha} (1+x)^{-\beta} \frac{d}{dx^n}\left\{ (1-x)^{\alpha}(1+x)^{\beta}(1-x^2)^n \right\}\).

  1. The value of the polynomial \(P^{\alpha, \beta}_n(x)\) is returned.
  2. The operation is performed conditionally.

External references

Example

// revision 0
#include <eve/module/polynomial.hpp>
#include <iostream>
int main()
{
eve::wide xd{0.5, -1.5, 0.1, -1.0, 19.0, 25.0, 21.5, 10000.0};
eve::wide n{0, 1, 2, 3, 4, 5, 6, 7};
eve::wide n1{0.5, -3.0, 2.0, 3.0};
eve::wide aa{-0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0};
double x(0.5);
double a(-3/8.0);
double b(0.25);
std::cout << "<- xd = " << xd << '\n';
std::cout << "<- n = " << n << '\n';
std::cout << "<- n1 = " << n1 << '\n';
std::cout << "<- x = " << x << '\n';
std::cout << "<- aa = " << aa << '\n';
std::cout << "<- a = " << a << '\n';
std::cout << "<- b = " << b << '\n';
std::cout << "-> jacobi(n, a, b, xd) = " << eve::jacobi(n, a, b, xd) << '\n';
std::cout << "-> jacobi[ignore_last(2)](n, a, b, xd)= " << eve::jacobi[eve::ignore_last(2)](n, a, b, xd) << '\n';
std::cout << "-> jacobi[n > 3](n, a, b, xd) = " << eve::jacobi[n > 3](n, a, b, xd) << '\n';
std::cout << "-> jacobi(4, a, b, xd) = " << eve::jacobi(4, a, b, xd) << '\n';
std::cout << "-> jacobi(4, a, b, x) = " << eve::jacobi(4, a, b, x) << '\n';
std::cout << "-> jacobi(n, a, b 0.5) = " << eve::jacobi(n, a, b, 0.5) << '\n';
std::cout << "-> jacobi(n, a, b, x) = " << eve::jacobi(n, a, b, x) << '\n';
std::cout << "-> jacobi(n, aa, b, x) = " << eve::jacobi(n, aa, b, x) << '\n';
std::cout << "-> jacobi(n1, a, b, x) = " << eve::jacobi(n1, a, b, x) << '\n';
std::cout << "-> jacobi(-3.0, a, b, x) = " << eve::jacobi(-3.0, a, b, x) << '\n';
}

◆ laguerre

auto eve::laguerre = functor<laguerre_t>
inlineconstexpr

strict_elementwise_callable object computing the value of the Laguerre and associated Laguerre polynomials of order n at x:

  • The Laguerre polynomial of order n is given by \(\displaystyle \mbox{L}_{n}(x) = \frac{e^x}{n!}\frac{d^n}{dx^n}(x^ne^{-x})\).
  • The associated laguerre polynomial is given by \(\displaystyle \mbox{L}_{n}^{m} = (-1)^m\frac{d^m}{dx^m}\mbox{L}_{n+m}(x)\).

Header file

#include <eve/module/polynomial.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto laguerre(integral_value auto n, floating_value auto x) noexcept; //1
// Semantic options
constexpr auto laguerre[associated](integral_value auto n, integral_value auto m,
floating_value auto x) noexcept; // 2
constexpr auto laguerre[successor](integral_value auto n,
integral_value auto ln, integral_value auto lnm1) noexcept; // 3
constexpr auto laguerre[successor](integral_value auto n, integral_value auto l,
integral_value auto ln, integral_value auto lnm1) noexcept; // 3
constexpr auto laguerre[associated][successor](integral_value auto n,
integral_value auto m, floating_value auto x) noexcept; // 4
}
constexpr auto laguerre
strict_elementwise_callable object computing the value of the Laguerre and associated Laguerre polyno...
Definition laguerre.hpp:99

Parameters

Return value

  1. The value of the Laguerre polynomial of order n at x is returned.
  2. The value of the associated Laguerre polynomial of orders n, m at x is returned. constexpr auto legendre(integral_value auto n, floating_value auto x) noexcept; //1
  3. implements the three term recurrence relation for the Laguerre polynomials, \(\displaystyle \mbox{L}_{n+1} = \left((2n+1-x)\mbox{L}_{n}-n\mbox{L}_{n-1}\right)/(n+1)\)
  4. implements the three term recurrence relation for the associated Laguerre polynomials, \(\displaystyle \mbox{L}_{n+1}^m = \left((m+2n+1-x)\mbox{L}_{n}^{m}-(m+n)\mbox{L}_{n-1}^{m}\right)/(n+1)\)

External references

Example

// revision 1
#include <eve/module/polynomial.hpp>
#include <iostream>
int main()
{
eve::wide n{0, 1, 2, 3, 4, 5, 6, 7};
eve::wide m{0, 1, 2, 3, 4, 5, 6, 7};
eve::wide xd{0.5, -1.5, 0.1, -1.0, 19.0, 25.0, 21.5, 10000.0};
double x(0.5);
std::cout << "<- n = " << n << '\n';
std::cout << "<- m = " << m << '\n';
std::cout << "<- xd = " << xd << '\n';
std::cout << "<- x = " << x << '\n';
std::cout << "-> laguerre(n, xd) = " << eve::laguerre(n, xd) << '\n';
std::cout << "-> laguerre[ignore_last(2)](n, xd) = " << eve::laguerre[eve::ignore_last(2)](n, xd) << '\n';
std::cout << "-> laguerre[n > 3](n, xd) = " << eve::laguerre[n > 3](n, xd) << '\n';
std::cout << "-> laguerre(3, xd) = " << eve::laguerre(3, xd) << '\n';
std::cout << "-> laguerre(n, x) = " << eve::laguerre(n, x) << '\n';
std::cout << "-> laguerre[associated](n, m, xd) = " << eve::laguerre[eve::associated](n, m, xd) << '\n';
std::cout << "-> laguerre[associated](3, m, xd) = " << eve::laguerre[eve::associated](3, m, xd) << '\n';
std::cout << "-> laguerre[associated](n, 3, xd) = " << eve::laguerre[eve::associated](n, 3, xd) << '\n';
std::cout << "-> laguerre[associated](n, m, x) = " << eve::laguerre[eve::associated](n, m, x) << '\n';
}

◆ legendre

auto eve::legendre = functor<legendre_t>
inlineconstexpr

Computes the value of the Legendre and associated Legendre polynomials of order n at x:

  • The Legendre polynomial of order n is given by \(\displaystyle \mbox{L}_{n}(x) = \frac{e^x}{n!}\frac{d^n}{dx^n}(x^ne^{-x})\).
  • The associated legendre polynomial is given by \(\displaystyle \mbox{L}_{n}^{m} = (-1)^m\frac{d^m}{dx^m}\mbox{L}_{n+m}(x)\).

Defined in header

#include <eve/module/polynomial.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto legendre(integral_value auto n, floating_value auto x) noexcept; // 1
// Semantic options
constexpr auto legendre[p_kind](integral_value auto n, floating_value auto x) noexcept; // 1
constexpr auto legendre[q_kind](integral_value auto n, floating_value auto x) noexcept; // 2
constexpr auto legendre[associated](integral_value auto n,
floating_value auto x) noexcept; // 3
constexpr auto legendre[condon_shortley](integral_value auto n,
floating_value auto x) noexcept; // 4
constexpr auto legendre[sph](integral_value auto l, integral_value auto m,
floating_value auto theta) noexcept; // 5
constexpr auto legendre[successor](integral_value auto l,
integral_value auto ln, integral_value lnm1) noexcept; // 6
constexpr auto legendre[successor](integral_value auto l,integral_value auto m,
integral_value auto ln, integral_value lnm1) noexcept; // 6
}
constexpr auto legendre
Computes the value of the Legendre and associated Legendre polynomials of order n at x:
Definition legendre.hpp:124

Parameters

Return value

  1. The value of the Legendre polynomial of order n at x is returned.
  2. The value of the Legendre polynomial of order n at x of the second kind is returned.
  3. The value of the associated legendre polynomial of orders n, m at x is returned.
  4. multiplies the associated legendre polynomial value by the Condon-Shortley phase \((-1)^m\) to match the definition given by Abramowitz and Stegun (8.6.6). This is currently the version implemented in boost::math.
  5. returns the spherical associated Legendre function of degree l, order m, and polar angle theta in radian (that is the classical spherical harmonic with \(\phi = 0\)), i.e. \(\displaystyle (-1)^m\frac{(2l+1)(l-m)!}{4\pi(l+m)!}\mbox{P}^m_{l}(\cos\theta)\)
  6. The successor option implements the three term recurrence relation for the (associated) Legendre polynomials, \(\displaystyle \mbox{P}^m_{l+1} = \left((2l+1)\mbox{P}^m_{l}(x)-l\mbox{P}^m_{l-1}(x)\right)/(l+m+1)\) ( \(m = 0\) and no \(m\) in call are equivalent here).

External references

Example

// revision 1
#include <eve/module/polynomial.hpp>
#include <iostream>
int main()
{
eve::wide n = {0, 1, 2, 3, 4, 5, 6, 7};
eve::wide xd = {-0.1, -0.2, -0.3, -0.5, 0.0, 0.2, 0.3, 2.0};
double x(0.5);
double z(1);
std::cout << "<- xd = " << xd << '\n';
std::cout << "<- n = " << n << '\n';
std::cout << "<- x = " << x << '\n';
std::cout << "<- z = " << z << '\n';
std::cout << "-> legendre(n, xd) = " << eve::legendre(n, xd) << '\n';
std::cout << "-> legendre[ignore_last(2)](n, xd) = " << eve::legendre[eve::ignore_last(2)](n, xd) << "\n";
std::cout << "-> legendre[n > 3](n, xd) = " << eve::legendre[n > 3](n, xd) << "\n";
std::cout << "-> legendre(3, xd) = " << eve::legendre(3, xd) << '\n';
std::cout << "-> legendre(n, 0.5) = " << eve::legendre(n, 0.5) << '\n';
std::cout << "-> legendre(n, x) = " << eve::legendre(n, x) << '\n';
std::cout << "-> legendre[p_kind](n, xd) = " << eve::legendre[eve::p_kind](n, xd) << '\n';
std::cout << "-> legendre[q_kind](n, xd) = " << eve::legendre[eve::q_kind](n, xd) << '\n';
std::cout << "-> legendre[spherical](n, z, xd) = " << eve::legendre[eve::spherical](n, z, xd) << '\n';
std::cout << "-> legendre[associated(n, z, xd) = " << eve::legendre[eve::associated](n, z, xd) << '\n';
std::cout << "-> legendre[condon_shortley(n, z, xd = " << eve::legendre[eve::condon_shortley](n, z, xd) << '\n';
}
constexpr auto spherical
Selects the spherical form of a Bessel function.
Definition core.hpp:97

◆ newton

auto eve::newton = functor<newton_t>
inlineconstexpr

Implement the Newton scheme to evaluate polynomials.

If \((c_i)_{0\le i\le n-1}\) denotes the coefficients of the polynomial by decreasing power order, and \((m_i)_{0\le i\le n-2}\) the nodes, the Newton scheme evaluates the polynom \(p\) at \(x\) using the following formula :

\(\qquad\displaystyle p(x) = (((c_0(x-m_0)+c_1)(x-m_1)+ ... )(x-m_{n-2}) + c_{n-1})\)

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto newton(floating_value auto x, floating_value auto ... cmi) noexcept; // 1
constexpr auto newton(floating_value auto x, eve::coefficients ci
eve::nodes auto ni) noexcept; // 2
// Lanes masking
constexpr auto newton[conditional_expr auto c](/*any of the above overloads*/) noexcept; // 3
constexpr auto newton[logical_value auto m](/*any of the above overloads*/) noexcept; // 3
// Semantic options
constexpr auto newton[pedantic](/*any of the above overloads*/) noexcept; // 4
}
constexpr auto pedantic
Follows the corner cases of the corresponding standard function.
Definition core.hpp:91
constexpr auto newton
Implement the Newton scheme to evaluate polynomials.
Definition newton.hpp:116

Parameters

  • x: real floating argument.
  • ci: eve::coefficients tuple containing the coefficients by decreasing power order.
  • cn: eve::nodes tuple containing the nodes by decreasing power order.
  • cni...: all the coefficients followed by all the nodes, both in decreasing power order. The total number of values is to be odd. If s is this number, the (s+1)/2 first are taken as the coefs and the others are the nodes. Note that the values of the cmi are not necessarily floating but the non floating ones are to be scalar
  • c: Conditional expression masking the operation.
  • m: Logical value masking the operation.

Return value

  1. The value of the polynom at x is returned.
  2. same as the call with the elements of the tuples.
  3. The operation is performed conditionally.
  4. fma[pedantic] instead of fma is used in internal computations.
Note
If the coefficients or nodes 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

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
#include <iomanip>
int main()
{
eve::wide<float> wf([](auto i, auto c){ return (1+eve::eps(eve::as<float>()))*(i-c/2);});
kumi::tuple wtc{wf,2*wf,3*wf};
kumi::tuple wtn{4*wf, 5*wf};
std::cout << std::setprecision(10);
std::cout << "<- wf = " << wf << "\n";
std::cout << "<- wtc = " << wtc << "\n";
std::cout << "<- wtn = " << wtn << "\n";
std::cout << "-> newton(wf,wf,2*wf,3*wf,4*wf,5*wf) = " << eve::newton(wf,wf,2*wf,3*wf,4*wf,5*wf) << "\n";
std::cout << "-> newton(wf,coefficients(wtc),coefficients(wtn)) = " << eve::newton(wf, eve::coefficients(wtc),eve::nodes(wtn)) << "\n";
std::cout << "-> newton[pedantic](wf,wf,2*wf,3*wf,4*wf, 5*wf)= " << eve::newton[eve::pedantic](wf,wf,2*wf,3*wf,4*wf, 5*wf) << "\n";
}
constexpr auto eps
Computes a constant to the machine epsilon.
Definition eps.hpp:74
Lightweight type-wrapper.
Definition as.hpp:29

◆ tchebytchev

auto eve::tchebytchev = functor<tchebytchev_t>
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]\)

Header file

#include <eve/module/polynomial.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto tchebytchev(integral_value auto n, floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto tchebytchev[conditional_expr auto c](integral_value auto n, floating_value auto x) noexcept; // 2
constexpr auto tchebytchev[logical_value auto m](integral_value auto n, floating_value auto x) noexcept; // 2
// Semantic options
constexpr auto tchebytchev[kind_1](integral_value auto n, floating_value auto x) noexcept; // 1
constexpr auto tchebytchev[kind_2](integral_value auto n, floating_value auto x) noexcept; // 3
constexpr auto tchebytchev[successor](floating_value auto x, integral_value auto tn,
integral_value auto tnm1) noexcept; // 4
}
constexpr auto tchebytchev
Computes the value of the Tchebytchev polynomial of order n at x:
Definition tchebytchev.hpp:100

Parameters

Return value

1.The value of the polynomial at x is returned.

  1. The operation is performed conditionally.
  2. evaluates the nth polynomial of tchebytchev of second kind \( \displaystyle U_n(x) = \frac{\sin(n\arccos x)}{\sin(\arccos x)}\). on \([-1, +1]\).
  3. computes the value of \(T_{n+1}(x)\) knowing the values tn = \(T_n(x)\) and tnm1 = \(T_{n-1}(x)\), This call can be used to create a sequence of values evaluated at the same x and for rising n.

External references

Example

// revision 1
#include <eve/module/polynomial.hpp>
#include <iostream>
int main()
{
eve::wide xd{0.5, -1.5, 0.1, -1.0, 19.0, 25.0, 21.5, 10000.0};
eve::wide n{0, 1, 2, 3, 4, 5, 6, 7};
eve::wide n1{0, -1, -2, -3, -4, -5, -6, -7};
double x(0.5);
std::cout << "<- xd = " << xd << '\n';
std::cout << "<- n = " << n << '\n';
std::cout << "<- x = " << x << '\n';
std::cout << "-> tchebytchev(n, xd) = " << eve::tchebytchev(n, xd) << '\n';
std::cout << "-> tchebytchev[eve::ignore_last(2)](n, xd) = " << eve::tchebytchev[eve::ignore_last(2)](n, xd) << '\n';
std::cout << "-> tchebytchev[n > 3](n, xd) = " << eve::tchebytchev[n > 3](n, xd) << '\n';
std::cout << "-> tchebytchev(3, xd) = " << eve::tchebytchev(3, xd) << '\n';
std::cout << "-> tchebytchev(n, 2.0) = " << eve::tchebytchev(n, 2.0) << '\n';
std::cout << "-> tchebytchev(n, x) = " << eve::tchebytchev(n, x) << '\n';
std::cout << "-> tchebytchev[kind_2](n, xd) = " << eve::tchebytchev[eve::kind_2](n, xd) << "\n\n";
using wide_ft = decltype(xd);
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 << "-> t[1] = " << t[1] << '\n';
std::cout << "-> tchebytchev(" << 1 << ", xd) = " << eve::tchebytchev(1, xd) << '\n';
for(int i = 2; i <= 7; ++i)
{
t[i] = eve::tchebytchev[eve::successor](xd, t[i-1], t[i-2]);
std::cout << "-> t[" << i << "] = " << t[i] << '\n';
std::cout << "-> tchebytchev(" << i << ", xd) = " << eve::tchebytchev(i, xd) << '\n';
}
}