21 #ifndef FTN_TRAILING_UNDERSCORE
22 #define _DPOLFT_ dpolft
23 #define _DPCOEF_ dpcoef
25 #define _DPOLFT_ dpolft_
26 #define _DPCOEF_ dpcoef_
30 int _DPOLFT_(integer* n, doublereal* x, doublereal* y, doublereal* w,
31 integer* maxdeg, integer* ndeg, doublereal* eps, doublereal* r,
32 integer* ierr, doublereal* a);
34 int _DPCOEF_(integer* l, doublereal* c, doublereal* tc, doublereal* a);
46 if (x >= xpts.back()) {
49 vector_fp::const_iterator loc =
50 lower_bound(xpts.begin(), xpts.end(), x);
51 int iloc = int(loc - xpts.begin()) - 1;
52 doublereal ff = fpts[iloc] +
53 (x - xpts[iloc])*(fpts[iloc + 1]
54 - fpts[iloc])/(xpts[iloc + 1] - xpts[iloc]);
122 doublereal
polyfit(
int n, doublereal* x, doublereal* y, doublereal* w,
int maxdeg,
int& ndeg, doublereal eps, doublereal* r)
125 integer mdeg = maxdeg;
127 doublereal epss = eps;
129 int worksize = 3*n + 3*maxdeg + 3;
132 doublereal zer = 0.0;
134 _DPOLFT_(&nn, x, y, w, &mdeg, &ndg, &epss, &coeffs[0],
137 "DPOLFT returned error code IERR = " +
int2str(ierr) +
138 "while attempting to fit " +
int2str(n) +
" data points "
139 +
"to a polynomial of degree " +
int2str(maxdeg));
141 _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.
C interface for Fortran DPOLFT subroutine.
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.