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
 Calling NAG quadrature function in Origin8Pro

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
armink Posted - 02/27/2008 : 04:54:58 AM
Origin Version (Select Help-->About Origin):
Operating System: Windows XP Professional

I tried to call the NAG function nag_1d_quad_gen. For simplicity I used the example given in the NAG documentation. After removing some incompatibilities, the compiler still complains "unable to convert argument in function" when calling the function f in nag_1d_quad_gen.

Could you post a working example using nag_1d_quad_gen?

Thank you very much!

Edited by - armink on 02/27/2008 04:56:25 AM
2   L A T E S T    R E P L I E S    (Newest First)
armink Posted - 02/29/2008 : 05:53:52 AM
Thanks ML!

Here is briefly my working example:

//////////////////////////////////////////////////////////////////////

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

double NAG_CALL f(double x);

void test_NAG_quadrature (void)

{

double a, b, x;
double epsabs, abserr, epsrel, result;

Nag_QuadProgress qp;
Integer max_num_subint;

static NagError fail;

printf("nag_1d_quad_gen (d01ajc) Example Program Results\n");

epsabs = 0.0;
epsrel = 0.0001;
a = -1.0;
b = 2.0;
max_num_subint = 200;


d01ajc( f, a, b, epsabs, epsrel, max_num_subint, &result, &abserr, &qp, &fail);

printf("r - result of integration = %10.8f\n", result);
printf("a - lower limit of integration = %10.8f\n", a);
printf("b - upper limit of integration = %10.8f\n", b);
printf("epsabs - absolute accuracy requested = %9.2e\n", epsabs);
printf("epsrel - relative accuracy requested = %9.2e\n\n", epsrel);


}

double NAG_CALL f(double x)

{
return (x*sin(x*30.0)/sqrt(1.0-x*x/(4.0)));
}

////////////////////////////////////////////////////////////////////

Output is as follows:

nag_1d_quad_gen (d01ajc) Example Program Results
r - result of integration = 0.28517258
a - lower limit of integration = -1.00000000
b - upper limit of integration = 2.00000000
epsabs - absolute accuracy requested = 0.00e+000
epsrel - relative accuracy requested = 1.00e-004

Edited by - armink on 02/29/2008 05:56:28 AM
ML Posted - 02/28/2008 : 10:40:50 AM
Hi armink,

Are you sure that the function ptr prototype is exactly the same?

I see this:

  extern NAG_DLL_EXPIMP void NAG_CALL d01ajc(NAG_D01AJC_FUN f , double a, double b, 
double epsabs, double epsrel, Integer max_num_subint,
double *result, double *abserr, Nag_QuadProgress *qp,
NagError *fail);


where

  typedef double (NAG_CALL * NAG_D01_FUN)(double);

typedef NAG_D01_FUN NAG_D01AJC_FUN;


So, your function should be declared like this:

double NAG_CALL f(double x)
{
...
}



NAG_CALL denotes proper calling convention.

ML


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