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
 All Forums
 Origin Forum
 Origin Forum
 Error compiling user defined fitting function

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
CelineVB Posted - 06/08/2015 : 11:29:00 AM
Hi, I am having trouble compiling a user-defined fitting function. However, I got it from an experienced user so in principle it should work fine. I only have very little experience with Origin so it would be great if anyone could help me out. I tried already to use fitting function organizer, fitting function builder and different function types. A similar fitting function works fine, I tried that one last week.
This is the function that is not compiling:

const double omega[81]={.0d0,0.1d0,0.2d0,0.3d0,0.4d0,0.5d0,0.6d0,0.7d0,0.8d0,
0.9d0,1.0d0,1.1d0,1.2d0,1.3d0,1.4d0,1.5d0,1.6d0,1.7d0,1.8d0,1.9d0,
2.0d0,2.1d0,2.2d0,2.3d0,2.4d0,2.5d0,2.6d0,2.7d0,2.8d0,2.9d0,
3.0d0,3.1d0,3.2d0,3.3d0,3.4d0,3.5d0,3.6d0,3.7d0,3.8d0,3.9d0,
4.0d0,4.2d0,4.4d0,4.6d0,4.8d0,5.0d0,5.2d0,5.4d0,5.6d0,5.8d0,
6.0d0,6.2d0,6.4d0,6.6d0,6.8d0,7.0d0,7.2d0,7.4d0,7.6d0,7.8d0,8.0d0,
8.2d0,8.4d0,8.6d0,8.8d0,9.0d0,9.2d0,9.4d0,9.6d0,9.8d0,10.0d0,
10.2d0,10.4d0,10.6d0,10.8d0,11.0d0,11.2d0,11.4d0,11.6d0,11.8d0,
12.0d0};
const double h0a[81]={1.0d0,0.990050d0,0.960789d0,0.913931d0,0.852144d0,
0.778801d0,0.697676d0,0.612626d0,0.527292d0,0.444858d0,
0.367879d0,0.298197d0,0.236928d0,0.184520d0,0.140858d0,0.105399d0,0.077305d0,
0.055576d0,0.039164d0,0.027052d0,0.0183156d0,0.0121552d0,
0.0079071d0,0.0050418d0,0.0031511d0,0.0019305d0,0.0011592d0,
0.0006823d0,0.0003937d0,0.0002226d0,0.0001234d0,0.0000671d0,
0.0000357d0,0.0000186d0,0.0000095d0,
0.0000048d0,0.0000024d0,
0.0000011d0,0.0000005d0,0.0000002d0,0.0000001d0,
0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,
0.0d0,0.0d0,0.0d0,0.0d0,
0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,
0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,
0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0};
const double h1a[81]={-1.12838d0,-1.10596d0,-1.04048d0,-0.93703d0,
-0.80346d0,-0.64945d0,-0.48552d0,-0.32192d0,-0.16772d0,-0.03012d0,
0.08594d0,0.17789d0,0.24537d0,0.28981d0,
0.31394d0,0.32130d0,0.31573d0,0.30094d0,0.28027d0,0.25648d0,
0.231726d0,0.207528d0,0.184882d0,
0.164341d0,0.1461280d0,0.130236d0,0.116515d0,0.104739d0,
0.094653d0,0.086005d0,0.078565d0,
0.072129d0,0.066526d0,0.061615d0,0.057281d0,0.053430d0,0.049988d0,
0.046894d0,0.044098d0,
0.041561d0,0.039250d0,0.035195d0,0.031762d0,0.028824d0,
0.026288d0,0.024081d0,0.022146d0,
0.020441d0,0.018929d0,0.017582d0,0.016375d0,0.015291d0,
0.014312d0,0.013426d0,0.012620d0,
0.011886d0,0.0112145d0,0.010599d0,0.0100332d0,0.0095119d0,
0.0090306d0,0.0085852d0,
0.0081722d0,0.0077885d0,0.0074314d0,0.0070985d0,0.0067875d0,
0.0064967d0,0.0062243d0,
0.0059688d0,0.0057287d0,0.0055030d0,0.0052903d0,0.0050898d0,
0.0049006d0,0.0047217d0,
0.0045526d0,0.0043924d0,0.0042405d0,0.0040964d0,0.0039595d0}
const double h2a[81]={1.0d0,0.9702d0,0.8839d0,0.7494d0,0.5795d0,
0.3894d0,0.1953d0,
0.0123d0,-0.1476d0,-0.2758d0,-0.3679d0,-0.4234d0,-0.4454d0,
-0.4392d0,-0.4113d0,-0.3689d0,
-0.3185d0,-0.2657d0,-0.2146d0,-0.1683d0,-0.12821d0,
-0.09505d0,-0.06863d0,-0.04830d0,-0.03315d0,
-0.02220d0,-0.01451d0,-0.00927d0,-0.00578d0,-0.00352d0,-0.00210d0,
-0.00122d0,-0.00070d0,
-0.00039d0,-0.00021d0,-0.00011d0,-0.00006d0,-0.00003d0,
-0.00001d0,-0.00001d0,0.0d0,
0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,
0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,
0.0d0,0.0d0,0.0d0,0.0d0,
0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,
0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0};
const double h3a[81]={-0.752d0,-0.722d0,-0.637d0,-0.505d0,-0.342d0,
-0.165d0,0.007d0,0.159d0,0.280d0,0.362d0,0.405d0,0.411d0,
0.386d0,0.339d0,0.280d0,0.215d0,0.153d0,0.097d0,
0.051d0,0.015d0,0.0101d0,0.0265d0,0.0355d0,0.0391d0,0.0389d0,
0.0363d0,0.0325d0,0.0282d0,0.0239d0,
0.0201d0,0.0167d0,0.0138d0,0.0115d0,0.0096d0,0.0080d0,0.0068d0,
0.0058d0,0.0050d0,0.0043d0,0.0037d0,
0.00329d0,0.00257d0,0.00205d0,0.00166d0,0.00137d0,0.00113d0,
0.00095d0,0.00080d0,0.00068d0,
0.00059d0,0.00051d0,0.00044d0,0.00038d0,0.00034d0,0.00030d0,
0.00026d0,0.00023d0,0.00021d0,
0.00019d0,0.00017d0,0.00015d0,0.00013d0,0.00012d0,0.00011d0,
0.00010d0,0.00009d0,0.00008d0,
0.00008d0,0.00007d0,0.00007d0,0.00006d0,0.00006d0,0.00005d0,
0.00005d0,0.00004d0,0.00004d0,
0.00004d0,0.00003d0,0.00003d0,0.00003d0,0.00003d0};
const double h4a[81]={0.50d0,0.48d0,0.40d0,0.30d0,0.17d0,0.03d0,
-0.09d0,-0.20d0,
-0.27d0,-0.30d0,-0.31d0,-0.28d0,-0.24d0,-0.18d0,-0.12d0,-0.07d0,
-0.02d0,0.02d0,0.04d0,0.05d0,0.058d0,
0.056d0,0.051d0,0.043d0,0.035d0,0.027d0,0.020d0,0.015d0,0.010d0,
0.007d0,0.005d0,0.003d0,0.002d0,
0.001d0,0.001d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,
0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,
0.0d0,0.0d0,0.0d0,0.0d0,
0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,
0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,
0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0,0.0d0};
const double zh[20]={0.000000000E+0000, 3.535358470E-0001,
7.076332733E-0001, 1.062865567E+0000,
1.419830158E+0000, 1.779162583E+0000,
2.141553012E+0000, 2.507766694E+0000,
2.878670311E+0000, 3.255267236E+0000,
3.638746425E+0000, 4.030552815E+0000,
4.432492883E+0000, 4.846900569E+0000,
5.276913315E+0000, 5.726965452E+0000, 6.203757998E+0000,
6.718438506E+0000, 7.292633671E+0000, 7.983034773E+0000};
const double wh[20]={3.534426357E-0001, 3.121628489E-0001,
2.148960768E-0001, 1.150350458E-0001, 4.769007133E-0002,
1.522198084E-0002, 3.711230232E-0003, 6.840575952E-0004,
9.407727947E-0005, 9.494299536E-0006, 6.884420409E-0007,
3.491508844E-0008, 1.196166424E-0009, 2.644004877E-0011,
3.542650802E-0013, 2.634096111E-0015, 9.519320482E-0018,
1.345726820E-0020, 4.935907338E-0024, 1.673789246E-0028};
double x2=0.,p=0.,u=0.,yy=0.,y2=0.,tt=0.;
double vv=0.,t=0.,aa=0.;
const double pii=3.14159265358979;
int kj=0;
int kz=19;

