Hi greadey,
Those functions (fitpoly, fitpoly_range etc) were written just to get quick estimates on polynomial coefficients - they are used in initialization code for nonlinear fitting mainly.
You would be better off using the LabTalk stat object directly from your Origin C code (these functions in fact use the stat object anyway).
Sample code pasted below:
Easwar
OriginLab
void test()
{
// fit to x,y data in cols 1, 2 of active wks
Worksheet wks = Project.ActiveLayer();
Curve crv( wks, 0, 1);
if( !crv ) return;
// Point to LabTalk stat object
using stat = LabTalk.Stat;
// Reset object
stat.reset();
// Set data name
stat.Data$ = crv.GetName();
// Set chi-sq scaling to 1 - need to do this if no error bars associated with data
// If error bars, then set to 0
stat.ChiSqrErr = 1;
// Set order - poly of order 3 for example
stat.pr.order = 3;
// Perform the operation
stat.pr();
// Print results
printf("Coeff[0], Err[0] = %f, %f\n", stat.pr.a, stat.pr.ase);
for(int ii=1; ii < 4; ii++)
printf("Coeff[%d], Err[%d] = %f, %f\n", ii, ii, stat.pr.b$(ii), stat.pr.bse$(ii));
printf("R-Sqr = %f\n", stat.adrsq);
// See the documentation on Stat object under LabTalk language reference file for more info
}