Cantera  2.3.0
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 http://www.cantera.org/license.txt for license and copyright information.
5 
6 #ifndef CT_POLYFIT_H
7 #define CT_POLYFIT_H
8 
9 #include "cantera/base/ct_defs.h"
10 
11 namespace 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  */
32 double polyfit(size_t n, size_t deg, const double* x, const double* y,
33  const double* w, double* p);
34 
35 //! Fits a polynomial function to a set of data points
36 /*!
37  * @deprecated The ndeg and eps arguments to polyfit are deprecated and unused.
38  * Use the form of polyfit with signature polyfit(n, deg, x, y, w, p). To be
39  * removed after Cantera 2.3.
40  */
41 doublereal polyfit(int n, doublereal* x, doublereal* y, doublereal* w,
42  int maxdeg, int& ndeg, doublereal eps, doublereal* r);
43 }
44 #endif
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
double polyfit(int n, double *xp, double *yp, double *wp, int deg, int &ndeg, double eps, double *rp)
Fits a polynomial function to a set of data points.
Definition: polyfit.cpp:14
Namespace for the Cantera kernel.
Definition: application.cpp:29