t=sqrt(log(2.0));
aa=wL/wD*t;


int K=0, K1=0,K2=0,nl=0;
double C=0., FF=0., S=0., G=0., H=0.,J=0.,A=0.,B=0.,A2=0.,B2=0.,W=0.;
double F1[40],E1[40],F2[40],E2[40],E3[40];
double F3[40],F4[40],WW[40], F11,F21,F;
double J1=0.5, J2=1.5, B1=1., ga=-0.00201306;

J=J1; A=A1; B=B1;
C=II-J;
if (C<0.0) C=-C;
FF=II+J+0.1;
S=II*(II+1.0);
G=J*(J+1.0);
H=II+II;
K=0;
F1[1]=C;
do
{
K=K+1;
C=F1[K]*(F1[K]+1.0)-S-G;
E1[K]=A*C/2.0;
if ((H!=0.0) && (J!=0.0) && (H!=1.0) && (J!=0.5))
{
E1[K]=E1[K]+B*(0.75*C*(C+1.0)-S*G)/(H*(H-1.0)*J*(J+J-1.0));
};

F1[K+1]=F1[K]+1.0;
}
while (F1[K+1]<=FF);
K1=K;

A2=ga*A1;B2=gb*B1;
J=J2; A=A2; B=B2;
C=II-J;
if (C<0.0) C=-C;
FF=II+J+0.1;
S=II*(II+1.0);
G=J*(J+1.0);
H=II+II;
K=0;
F2[1]=C;
do
{
K=K+1;
C=F2[K]*(F2[K]+1.0)-S-G;
E2[K]=A*C/2.0;
if ((H!=0.0) && (J!=0.0) && (H!=1.0) && (J!=0.5))
{
E2[K]=E2[K]+B*(0.75*C*(C+1.0)-S*G)/(H*(H-1.0)*J*(J+J-1.0));
};

F2[K+1]=F2[K]+1.0;
}
while (F2[K+1]<=FF);
K2=K;


