6#ifndef THEORETICA_INTERP_POLYNOMIAL_H
7#define THEORETICA_INTERP_POLYNOMIAL_H
10#include "../core/real_analysis.h"
11#include "../polynomial/polynomial.h"
12#include "../algebra/algebra_types.h"
13#include "../core/function.h"
23 template<
typename T = real>
33 for (
unsigned int i = 0; i <
points.size() - 1; ++i) {
43 for (
unsigned int j = 0;
j <
points.size(); ++
j) {
49 for (
unsigned int m = 0;
m <
points.size(); ++
m) {
72 template<
typename VectorType = std::vector<real>>
78 real m = (b + a) / 2.0;
79 real c = (b - a) / 2.0;
81 for (
unsigned int i = 1; i <
n + 1; ++i)
100 for (
unsigned int i = 0; i <
order + 1; ++i) {
127 for (
unsigned int i = 0; i <
order + 1; ++i)
128 points[i] = {nodes[i], f(nodes[i])};
#define TH_MATH_ERROR(F_NAME, VALUE, EXCEPTION)
TH_MATH_ERROR is a macro which throws exceptions or modifies errno (depending on which compiling opti...
Definition error.h:219
Main namespace of the library which contains all functions and objects.
Definition algebra.h:27
double real
A real number, defined as a floating point type.
Definition constants.h:198
VectorType chebyshev_nodes(real a, real b, unsigned int n)
Compute the n Chebyshev nodes on a given interval.
Definition polynomial.h:73
std::remove_reference_t< decltype(std::declval< Structure >()[0])> vector_element_t
Extract the type of a vector (or any indexable container) from its operator[].
Definition core_traits.h:134
polynomial< real > interpolate_chebyshev(real_function f, real a, real b, unsigned int order)
Compute the interpolating polynomial of a real function using Chebyshev nodes as sampling points.
Definition polynomial.h:120
dual2 cos(dual2 x)
Compute the cosine of a second order dual number.
Definition dual2_functions.h:86
polynomial< real > interpolate_grid(real_function f, real a, real b, unsigned int order)
Compute the interpolating polynomial of a real function on an equidistant point sample.
Definition polynomial.h:95
polynomial< T > lagrange_polynomial(const std::vector< vec< T, 2 > > &points)
Compute the Lagrange polynomial interpolating a set of points.
Definition polynomial.h:24
std::function< real(real)> real_function
Function pointer to a real function of real variable.
Definition function.h:20
constexpr real PI
The Pi mathematical constant.
Definition constants.h:216
real nan()
Return a quiet NaN number in floating point representation.
Definition error.h:54