BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Integrator.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Base/Utils/Integrator.h
6 //! @brief Defines classes RealIntegrator, ComplexIntegrator.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
15 #ifndef BORNAGAIN_BASE_UTILS_INTEGRATOR_H
16 #define BORNAGAIN_BASE_UTILS_INTEGRATOR_H
17 
18 #include "Base/Types/Complex.h"
19 #include <functional>
20 #include <gsl/gsl_integration.h>
21 
22 //! To integrate a real function of a real variable.
24 {
25 public:
28  double integrate(const std::function<double(double)>& f, double lmin, double lmax);
29 
30 private:
31  static double m_Cfunction(double x, void* p)
32  {
33  return (*(const std::function<double(double)>*)(p))(x);
34  };
35  gsl_function m_gsl_f;
36  gsl_integration_workspace* m_workspace;
37 };
38 
39 //! To integrate a complex function of a real variable.
41 {
42 public:
43  complex_t integrate(const std::function<complex_t(double)>& f, double lmin, double lmax);
44 
45 private:
48 };
49 
50 #endif // BORNAGAIN_BASE_UTILS_INTEGRATOR_H
Defines complex_t, and a few elementary functions.
std::complex< double > complex_t
Definition: Complex.h:20
To integrate a complex function of a real variable.
Definition: Integrator.h:41
complex_t integrate(const std::function< complex_t(double)> &f, double lmin, double lmax)
Definition: Integrator.cpp:36
RealIntegrator realPart
Definition: Integrator.h:46
RealIntegrator imagPart
Definition: Integrator.h:47
To integrate a real function of a real variable.
Definition: Integrator.h:24
double integrate(const std::function< double(double)> &f, double lmin, double lmax)
Definition: Integrator.cpp:27
static double m_Cfunction(double x, void *p)
Definition: Integrator.h:31
gsl_integration_workspace * m_workspace
Definition: Integrator.h:36
gsl_function m_gsl_f
Definition: Integrator.h:34