Hi..I have a function which is to return an array...I probably need to pass the array as a reference or pointer; but I don't fully understand these. Asides from the fact that the code which I'll post below probably returns only a value, and not an array, I get error c2664 at 2 lines(as indicated in code); but these 2 lines call perfectly compiled functions, so I cannot even "return the array" without addressing the errors. I'd appreciate any tips on this.
Here's the code:
I know the reason for the errors: bessj0 and bessj1 don't return arrays in the 1st place!!
But I don't know how to write the code to return arrays. I'd really appreciate anyone's help. Thanks a lot.
Here's 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]);//ERROR C2664! :'bessj0':cannot convert parameter 1 from 'double, to 'double[]'
j1[t] = bessj1(p[t]);]);//ERROR C2664! :'bessj1':cannot convert parameter 1 from 'double, to 'double[]'
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];
//}
}
}
I know the reason for the errors: bessj0 and bessj1 don't return arrays in the 1st place!!
Code:
double bessj0(double x[20])
//Returns the Bessel function j0(x) for any real x.
{
//CKuchukDlg MyClas;
//MyClas.m_fWellRad = x;
/* Specify definition of 'x' at point of usage..
in Ip() and unbounded.cpp,for instance. */
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];//THIS DOESN'T RETURN AN ARRAY! HOW CAN I RETURN AN ARRAY??
}