int L,L1,L2,LL;
double SPI,D;

SPI=sqrt(3.1415926535);

K=0;
for (L1=1; L1<=K1; L1++)
{
for (L2=1; L2<=K2; L2++)
{
if ((F1[L1]!=0.0) || (F2[L2]!=0.0))
{
D=F1[L1]-F2[L2];
if (D<0.0) D=-D;
if ((D==0.0) || (D==1.0))

{

K=K+1;
E3[K]=E2[L2]-E1[L1]+E0;
F3[K]=F1[L1];
F4[K]=F2[L2];


J=J1;
F11=F3[K];F21=F4[K];
F=F11;
if (J2==J1) goto a1;
C=J2-J1;
if (C<0.0) goto a2;
if (F11!=F21) goto a8;
J=J2;
goto a5;
a8: C=F21-F11;
if (C<0.0) goto a7;
J=J2;
F=F21;
goto a6;
a1: if (F21==F11) goto a3;
C=F21-F11;
if (C<0.0) goto a4;
F=F21;
goto a4;
a3: A=J1*(J1+1.0);
B=F11*(F11+1.0);
W=(A+B-II*(II+1.0))*(A+B-II*(II+1.0))*(2.0*F11+1.0)/(4.0*A*B*(2.0*J1+1.0)*(2.0*II+1.0));
goto a10;
a4:
A=(II+J+F+1.0)*(J+F-II)*(II+F-J)*(J+II-F+1.0);
W=A/(4.0*J*(J+1.0)*(2.0*J+1.0)*F*(2.0*II+1.0));
goto a10;
a2: if (F21==F11) goto a5;
C=F21-F11;
if (C<0.0) goto a6;
J=J2;
F=F21;
a7: A=(II+F-J-1.0)*(II+F-J)*(II+J-F+1.0)*(II+J-F+2.0);
W=A/(4.0*(2.0*J+1.0)*(J+1.0)*(2.0*J+3.0)*F*(2.0*II+1.0));
goto a10;
a5: A=(II+J+F+1.0)*(J+F-II)*(J+II-F)*(II+F-J+1.0)*(2.0*F+1.0);
W=A/(4.0*F*(F+1.0)*(2.0*J-1.0)*(2.0*J+1.0)*J*(2.0*II+1.0));
goto a10;
a6: A=(II+J+F)*(II+J+F+1.0)*(J+F-II-1.0)*(J+F-II);
W=A/(4.0*(2.0*J+1.0)*(2.0*J-1.0)*J*F*(2.0*II+1.0));
a10:
;
WW[K]=W;


};
};
};
};

