ODIN
integration.h
1 /***************************************************************************
2  integration.h - description
3  -------------------
4  begin : Fri Apr 6 2001
5  copyright : (C) 2000-2021 by Thies Jochimsen
6  email : thies@jochimsen.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef INTEGRATION_H
19 #define INTEGRATION_H
20 
21 #include <odindata/data.h>
22 
23 
34 class Integrand {
35 
36  public:
37 
41  virtual double evaluate(double x) const = 0;
42 
48  double get_integral(double xmin, double xmax, unsigned int max_subintervals=1000, double error_limit=1e-7) const;
49 
50 
51  protected:
52  Integrand() {}
53  virtual ~Integrand() {}
54 };
55 
57 
58 class GslData4Integr; // forward declaration
59 
64 
65  public:
66 
72  FunctionIntegral(const Integrand& func, unsigned int max_subintervals=1000, double error_limit=1e-7);
73 
78 
82  double get_integral(double xmin, double xmax) const;
83 
84 
85  private:
86  static double integrand(double x, void *params);
87 
88  const Integrand& f;
89  unsigned int n_intervals;
90  double errlimit;
91  GslData4Integr* gsldata;
92 
93 };
94 
99 #endif
100 
FunctionIntegral(const Integrand &func, unsigned int max_subintervals=1000, double error_limit=1e-7)
double get_integral(double xmin, double xmax) const
double get_integral(double xmin, double xmax, unsigned int max_subintervals=1000, double error_limit=1e-7) const
virtual double evaluate(double x) const =0