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
 Error compiling nag_zero_cont_func_bd_1 in fit
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

peptalasa

1 Posts

Posted - 05/11/2010 :  5:57:11 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): Origin Pro 8 v80724
Operating System: XP

Hi

I am trying to use the nag_zero_cont_func_bd_1 in a non linear fitting function. I am using according the manual, but I get this error message when I try to compile it:

Error, cannot convert argument in function call

Any hint is greatly appreciated. I have searched everywhere, but without success.

The code (not complete) is:

#include <stdio.h>
#include <OC_nag8.h>
#include <math.h>

static double fitE2(double,Nag_User *);

struct user {
double alpha;
double beta;
double DE;
double tE;
double s0;
double s1;
};


static double fitE2(double x,Nag_User *comm) {
double e0=8.85E-14;
double theta,r;
double e2;
double w;
double p=3.141516;
double alpha1,beta1,DE1,tHN1,s0,s1;

struct user *sp = (struct user *)(comm->p);

alpha1 = sp->alpha;
beta1 = sp->beta;
DE1= sp->DE;
tHN1=sp->tE;
s0=sp->s0;
s1=sp->s1;

w=2*pi*x;

r=( 1+(w*tHN1)^(1-alpha1)*sin(alpha1*p/2) )^2 + ((w*tHN1)^(1-alpha1)*cos(alpha1*p/2))^2;

theta=atan(((w*tHN1)^(1-alpha1)*cos(alpha1*p/2)) / ( 1+(w*tHN1)^(1-alpha1)*sin(alpha1*p/2) ) );

e2 = 1/(r^(beta1/2))*DE1*sin(beta1*theta);


return (e2+s1/(e0*w)-s0/(e0*w));
}


//----------------------------------------------------------
//
void _nlsfe2fit(
// Fit Parameter(s):
double alpha1, double beta1, double DE1, double tHN1, double sigma0, double sigma1,
double fC,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
double e0=8.85E-14;
double theta,r;
double e2;
double w;
double p=3.141516;
double wC;

struct user *u;
double a, b,x1;
double ftol, xtol;
static NagError fail;
Nag_User comm;

a = 0.0;
b = 1.0;
xtol = 1e-05;
ftol = 0.0;
x1=x;
nag_zero_cont_func_bd_1(a,b,&x1,fitE2,xtol,ftol,&comm,&fail);


w=2*p*x;
wC=2*p*fC;

//Find the root

r=( 1+(w*tHN1)^(1-alpha1)*sin(alpha1*p/2) )^2+
((w*tHN1)^(1-alpha1)*cos(alpha1*p/2))^2;

theta=atan(((w*tHN1)^(1-alpha1)*cos(alpha1*p/2)) / ( 1+(w*tHN1)^(1-alpha1)*sin(alpha1*p/2) ) );

if(w<=fC) {
e2 = 1/(r^(beta1/2))*DE1*sin(beta1*theta)+(sigma1/(e0*w));
} else {
e2 = (sigma0/(e0*w));
}

y=e2;

Penn

China
644 Posts

Posted - 05/11/2010 :  10:09:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

There is something wrong with the return type of the NAG callback function (fitE2) in your issue. It should be:

static double NAG_CALL fitE2(double,Nag_User *);

For more information about how to define NAG callback function, please refer to this page.

Penn
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