MayaFlux 0.3.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ create_polynomial_function()

Polynomial::DirectFunction MayaFlux::Nodes::Generator::Polynomial::create_polynomial_function ( const std::vector< double > &  coefficients)

Creates a polynomial function from coefficients.

Parameters
coefficientsVector of polynomial coefficients (highest power first)
Returns
Function that evaluates the polynomial

Generates a function that evaluates the polynomial defined by the specified coefficients. The cofficients are ordered from highest power to lowest.

Definition at line 170 of file Polynomial.cpp.

171{
172 return [coefficients](double x) {
173 double result = 0.0;
174 double x_power = 1.0;
175
176 for (double coefficient : std::ranges::reverse_view(coefficients)) {
177 result += coefficient * x_power;
178 x_power *= x;
179 }
180
181 return result;
182 };
183}