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.h"
13#include "../core/function.h"
42 if(x.size() !=
y.size()) {
48 for (
unsigned int i = 0; i < x.size() - 1; ++i) {
59 for (
unsigned int j = 0;
j < x.size(); ++
j) {
64 for (
unsigned int m = 0;
m < x.size(); ++
m) {
77 for (
size_t i = 0; i <
l_j.size(); ++i)
95 template<
typename Vector = vec<real>>
101 real m = (b + a) / 2.0;
102 real c = (b - a) / 2.0;
104 for (
unsigned int i = 1; i <
n + 1; ++i)
129 for (
unsigned int i = 0; i <
order + 1; ++i) {
160 for (
unsigned int i = 0; i <
order + 1; ++i)
A polynomial of arbitrary order with coefficients of a specified type.
Definition polynomial.h:28
void resize(size_t sz)
Change the number of coefficients of the polynomial.
Definition polynomial.h:168
A statically allocated N-dimensional vector with elements of the given type.
Definition vec.h:92
#define TH_MATH_ERROR(F_NAME, VALUE, EXCEPTION)
TH_MATH_ERROR is a macro which throws exceptions or modifies errno (depending on which compilation op...
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:207
dual2 abs(dual2 x)
Compute the absolute value of a second order dual number.
Definition dual2_functions.h:242
Vector chebyshev_nodes(real a, real b, unsigned int n)
Compute the n Chebyshev nodes on a given interval.
Definition polynomial.h:96
Vector make_error()
Create a vector representing an error state, with all NaN values.
Definition algebra.h:103
polynomial< Type > interpolate_grid(RealFunction f, real a, real b, unsigned int order)
Compute the interpolating polynomial of a real function on an equidistant grid.
Definition polynomial.h:123
polynomial< Type > lagrange(const Vector1 &x, const Vector2 &y)
Compute the Lagrange interpolating polynomial of a set of points.
Definition polynomial.h:35
polynomial< Type > interpolate(RealFunction f, real a, real b, unsigned int order)
Use the best available method to compute the interpolating polynomial of a real function.
Definition polynomial.h:178
dual2 cos(dual2 x)
Compute the cosine of a second order dual number.
Definition dual2_functions.h:86
@ InvalidArgument
Invalid argument.
constexpr real MACH_EPSILON
Machine epsilon for the real type.
Definition constants.h:216
polynomial< Type > interpolate_chebyshev(RealFunction 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:154
constexpr real PI
The Pi mathematical constant.
Definition constants.h:225