Romberg's integration of real valued functions by CUDA Thrust

From the point of view of parallel programming, integration is basically a reduction, so that a very simple way to implement integration in CUDA is exploiting the primitives of the Thrust library. Below is a simple example implementing the Romberg integration method by the Thrust primitives. It is a "direct" translation of the corresponding Matlab code available at this site, so this example also shows how "simply" some Matlab codes can be ported to CUDA by Thurst. #include <thrust/sequen...
More

Simpson's integration of real valued functions by CUDA Thrust

Simpson's integration can be easily implemented by using CUDA Thrust. You basically need five steps: 1. Generate the Simpson's quadrature weights; 2. Generate the function sampling points; 3. Generate the function values; 4. Calculate the elementwise product between the quadrature weights and the function values; 5. Sum the above products. Step #1 requires creating an array with elements repeated many times, namely, 1 4 2 4 2 4 ... 1 for the Simpson's case. This can be accomplished by bor...
More