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 for Programming
 Forum for Origin C
 Double integration using NAG and d01sjc

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
tskisiu Posted - 12/16/2010 : 11:02:05 AM
Origin Ver. and Service Release (Select Help-->About Origin): 8.1SR3
Operating System: WinXP

I would be very grateful if someone could help me with the following problem:
I am fitting :

my function has three fitting parameters: R, L, I0
the code is as follows:
#pragma warning(error : 15618)
#include <origin.h>
#include <oc_nag8.h>
struct user
{
double R, L, fitX;
};
static double NAG_CALL f_callback(double alfa, Nag_User *comm)
{
struct user *sp = (struct user *)(comm->p);
double R_2,L_2, fitX, Rdependent, Ldependent,cylinder;

R_2=sp->R;
L_2=sp->L;
fitX=sp->fitX;
Rdependent=2*J1(fitX*R_2*sin(alfa))/(fitX*R_2*sin(alfa));
Ldependent=sin(0.5*fitX*L_2*cos(alfa))/(fitX*L_2*cos(alfa));
cylinder=Rdependent*Ldependent*Rdependent*Ldependent*sin(alfa);
return (cylinder);
}

//----------------------------------------------------------
//
void _nlsfCylinderFormFactor(
// Fit Parameter(s):
double I0, double R, double L,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
double epsabs = 0.00001, epsrel = 0.0000001, result, abserr;
Integer max_num_subint = 100;
Nag_QuadProgress qp;
static NagError fail;

Nag_User comm;
struct user s;
s.R = R;
s.L = L;
s.fitX = x;
comm.p = (Pointer)&s;

d01sjc(f_callback, 0.0, PI/2.0, epsabs, epsrel, max_num_subint, &result, &abserr, &qp, &comm, &fail);



if (fail.code != NE_INT_ARG_LT && fail.code != NE_BAD_PARAM && fail.code != NE_ALLOC_FAIL)
{
NAG_FREE(qp.sub_int_beg_pts);
NAG_FREE(qp.sub_int_end_pts);
NAG_FREE(qp.sub_int_result);
NAG_FREE(qp.sub_int_error);
}


y = I0*result;
}

I am using integrator d01sjc to integrate f_callback over all alpha range, and it works very well. Now, I would like to introduce function w(L) so that the total fitting expression is:


How should I do it? I would be grateful for any suggestions, but a code example would be best.

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