16 #ifndef FTN_TRAILING_UNDERSCORE
17 #define _DPOLFT_ dpolft
18 #define _DPCOEF_ dpcoef
20 #define _DPOLFT_ dpolft_
21 #define _DPCOEF_ dpcoef_
25 int _DPOLFT_(integer* n, doublereal* x, doublereal* y, doublereal* w,
26 integer* maxdeg, integer* ndeg, doublereal* eps, doublereal* r,
27 integer* ierr, doublereal* a);
29 int _DPCOEF_(integer* l, doublereal* c, doublereal* tc, doublereal* a);
41 if (x >= xpts.back()) {
44 vector_fp::const_iterator loc =
45 lower_bound(xpts.begin(), xpts.end(), x);
46 int iloc = int(loc - xpts.begin()) - 1;
47 doublereal ff = fpts[iloc] +
48 (x - xpts[iloc])*(fpts[iloc + 1]
49 - fpts[iloc])/(xpts[iloc + 1] - xpts[iloc]);
117 doublereal
polyfit(
int n, doublereal* x, doublereal* y, doublereal* w,
int maxdeg,
int& ndeg, doublereal eps, doublereal* r)
120 integer mdeg = maxdeg;
122 doublereal epss = eps;
124 int worksize = 3*n + 3*maxdeg + 3;
127 doublereal zer = 0.0;
129 _DPOLFT_(&nn, x, y, w, &mdeg, &ndg, &epss, &coeffs[0],
132 "DPOLFT returned error code IERR = " +
int2str(ierr) +
133 "while attempting to fit " +
int2str(n) +
" data points "
134 +
"to a polynomial of degree " +
int2str(maxdeg));
136 _DPCOEF_(&ndg, &zer, r, &awork[0]);
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
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.
Base class for exceptions thrown by Cantera classes.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Contains declarations for string manipulation functions within Cantera.
Header for a file containing miscellaneous numerical functions.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
doublereal linearInterp(doublereal x, const vector_fp &xpts, const vector_fp &fpts)
Linearly interpolate a function defined on a discrete grid.