double integral and problem with function to evaluate


bingobongo
01-17-2008, 04:15 PM
well, i have a problem with function qgauss,
i want to do a double integral, (must C language) with this function.This function make one dimensional integral good way is use the static expression described on the book.
I talk about the problem:
this function evaluate the points of integral, whith passing pointer to function, when the function is called. (this function return the expression for the integral).
double qgaus(double (*func)(double), double a, double b)
the function accept only one input (func)(double) .
my problem is passing expression derived from computation with more arguments, i have not simple expression x*sin(x) or others.
my problem is passing complex expression with recalling other function with this header:
double integrand(x,par1,par2,par3,matrix)

//
and this function return expression for esemple:
return as=(a*cos+funzi3(par1,par2,par3)) on other words calling under it other function.
//

On other words i want to do qgauss(integrand(x,par1,par2,par3,matrix),xmin,xma x)
but is not possible.

I think the solution using global variables, (i think is quite good way) but for matrix? i not sure is possible for matrix.
Then i think to make a struct:
struct funz{double par1, double(*point)(struct funz *funzi, double x}
when the function is called with qgauss i change pointer to function with pointer to struct.
The function for evaluate is changed, i have on input the structure and i return the expression using a parameters of struct exemple par1*sin(x).
final i change the evaluation the point under function using pointer to to struct funz.

well i have do this for one dimensional integral.
But not for 2-dimensional integral.
i not sure if this ways is the correct way.
there is a way to solve this annoying and difficult problem?

best regard
please help me on this problem is very important, try to understand what I've wrote