Click here to Skip to main content
15,919,879 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 
Thanks for the valuable tips!
Since I'd rather not mess with pointers if I can help it, I called the array in my Bessel functions; viz:

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

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


I later called the function above with:
bessj0(p,j0);


But I'm not sure if a certain line in the implementing code, to return Ip[] would be valid, viz:
void Integrals(double Ip[20])	
{	
	double alpha[20],beta[20];
	for (int t=0;t<20;t++)
	{
		double j0[20],j1[20],H0[20],H1[20],p[20];

		void bessj0(double x[20],double j0[20]);	
		void bessj1(double x[20],double j1[20]);
		//int t = 1;

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


		H0[t] = sum0(p[t]);//Watch this!(***)
		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]);//WATCH THIS: WOULD IT BE PROPER TO USE 'j0[t]' in this line? the function call is :bessj0(p,j0), but I need to use the values of j0[t] from the function. Is this appropriate?

	//	return 0;//Ip[20];
	
	}
}


Also, why didn't I get an error at line (***)? The function is defined thus:
double sum0(double x)	//using the power series expansion, till the 11th power
{
	double H0;
	H0 = x - (pow(x,3)/9) + (pow(x,5)/(9*25)) - (pow(x,7)/(9*25*49))
		+ (pow(x,9)/(9*25*49*81)) - (pow(x,11)/(9*25*49*81*121));

	return H0;
}


The code pasted compiles without any errors. But I'm concerned to make sure I'm doing the correct and logical thing in the 1st place.

I'd be greatful for constructive criticism and useful tips directly applicable to the pasted code. Thanks a lot!
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 
GeneralRe: Little Doubt Using Send Message Pin
PJ Arends26-Nov-04 23:00
professionalPJ Arends26-Nov-04 23:00 
GeneralRe: Little Doubt Using Send Message Pin
ThatsAlok26-Nov-04 23:03
ThatsAlok26-Nov-04 23:03 
GeneralRe: Little Doubt Using Send Message Pin
ThatsAlok26-Nov-04 23:37
ThatsAlok26-Nov-04 23:37 
GeneralRe: Little Doubt Using Send Message Pin
PJ Arends27-Nov-04 0:07
professionalPJ Arends27-Nov-04 0:07 
GeneralRe: Little Doubt Using Send Message Pin
ThatsAlok27-Nov-04 0:34
ThatsAlok27-Nov-04 0:34 

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.