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
 Calling NAG quadrature function in Origin8Pro
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

armink

Germany
Posts

Posted - 02/27/2008 :  04:54:58 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

ML

USA
63 Posts

Posted - 02/28/2008 :  10:40:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Go to Top of Page

armink

Germany
Posts

Posted - 02/29/2008 :  05:53:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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