1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-10 00:45:36 +00:00

GSL integrator generalised to integrals with infinite bounds

This commit is contained in:
Antonin Portelli 2017-07-09 14:15:01 +01:00
parent 810c860256
commit 92822348f6

View File

@ -19,6 +19,7 @@
#include <LatAnalyze/GslQagsIntegrator.hpp>
#include <LatAnalyze/includes.hpp>
#include <LatAnalyze/Math.hpp>
using namespace std;
using namespace Latan;
@ -55,9 +56,26 @@ double GslQagsIntegrator::operator()(const DoubleFunction &f, const double xMin,
gslF.function = fWrap;
gslF.params = reinterpret_cast<void *>(&const_cast<DoubleFunction &>(f));
gsl_integration_qags(&gslF, xMin, xMax, 0.0, precision_, limit_, workspace_,
&result, &error_);
if ((xMin > -Math::inf) and (xMax < Math::inf))
{
gsl_integration_qags(&gslF, xMin, xMax, 0.0, precision_, limit_,
workspace_, &result, &error_);
}
else if (xMax < Math::inf)
{
gsl_integration_qagil(&gslF, xMax, 0.0, precision_, limit_,
workspace_, &result, &error_);
}
else if (xMin > -Math::inf)
{
gsl_integration_qagiu(&gslF, xMin, 0.0, precision_, limit_,
workspace_, &result, &error_);
}
else
{
gsl_integration_qagi(&gslF, 0.0, precision_, limit_,
workspace_, &result, &error_);
}
return result;
}