mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-04-10 19:20:44 +01:00
GSL integrator generalised to integrals with infinite bounds
This commit is contained in:
parent
810c860256
commit
92822348f6
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <LatAnalyze/GslQagsIntegrator.hpp>
|
#include <LatAnalyze/GslQagsIntegrator.hpp>
|
||||||
#include <LatAnalyze/includes.hpp>
|
#include <LatAnalyze/includes.hpp>
|
||||||
|
#include <LatAnalyze/Math.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Latan;
|
using namespace Latan;
|
||||||
@ -55,9 +56,26 @@ double GslQagsIntegrator::operator()(const DoubleFunction &f, const double xMin,
|
|||||||
|
|
||||||
gslF.function = fWrap;
|
gslF.function = fWrap;
|
||||||
gslF.params = reinterpret_cast<void *>(&const_cast<DoubleFunction &>(f));
|
gslF.params = reinterpret_cast<void *>(&const_cast<DoubleFunction &>(f));
|
||||||
|
if ((xMin > -Math::inf) and (xMax < Math::inf))
|
||||||
gsl_integration_qags(&gslF, xMin, xMax, 0.0, precision_, limit_, workspace_,
|
{
|
||||||
&result, &error_);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user