Cantera  3.1.0a1
Loading...
Searching...
No Matches
polyfit.h
Go to the documentation of this file.
1//! @file polyfit.h
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#ifndef CT_POLYFIT_H
7#define CT_POLYFIT_H
8
10
11namespace Cantera
12{
13
14//! Fits a polynomial function to a set of data points
15/*!
16 * Given a collection of *n* points *x* and a set of values *y* of some function
17 * evaluated at those points, this function computes the weighted least-squares
18 * polynomial fit of degree *deg*:
19 *
20 * @f[ f(x) = p[0] + p[1] x + p[2] x^2 + \cdots + p[deg] x^deg @f]
21 *
22 * @param n The number of points at which the function is evaluated
23 * @param deg The degree of the polynomial fit to be computed. deg <= n - 1.
24 * @param x Array of points at which the function is evaluated. Length *n*.
25 * @param y Array of function values at the points in *x*. Length *n*.
26 * @param w Array of weights. If w == nullptr or w[0] < 0, then all the
27 * weights will be set to 1.0.
28 * @param[out] p Array of polynomial coefficients, starting with the constant
29 * term. Length *deg+1*.
30 * @returns the root mean squared error of the fit at the input points.
31 * @ingroup mathUtils
32 */
33double polyfit(size_t n, size_t deg, const double* x, const double* y,
34 const double* w, double* p);
35
36}
37#endif
This file contains definitions of constants, types and terms that are used in internal routines and a...
double polyfit(size_t n, size_t deg, const double *xp, const double *yp, const double *wp, double *pp)
Fits a polynomial function to a set of data points.
Definition polyfit.cpp:14
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564