Click here to Skip to main content
15,917,951 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ? Re: ? Re: How can a DLL execute a function of the main app? ? ? Pin
John R. Shaw28-Nov-04 11:35
John R. Shaw28-Nov-04 11:35 
GeneralRe: ? Re: ? Re: How can a DLL execute a function of the main app? ? ? Pin
Neville Franks28-Nov-04 11:17
Neville Franks28-Nov-04 11:17 
AnswerRe: How can a DLL execute a function of the main app? Pin
Nick Nougat29-Nov-04 5:52
Nick Nougat29-Nov-04 5:52 
GeneralAvoid compile entire proyect Pin
Juan Ignacio Garzón27-Nov-04 5:14
Juan Ignacio Garzón27-Nov-04 5:14 
GeneralRe: Avoid compile entire proyect Pin
John R. Shaw27-Nov-04 5:55
John R. Shaw27-Nov-04 5:55 
GeneralRe: Avoid compile entire proyect Pin
Michael Dunn27-Nov-04 8:26
sitebuilderMichael Dunn27-Nov-04 8:26 
GeneralRe: Avoid compile entire proyect Pin
Juan Ignacio Garzón27-Nov-04 8:54
Juan Ignacio Garzón27-Nov-04 8:54 
GeneralReturning an array from a function Pin
aaadetos27-Nov-04 2:21
aaadetos27-Nov-04 2:21 
Hi,
I have the function defined below, returns Ip without any error:

[code]
double Integral(void)
double j0,j1,H0,H1,p,Ip;

double bessj0(double x);
double bessj1(double x);
int t = 1;

alpha = beta = 2*t*PI; // t = 1
p = sqrt(pow(alpha,2.0)+pow(beta,2.0));

j0 = bessj0(2.0*p);
j1 = bessj1(2.0*p);


H0 = sum0(2.0*p);
H1 = sum1(2.0*p);

Ip = ((PI*p)/2) * ((2*p*j0) + (((PI*p)/2) * ((H0*j1)-(H1*j0))) - j1);

return Ip;
//}
}[/code]
However, I need an array, Ip[] to be returned;
not just one value. I made the following modifications to the code:
[code]
double Integrals(void)
{ double alpha[20],beta[20];
for (int t=1;t<21;t++)
{
double j0[20],j1[20],H0[20],H1[20],p[20],Ip[20];

double bessj0(double x[20]);
double bessj1(double x[20]);
int t = 1;

alpha[t] = beta[t] = 2*t*PI; // t = 1
p[t] = sqrt(pow(alpha[t],2.0)+pow(beta[t],2.0))
+sqrt(pow(alpha[t],2.0)+pow(beta[t],2.0));

j0[t] = bessj0(p[t]);
j1[t] = bessj1(p[t]);


H0[t] = sum0(p[t]);
H1[t] = sum1(p[t]);


Ip[t] = ((PI*p[t])/2) * ((2*p[t]*j0[t]) + (((PI*p[t])/2) * ((H0[t]*j1[t])-(H1[t]*j0[t]))) - j1[t]);

return Ip[20];
//}
}
}[/code]
However, I have 2 errors:
[code]error C2664: 'bessj0','bessj1' : cannot convert parameter 1 from 'double' to 'double []'[/code]

despite having modified the function definitions double bessj0(double x); and double bessj1(double x); to double bessj0(double x[20]); and double bessj1(double x[20]); WITHOUT ANY ERRORS.

viz:

[code]

