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 for Programming
 Forum for Origin C
 why I can not use erf function?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

irek

Japan
14 Posts

Posted - 06/01/2003 :  09:52:13 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
In NLCF Adv. Fitting Tools, I want to define a user-defined function. I just directly input several lines of C code in the Definition box under Y-script mode. One line I use "sum=1.772*width*erf(3);" where sum and width are declared variables. And "erf" is just the Error Function, which seems to be included in both Labtalk and Origin C. However, whenever I compile it, I got an error message saying that "function or variable erf not found". But I do see it in Origin C and Labtalk References. So how to use that?

easwar

USA
1965 Posts

Posted - 06/02/2003 :  11:29:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

If you look at the documentation for erf() function under Origin C, you will see that it is prototyped in the stat.h header file. So you need to include this header file in your fitting function file.

If you have 7SR4, you can click the "Edit in Code Builder" button on the NLSF edit page, which will open your fitting function in Code Builder, then scroll up to the top where other header files are included, and add stat.h to the list. You can then click the compile button in Code Builder and then return to NLSF.

If you have 7SR3 or lower, you will need to add the stat.h header file to a template file - edit the file nlsf.fit located under \OriginC\NLSF subfolder and add the new header line to the list in that file.

Also, in the line
sum=1.772*width*erf(3);
I presume "width" is a parameter in your function. If "sum" is just a temporary variable, note that when using Origin C, you will need to write this statement as
double sum=1.772*width*erf(3);
unless sum is already declared as double prior to this statement.

Easwar
OriginLab.

Go to Top of Page

irek

Japan
14 Posts

Posted - 06/02/2003 :  12:16:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you, easwar.

I see. But I have one thing to make clear. When I declare a temporary varible, say sum1, in the defination box, like "double sum1;" and calculate sum1 with a parameter, say "P1", like "sum1=P1^2;". Then I let the fitting to be "y=sum1*exp(-(x-x0)/t1)", where x0 and t1 are also parameters. You see, sum1 should be dependent on P1 only. So in each iteration, or when P1 is fixed, sum1 should be calculated only once, for the whole range of data, not for each data point. So, in reality, is it calculated only once? Or for each data point it is calculated though the results are the same. The reason that I ask this is because it affects time needed for curve fitting.

Edited by - irek on 06/02/2003 12:18:16 PM
Go to Top of Page

easwar

USA
1965 Posts

Posted - 06/02/2003 :  1:08:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Yes, currently all the function code is computed for each data point. There is currently no mechanism to specify part of the code to be executed only on parameter change. We are working on adding this in the future.

Easwar
OriginLab.

Go to Top of Page

irek

Japan
14 Posts

Posted - 06/03/2003 :  12:31:21 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you. But I can not find nslf.fit under any folder. And there is no folder named NSLF under \OriginC. I created a folder with that name under \OriginC and a file named nslf.fit under that folder, but it did not work. How to figout it out? I am using Origin7 SR0.

Go to Top of Page

easwar

USA
1965 Posts

Posted - 06/03/2003 :  2:15:02 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

This (integration of NLSF and Code Builder) was added post SR0. So please apply a later patch such as SR3 or SR4. And then follow the instructions from my earlier post.

Easwar
OriginLab.

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