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
 erf function problen in fitting
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

giovanetti

Argentina
Posts

Posted - 10/05/2004 :  3:56:08 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I have a proble to make a new function for fitting, this is the source code in C

// For more information and examples, please refer to the "User-Defined Fitting Function"
// section of the Origin Help file.

//----------------------------------------------------------
// user1
void _nlsfbeacauge(
// Fit Parameter(s):
double G1, double B1, double R1, double P1, double G2, double B2, double R2, double P2,
double Rg, double Bg, double k1, double b,
// Independent Variable(s):
double q,
// Dependent Variable(s):
double& i)
{
// Beginning of editable part
i = G1*exp(-(1/5) * (R1*q)^2) + B1 * exp(-(1/5) * (Rg*q)^2) * (erf(q*R1/6^(1/2))^3/q)^P1 + (G2 * exp(-(1/5) * (R2*q)^2) + B2 * (erf(q*R2/6^(1/2))^3/q)^P2)*(1 - 8*k1*3*(sin(2*q*b)-2*q*b*cos(2*q*b))/(2*q*b)^3) + Bg;
// End of editable part
}

when i compiled this are the errors


compiling...
_nlfbeacauge.fit
C:\Archivos de programa\OriginLab\OriginPro7\OriginC\NLSF\_nlfbeacauge.fit(40) :Error, function or variable erf not found
C:\Archivos de programa\OriginLab\OriginPro7\OriginC\NLSF\_nlfbeacauge.fit(40) :Error, general compile error
C:\Archivos de programa\OriginLab\OriginPro7\OriginC\NLSF\_nlfbeacauge.fit(30) :Error, error(s) found in compiling function _nlsfbeacauge

Someone have any sugestions

Thanks

easwar

USA
1965 Posts

Posted - 10/05/2004 :  4:07:37 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

When you are editing the fitting function in the Code Builder window, scroll all the way to the top. There will be four separate include statements at the top. Remove all of those and replace them with just
#include <origin.h>
Your function should then compile.

Easwar
OriginLab



Edited by - easwar on 10/05/2004 4:10:31 PM
Go to Top of Page

giovanetti

Argentina
Posts

Posted - 10/05/2004 :  4:18:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks, but when i change my code i have this erros
here is the changed code

#pragma warning(error : 15618)
#include <origin.h>
#include <stdio.h>
#include <data.h>
#include <math.h>
#include <utilities.h>


// Add your special include files here.
// For example, if you want to fit with functions from the NAG library,
// add the header file for the NAG functions here.

// Add code here for other Origin C functions that you want to define in this file,
// and access in your fitting function.

// You can access C functions defined in other files, if those files are loaded and compiled
// in your workspace, and the functions have been prototyped in a header file that you have
// included above.

// You can access NLSF object methods and properties directly in your function code.

// You should follow C-language syntax in defining your function.
// For instance, if your parameter name is P1, you cannot use p1 in your function code.
// When using fractions, remember that integer division such as 1/2 is equal to 0, and not 0.5
// Use 0.5 or 1/2.0 to get the correct value.

// For more information and examples, please refer to the "User-Defined Fitting Function"
// section of the Origin Help file.

//----------------------------------------------------------
// user1
void _nlsfbeacauge(
// Fit Parameter(s):
double G1, double B1, double R1, double P1, double G2, double B2, double R2, double P2,
double Rg, double Bg, double k1, double b,
// Independent Variable(s):
double q,
// Dependent Variable(s):
double& i)
{
// Beginning of editable part
i = G1*exp(-(1/5) * (R1*q)^2) + B1 * exp(-(1/5) * (Rg*q)^2) * (nag_erfc(q*R1/6^(1/2))^3/q)^P1 + (G2 * exp(-(1/5) * (R2*q)^2) + B2 * (nag_erfc(q*R2/6^(1/2))^3/q)^P2)*(1 - 8*k1*3*(sin(2*q*b)-2*q*b*cos(2*q*b))/(2*q*b)^3) + Bg;
// End of editable part
}

and here is the list of errors

compiling...
_nlfbeacauge.fit
C:\Archivos de programa\OriginLab\OriginPro7\OriginC\NLSF\_nlfbeacauge.fit(42) :Error, function or variable nag_erfc not found
C:\Archivos de programa\OriginLab\OriginPro7\OriginC\NLSF\_nlfbeacauge.fit(42) :Error, general compile error
C:\Archivos de programa\OriginLab\OriginPro7\OriginC\NLSF\_nlfbeacauge.fit(32) :Error, error(s) found in compiling function _nlsfbeacauge

It seems like the the same error as before


quote:

Hi,

When you are editing the fitting function in the Code Builder window, scroll all the way to the top. There will be four separate include statements at the top. Remove all of those and replace them with just
#include <origin.h>
Your function should then compile.

Easwar
OriginLab



Edited by - easwar on 10/05/2004 4:10:31 PM

Go to Top of Page

easwar

USA
1965 Posts

Posted - 10/05/2004 :  4:29:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

My apologies...I assumed that you are using Origin 7.5 - looks like you are running version 7.

Please change include lines like below and it should compile:
#include <stdio.h>
#include <data.h>
#include <math.h>
#include <utilities.h>
#include <OC_NAG.h>

The function you are trying to access, nag_erf(), is prototyped in OC_NAG.h and so this is why that header file needs to be included.

In 7.5, including Origin.h automatically includes (most) all header files including the NAG header file and this is why in 7.5 only need to include origin.h

Easwar
OriginLab

Go to Top of Page

giovanetti

Argentina
Posts

Posted - 10/06/2004 :  08:03:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thaks, this solve my problem
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