Cantera
Install
User Guide
Examples
Reference
Develop
Community
4.0.0a2
Toggle main menu visibility
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
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 deg The degree of the polynomial fit to be computed. `deg <= x.size() - 1`.
23
* @param x Array of points at which the function is evaluated.
24
* @param y Array of function values at the points in *x*.
25
* @param w Array of weights. If empty or `w[0] < 0`, then all the
26
* weights will be set to 1.0.
27
* @param[out] p Array of polynomial coefficients, starting with the constant
28
* term. Length *deg+1*.
29
* @returns the root mean squared error of the fit at the input points.
30
* @ingroup mathUtils
31
*/
32
double
polyfit
(
size_t
deg, span<const double> x, span<const double> y,
33
span<const double> w, span<double> p);
34
35
}
36
#endif
ct_defs.h
This file contains definitions of constants, types and terms that are used in internal routines and a...
Cantera::polyfit
double polyfit(size_t deg, span< const double > x, span< const double > y, span< const double > w, span< double > p)
Fits a polynomial function to a set of data points.
Definition
polyfit.cpp:14
Cantera
Namespace for the Cantera kernel.
Definition
AnyMap.cpp:595
include
cantera
numerics
polyfit.h
Generated by
1.17.0