1

I am trying to write a triple integration routine in C++ using the Boost Gauss-Kronrod quadrature for a function returning a complex result. I am not set on the Boost library, if there is another library that fits my requirements better suggestions are welcome. I am looking for an alternative to scipy since it doesn't support integrands returning complex values, meaning I have to integrate twice (complex and real part) and I am looking for a faster method.

Scipy.integrate provides a tplquad function which integrates f(x, y, z). The integration interval can even be specified as a lambda function, so integration over a spherical domain is possible. Scipy also has nquad, which can integrate over n dimensions. So far I have failed to write something similar in C++, since the boost integration doesn't have an args parameter to allow me to pass additional arguments to a function. In Python with the quad 1D integration routine from scipy I could pass the current y,z values to the x integration.

This answer has code that shows what I am thinking about doing in C++, using a 1D integration routine for 3D integration.

Olaf
  • 586
  • 5
  • 18
  • I don't think you need an `args` parameter for boost. Just use a lambda to consume any extra state you need. – user14717 May 28 '19 at 16:45
  • If you use Python, check out [quadpy](https://github.com/nschloe/quadpy) (a project of mine). It supports complex-valued integrands, is fully vectorized. – Nico Schlömer Jun 08 '19 at 13:44
  • 1
    @Nico Schlömer I just finished implementing the integration in quadpy and I am very happy with the speed. – Olaf Jun 10 '19 at 13:44

0 Answers0