Click here to Skip to main content
15,899,313 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help! in C++ How to implement 2 classes share one class Pin
Prakash Nadar27-Dec-04 23:41
Prakash Nadar27-Dec-04 23:41 
GeneralCommon header Pin
Dennis Gourjii27-Dec-04 23:58
Dennis Gourjii27-Dec-04 23:58 
GeneralRe: Common header Pin
Prakash Nadar28-Dec-04 0:33
Prakash Nadar28-Dec-04 0:33 
GeneralRe: Help! in C++ How to implement 2 classes share one class Pin
Henry miller28-Dec-04 4:37
Henry miller28-Dec-04 4:37 
QuestionHow to list the program hooking windows Pin
lekhacnhu27-Dec-04 13:49
lekhacnhu27-Dec-04 13:49 
QuestionHow to release HDC ? Pin
uus9927-Dec-04 13:47
uus9927-Dec-04 13:47 
AnswerRe: How to release HDC ? Pin
PJ Arends27-Dec-04 14:38
professionalPJ Arends27-Dec-04 14:38 
Generalintegrating a function... Pin
aaadetos27-Dec-04 12:07
aaadetos27-Dec-04 12:07 
The following code below is from a text on numerical recipes in C++...Its purpose is to evaluate the integral of a function, "func", using the Gaussian Quadrature formula, viz:
<br />
double qgaus(double func, double a, double b)<br />
{<br />
	//elements of the integral<br />
	double xr,xm,dx,s;	//s unrelated to Laplace<br />
	//at abscissas x and with weights w,<br />
	double x[] = {0.1488743389816312,0.4333953941292472,<br />
		0.6794095682990244,0.8650633666889845,0.9739065285171717};<br />
	double w[] = {0.2955242247147529,0.2692667193099963,<br />
		0.2190863625159821,0.1494513491505806,0.0666713443086881};<br />
<br />
	xm = 0.5*(b+a);<br />
	xr = 0.5*(b-a);<br />
	s = 0;<br />
	<br />
	//performing the integration on func<br />
	for(int j=0;j<5;j++)<br />
	{<br />
		dx = xr*x[j];<br />
		s += w[j]*(func(xm+dx)+func(xm-dx));<br />
	}<br />
	return s *= xr;<br />
}

Im trying to adapt the code to integrate my function, "func", which returns an array of values, viz:
<br />
void function(double (*func)[nSize],CKuchukDlg *pDialog)<br />
{<br />
	enum{nSize = 100};<br />
	double Ip[nSize],p[nSize],gh[1][nSize];<br />
	double alpha[nSize],beta[nSize];	//this 's' is unrelated to Laplace's<br />
<br />
	for(int t=0;t<nSize;t++)<br />
	{<br />
		if(t==0)<br />
		{<br />
				alpha[0] = beta[0] = 1;<br />
				p[0] = sqrt(pow(alpha[0],2.0)+pow(beta[0],2.0));<br />
<br />
				homo(gh,nSize,pDialog);<br />
				Integrals(Ip,nSize);<br />
<br />
				func[0][0] = (gh[0][0] * Ip[0])/p[0];<br />
		}<br />
		else<br />
		{<br />
			alpha[t] = beta[t] = 2*t*PI;<br />
<br />
			homo(gh,nSize,pDialog);<br />
			Integrals(Ip,nSize);<br />
		<br />
			p[t] = sqrt(pow(alpha[t],2.0)+pow(beta[t],2.0));<br />
		<br />
			func[0][t] = (gh[0][t] * Ip[t])/p[t];<br />
		}<br />
	}<br />
}<br />


Can anyone please show me how I may do this? I have tried a number of ways, but I keep running into errors. Thank you!
Generalconst pointer Pin
act_x27-Dec-04 10:48
act_x27-Dec-04 10:48 
GeneralRe: const pointer Pin
Prakash Nadar27-Dec-04 18:38
Prakash Nadar27-Dec-04 18:38 
GeneralRe: const pointer Pin
Dennis Gourjii28-Dec-04 0:09
Dennis Gourjii28-Dec-04 0:09 
GeneralRe: const pointer Pin
Henry miller28-Dec-04 4:42
Henry miller28-Dec-04 4:42 
GeneralCallback Function Pin
RedDragon2k27-Dec-04 10:13
RedDragon2k27-Dec-04 10:13 
GeneralRe: Callback Function Pin
Tom Wright27-Dec-04 10:30
Tom Wright27-Dec-04 10:30 
GeneralRe: Callback Function Pin
RedDragon2k27-Dec-04 10:43
RedDragon2k27-Dec-04 10:43 
GeneralRe: Callback Function Pin
Tom Wright27-Dec-04 12:00
Tom Wright27-Dec-04 12:00 
GeneralRe: Callback Function Pin
Dennis Gourjii28-Dec-04 0:15
Dennis Gourjii28-Dec-04 0:15 
Generalpassing a struct with WM_COPYDATA Pin
Tom Wright27-Dec-04 9:14
Tom Wright27-Dec-04 9:14 
GeneralRe: passing a struct with WM_COPYDATA Pin
PJ Arends27-Dec-04 11:01
professionalPJ Arends27-Dec-04 11:01 
GeneralRe: passing a struct with WM_COPYDATA Pin
Tom Wright27-Dec-04 11:33
Tom Wright27-Dec-04 11:33 
GeneralRe: passing a struct with WM_COPYDATA Pin
PJ Arends27-Dec-04 11:53
professionalPJ Arends27-Dec-04 11:53 
GeneralRe: passing a struct with WM_COPYDATA Pin
Tom Wright28-Dec-04 11:55
Tom Wright28-Dec-04 11:55 
GeneralRe: passing a struct with WM_COPYDATA Pin
PJ Arends28-Dec-04 16:09
professionalPJ Arends28-Dec-04 16:09 
GeneralRe: passing a struct with WM_COPYDATA Pin
Tom Wright29-Dec-04 3:54
Tom Wright29-Dec-04 3:54 
GeneralCStatusBar Pin
Anthony988727-Dec-04 8:40
Anthony988727-Dec-04 8:40 

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.