nl=K;

int k;
double coeff=1.0;

y=0.0;
for (k=1; k<=nl; k++)
{
if (F3[k]==(II+J1)) coeff=1.0;
if (F3[k]==(II-J1)) coeff=redAmp;

vv=t*(E3[k]-x)/wD;
x2=vv*vv;
tt=aa*aa+ x2;
double avv=abs(vv);
if ((aa>0.35d0)||(avv>=4.2d0)) goto m13;
if ((aa<=0.35d0)&&(aa>0.3d0)&&(avv<1.6d0)) goto m19;
if ((aa<=0.3d0)&&(aa>0.2d0)&&(avv<1.8d0)) goto m19;
if ((aa<=0.2d0)&&(aa>0.15d0)&&(avv<1.95d0)) goto m19;
if ((aa<=0.15d0)&&(aa>0.1d0)&&(avv<2.4d0)) goto m19;
if ((aa<=0.1d0)&&(aa>0.08d0)&&(avv<2.95d0)) goto m19;
if ((aa<=0.08d0)&&(aa>0.06d0)&&(avv<3.1d0)) goto m19;
if ((aa<=0.06d0)&&(aa>0.001d0)&&(avv<4.0d0)) goto m19;
if ((aa<=0.001d0)&&(avv<4.2d0)) goto m19;
goto m13;
m19:
double h0,h1,h2,h3,h4;
int kl;
for(int i=0; i<= 80; i++) if (avv>omega[i]) kl=i;
if (kl>=81) goto m14;

h0=dinterpolation(avv,omega[kl],omega[kl+1],h0a[kl],h0a[kl+1]);
h1=dinterpolation(avv,omega[kl],omega[kl+1],h1a[kl],h1a[kl+1]);
h2=dinterpolation(avv,omega[kl],omega[kl+1],h2a[kl],h2a[kl+1]);
h3=dinterpolation(avv,omega[kl],omega[kl+1],h3a[kl],h3a[kl+1]);
h4=dinterpolation(avv,omega[kl],omega[kl+1],h4a[kl],h4a[kl+1]);
goto m15;
m14:
h0=0.;
h1=0.;
h2=0.;
h3=0.;
h4=0.;
m15:
double a2=aa*aa;
u=h0+h1*aa+h2*a2+h3*a2*aa+h4*a2*a2;
goto m16;

m13:

y2=wh[0]*aa/tt;

u=0.0;
for (kj=2; kj<=(kz+1);kj++)
{
p =zh[kj-1]*zh[kj-1];
yy =tt+p;
u=u+wh[kj-1]*yy/(yy*yy-4.0*p*x2)/pii;
};
y=y+(y2+2.0*u*aa)*WW[k]*coeff;
goto m18;
m16:
y=y+u*WW[k]*coeff;
m18:
};
y=y*Amp+back+slope*x;

;

Thanks a lot!!

Cheers,
Céline
1   L A T E S T    R E P L I E S    (Newest First)
SeanMao Posted - 06/09/2015 : 05:03:48 AM
Hi Celine,

There are several comments for your fitting functions:

1. OriginC does not support 0.1d0 scientific notation;

2. Function dinterpolation() is not defined in the fitting function

3. We are not sure what are the independent variables, dependent variables, parameters, which are the starting points for us to diagnose the function.

Regards!

Sean

OriginLab Tech. Service

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000