Search code examples
c++boostintegrationnumerical

Double Numerical Integration in C++


I am looking for a good way to compute a double integral numerically using pre-written C++ libraries. The basic integral I'm dealing with is this:

<code>\int_{b}^{c}\int_{a}^{f(y)} f(x,y) dx dy</code>

I've done some research and discovered a few libraries that might be useful, however I'm not sure which one to choose based on the problem I'm dealing with. The libraries I have looked at are

  1. GSL - The problem here is it's written in C and so I would have to find some kind of wrapper to make it compatible with my research codes.
  2. Cuba - This library seems very appropriate and well documented. However I would like to avoid importing an entirely new library if I can because I'm already importing Boost and Blitz and would like to keep the hassle of compiling everything to a minimum.
  3. Boost - From what I have read in their documentation Boost has methods for integrating ODE's, but I could not find any libraries for numerically integrating double integrals of functions. Am I missing something? This would be the most convenient option as I already use Boost in my codes and its already in C++.

So my question essentially boils down to this:

Which of these three libraries would be most useful for my purposes? Is it possible to conduct the integral I have specified using Boost? Additionally any tips on how to implement this integral using any of the above libraries would be greatly appreciated.


Solution

  • Take a look at these sources, calling c code from c++ is generally not problematic. It's going the other direction that can be.

    How to mix C and C++

    How to Call C Function in C++, C++ Function in C (Mix C and C++)