integrate.hpp
Go to the documentation of this file.
1 #ifndef JULIAN_INTEGRATION_HPP
2 #define JULIAN_INTEGRATION_HPP
3 
5 #include <gsl/gsl_integration.h>
6 
7 namespace julian {
8 
55  };
56 
73  template<typename F>
74  double integrate(F f, double x_lo, double x_hi, double precision_abs,double precision_rel, int n, Integration t) {
76  gsl_function *gsl_f = static_cast<gsl_function*>(&pF);
77 
78  double ret;
79  double error;
80  size_t number_of_eval;
81 
82  gsl_integration_workspace * workspace = gsl_integration_workspace_alloc (n);
83 
84  switch (t) {
86  gsl_integration_qng(gsl_f, x_lo, x_hi, precision_abs, precision_rel, &ret, &error, &number_of_eval);break;
88  gsl_integration_qag(gsl_f, x_lo, x_hi, precision_abs, precision_rel, n, 4, workspace, &ret, &error);break; // 4 means it is a 41 point rule
90  gsl_integration_qags (gsl_f, x_lo, x_hi, precision_abs, precision_rel, n, workspace, &ret, &error);break;
92  gsl_integration_qagi (gsl_f, precision_abs, precision_rel, n, workspace, &ret, &error);break;
94  gsl_integration_qagil(gsl_f, x_lo, precision_abs, precision_rel, n, workspace, &ret, &error );break;
96  gsl_integration_qagiu(gsl_f, x_hi, precision_abs, precision_rel, n, workspace, &ret, &error );break;
97  }
98 
99  gsl_integration_workspace_free (workspace);
100  return ret;
101  }
102 } // namespace julian
103 
104 #endif /* INTEGRATION_HPP */
adaptive Gauss-Kronrod with Singularities
Integration
Types of integrating algorithms.
Definition: integrate.hpp:49
File contains adapter of GSL Function.
Definition: cadHoliday.cpp:3
Class implements adapter for gsl_function.
Definition: GslFunctionAdapter.hpp:25
double integrate(F f, double x_lo, double x_hi, double precision_abs, double precision_rel, int n, Integration t)
Function calculates integral.
Definition: integrate.hpp:74
adaptive Gauss-Kronrod solving improper integral with infinity as a upper limit of integration ...
adaptive Gauss-Kronrod on infinite range
adaptive Gauss-Kronrod solving improper integral with infinity as a lower limit of integration ...