T O P I C R E V I E W |
lulisa |
Posted - 05/27/2010 : 5:04:59 PM I have a problem with the nonlinear curve fitting tool in Origin 7.5. I'm trying to create my own user-defined function by calling another function that I created in C++, but it doesn't compile. I added my erf function .h file to origin.h, and it still won't work.
Here is what I have in the nonlinear curve fitting function:
#include <Origin.h>
y = A*exp(B*x^(d-1))*(1-c*erf(x^(d/2-1/2)));
And here is what I coded for the erf function:
#include <Origin.h>
double erf (double x) { static const double two_sqrtpi = 1.12838; static const double rel_error = 1E-12; if (abs(x) > 2.2) { return 1.0 - erfc(x); } double sum = x, term = x, xsqr = x*x; int j = 1; do{ term*=xsqr/j; sum-= term/(2*j+1); ++j; term*= xsqr/j; sum+= term/(2*j+1); ++j; } while (abs(term)/sum > rel_error); return two_sqrtpi*sum; };
|
1 L A T E S T R E P L I E S (Newest First) |
Shirley_GZ |
Posted - 05/28/2010 : 03:06:59 AM Hi Lulisa,
The declaration of function "erf" conflicts with that of an internal function. Please change the name to another, such as "erf1".
I also noticed that you used the function "erfc", I wonder whether you were calling an internal function "nag_erfc" or just calling a function defined by yourself. If the former, please use the right function name.
In addition, when you call this function in the nonlinear curve fitting function, you should add the header file for this function firstly, such as #include<erf.h>.
Best regards, Shirley
Originlab Technical Service Team |
|
|