I start with OpenCL, I can see a vector example of adding and understand it. But I was thinking about the trapezoid method. This is the code (C) for integral calculation for x ^ 2 in [a, b].
double f(double x)
{
return x*x;
}
double Simple_Trap(double a, double b)
{
double fA, fB;
fA = f(a);
fB = f(b);
return ((fA + fB) * (b-a)) / 2;
}
double Comp_Trap( double a, double b)
{
double Suma = 0;
double i = 0;
i = a + INC;
Suma += Simple_Trap(a,i);
while(i < b)
{
i+=INC;
Suma += Simple_Trap(i,i + INC);
}
return Suma;
}
The question arises: how to get a kernel for integral calculation using the trapezoid method?
So, I was thinking about this idea: partials [i] = integrate (a, a + offset), and then make a kernel to calculate the sum of partial numbers, as mentioned by Patrick87.
But is this the best way?
source
share