The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 How do I call my own function in NLCF (Origin 7.5)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

lulisa

1 Posts

Posted - 05/27/2010 :  5:04:59 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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;
};

Shirley_GZ

China
Posts

Posted - 05/28/2010 :  03:06:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000