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