double bessj0(double x)
//Returns the Bessel function j0(x) for any real x.
{
float x;
double ax,z,xx,y,ans1,ans2,j0;

if ((ax=fabs(x))<8.0) //Direct rational function fit
{
y=x*x;
ans1=57568490574.0+y*(-13362590354.0+y*(651619640.7
+y*(-11214424.18+y*(77392.33017+y*(-184.9052456)))));
ans2=57568490411.0+y*(1029532985.0+y*(9494680.718
+y*(59272.64853+y*(267.8532712+y*1.0))));
j0=ans1/ans2;
}
else
{
z=8.0/ax;
y=z*z;
xx=ax-0.785398164;
ans1=1.0+y*(-0.1098628627e-2+y*(0.2734510407e-4
+y*(-0.2073370639e-5+y*0.2093387211e-6)));
ans2=-0.1562499995e-1+y*(0.1430488765e-3
+y*(-0.6911147651e-5+y*(0.7621095161e-6
-y*0.934945152e-7)));
j0=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2);
}
return j0;
}[/code]
to:
[code]
double bessj0(double x[20])
//Returns the Bessel function j0(x) for any real x.
{
double ax[20],z[20],xx[20],y[20],ans1[20],ans2[20],j0[20];

if ((ax[20]=fabs(x[20]))<8.0) //Direct rational function fit
{
y[20]=x[20]*x[20];
ans1[20]=57568490574.0+y[20]*(-13362590354.0+y[20]*(651619640.7
+y[20]*(-11214424.18+y[20]*(77392.33017+y[20]*(-184.9052456)))));
ans2[20]=57568490411.0+y[20]*(1029532985.0+y[20]*(9494680.718
+y[20]*(59272.64853+y[20]*(267.8532712+y[20]*1.0))));
j0[20]=ans1[20]/ans2[20];
}
else
{
z[20]=8.0/ax[20];
y[20]=z[20]*z[20];
xx[20]=ax[20]-0.785398164;
ans1[20]=1.0+y[20]*(-0.1098628627e-2+y[20]*(0.2734510407e-4
+y[20]*(-0.2073370639e-5+y[20]*0.2093387211e-6)));
ans2[20]=-0.1562499995e-1+y[20]*(0.1430488765e-3
+y[20]*(-0.6911147651e-5+y[20]*(0.7621095161e-6
-y[20]*0.934945152e-7)));
j0[20]=sqrt(0.636619772/ax[20])*(cos(xx[20])*ans1[20]-z[20]*sin(xx[20])*ans2[20]);
}
return j0[20];
}[/code]

Is there another way I can re-write the code such that I return THE ARRAY, Ip[]? from the function double Integrals(void)?

THANKS


GeneralRe: Returning an array from a function Pin
Kevin McFarlane27-Nov-04 2:31
Kevin McFarlane27-Nov-04 2:31 
GeneralRe: Returning an array from a function Pin
aaadetos27-Nov-04 2:35
aaadetos27-Nov-04 2:35 
GeneralRe: Returning an array from a function Pin
Kevin McFarlane27-Nov-04 4:11
Kevin McFarlane27-Nov-04 4:11 
GeneralRe: Returning an array from a function Pin
John R. Shaw27-Nov-04 6:12
John R. Shaw27-Nov-04 6:12 
GeneralRe: Returning an array from a function Pin
aaadetos30-Nov-04 2:08
aaadetos30-Nov-04 2:08 
GeneralRe: Returning an array from a function Pin
John R. Shaw30-Nov-04 14:40
John R. Shaw30-Nov-04 14:40 
GeneralIShellFolder2 Pin
Gurra_Koo26-Nov-04 23:02
Gurra_Koo26-Nov-04 23:02 
GeneralRe: IShellFolder2 Pin
Gary R. Wheeler27-Nov-04 2:07
Gary R. Wheeler27-Nov-04 2:07 
GeneralRe: IShellFolder2 Pin
Gurra_Koo27-Nov-04 9:55
Gurra_Koo27-Nov-04 9:55 
QuestionHow can i get the boot drive Pin
Monty226-Nov-04 21:40
Monty226-Nov-04 21:40 
AnswerRe: How can i get the boot drive Pin
Alexander M.,27-Nov-04 9:28
Alexander M.,27-Nov-04 9:28 
Questionhow to prohibit a window maximizing in api?thanks Pin
cjwin8326-Nov-04 21:33
cjwin8326-Nov-04 21:33 
AnswerRe: how to prohibit a window maximizing in api?thanks Pin
PJ Arends26-Nov-04 21:40
professionalPJ Arends26-Nov-04 21:40 
QuestionHow to draw Dashed Ellipse in Embedded VC++ Pin
Arun AC26-Nov-04 20:39
Arun AC26-Nov-04 20:39 
GeneralLittle Doubt Using Send Message Pin
ThatsAlok26-Nov-04 20:38
ThatsAlok26-Nov-04 20:38 
GeneralRe: Little Doubt Using Send Message Pin
PJ Arends26-Nov-04 20:53
professionalPJ Arends26-Nov-04 20:53 
GeneralRe: Little Doubt Using Send Message Pin
ThatsAlok26-Nov-04 22:36
ThatsAlok26-Nov-04 22:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.