22 #ifndef FTN_TRAILING_UNDERSCORE
23 #define _DPOLFT_ dpolft
24 #define _DPCOEF_ dpcoef
26 #define _DPOLFT_ dpolft_
27 #define _DPCOEF_ dpcoef_
31 int _DPOLFT_(integer* n, doublereal* x, doublereal* y, doublereal* w,
32 integer* maxdeg, integer* ndeg, doublereal* eps, doublereal* r,
33 integer* ierr, doublereal* a);
35 int _DPCOEF_(integer* l, doublereal* c, doublereal* tc, doublereal* a);
62 if (x >= xpts.back()) {
65 vector_fp::const_iterator loc =
66 lower_bound(xpts.begin(), xpts.end(), x);
67 int iloc = int(loc - xpts.begin()) - 1;
68 doublereal ff = fpts[iloc] +
69 (x - xpts[iloc])*(fpts[iloc + 1]
70 - fpts[iloc])/(xpts[iloc + 1] - xpts[iloc]);
138 doublereal
polyfit(
int n, doublereal* x, doublereal* y, doublereal* w,
int maxdeg,
int& ndeg, doublereal eps, doublereal* r)
141 integer mdeg = maxdeg;
143 doublereal epss = eps;
145 int worksize = 3*n + 3*maxdeg + 3;
148 doublereal zer = 0.0;
150 _DPOLFT_(&nn, x, y, w, &mdeg, &ndg, &epss, &coeffs[0],
153 "DPOLFT returned error code IERR = " +
int2str(ierr) +
154 "while attempting to fit " +
int2str(n) +
" data points "
155 +
"to a polynomial of degree " +
int2str(maxdeg));
157 _DPCOEF_(&ndg, &zer, r, &awork[0]);