Cantera  2.1.2
polyfit.h
Go to the documentation of this file.
1 /**
2  * @file polyfit.h C interface for Fortran DPOLFT subroutine
3  */
4 /*
5  * Copyright 2001-2003 California Institute of Technology
6  * See file License.txt for licensing information
7  */
8 
9 #ifndef CT_POLYFIT_H
10 #define CT_POLYFIT_H
11 
12 #include "cantera/base/ct_defs.h"
13 
14 namespace Cantera
15 {
16 
17 //! Fits a polynomial function to a set of data points
18 /*!
19  * Given a collection of points X(I) and a set of values Y(I) which
20  * correspond to some function or measurement at each of the X(I),
21  * subroutine DPOLFT computes the weighted least-squares polynomial
22  * fits of all degrees up to some degree either specified by the user
23  * or determined by the routine. The fits thus obtained are in
24  * orthogonal polynomial form. Subroutine DP1VLU may then be
25  * called to evaluate the fitted polynomials and any of their
26  * derivatives at any point. The subroutine DPCOEF may be used to
27  * express the polynomial fits as powers of (X-C) for any specified
28  * point C.
29  *
30  * @param n The number of data points.
31  *
32  * @param x A set of grid points on which the data is specified.
33  * The array of values of the independent variable. These
34  * values may appear in any order and need not all be
35  * distinct. There are n of them.
36  *
37  * @param y array of corresponding function values. There are n of them
38  *
39  * @param w array of positive values to be used as weights. If
40  * W[0] is negative, DPOLFT will set all the weights
41  * to 1.0, which means unweighted least squares error
42  * will be minimized. To minimize relative error, the
43  * user should set the weights to: W(I) = 1.0/Y(I)**2,
44  * I = 1,...,N .
45  *
46  * @param maxdeg maximum degree to be allowed for polynomial fit.
47  * MAXDEG may be any non-negative integer less than N.
48  * Note -- MAXDEG cannot be equal to N-1 when a
49  * statistical test is to be used for degree selection,
50  * i.e., when input value of EPS is negative.
51  *
52  * @param ndeg output degree of the fit computed.
53  *
54  * @param eps Specifies the criterion to be used in determining
55  * the degree of fit to be computed.
56  * (1) If EPS is input negative, DPOLFT chooses the
57  * degree based on a statistical F test of
58  * significance. One of three possible
59  * significance levels will be used: .01, .05 or
60  * .10. If EPS=-1.0 , the routine will
61  * automatically select one of these levels based
62  * on the number of data points and the maximum
63  * degree to be considered. If EPS is input as
64  * -.01, -.05, or -.10, a significance level of
65  * .01, .05, or .10, respectively, will be used.
66  * (2) If EPS is set to 0., DPOLFT computes the
67  * polynomials of degrees 0 through MAXDEG .
68  * (3) If EPS is input positive, EPS is the RMS
69  * error tolerance which must be satisfied by the
70  * fitted polynomial. DPOLFT will increase the
71  * degree of fit until this criterion is met or
72  * until the maximum degree is reached.
73  *
74  * @param r Output vector containing the first ndeg+1 Taylor coefficients
75  *
76  * P(X) = r[0] + r[1]*(X-C) + ... + r[ndeg] * (X-C)**ndeg
77  * ( here C = 0.0)
78  *
79  * @return Returned value is the value of the rms of the interpolated
80  * function at x.
81  */
82 doublereal polyfit(int n, doublereal* x, doublereal* y, doublereal* w,
83  int maxdeg, int& ndeg, doublereal eps, doublereal* r);
84 
85 }
86 #endif
87 
88 
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
doublereal polyfit(int n, doublereal *x, doublereal *y, doublereal *w, int maxdeg, int &ndeg, doublereal eps, doublereal *r)
Fits a polynomial function to a set of data points.
Definition: funcs.cpp:122