This example shows how to use the wrapper for CUBA multidimensiona integration functions
try {
const int ndim = 2;
auto integrand = [] (const std::vector<double> x)
{
double sum = 0.;
for (size_t i=0; i<x.size(); i++)
sum += x[i];
return sum;
};
std::vector<std::vector<double>> integration_limits(2);
integration_limits[0] = {0., 2.};
integration_limits[1] = {0., 2.};
std::cout <<
"The integral computed with Vegas is: " << CW.
IntegrateVegas(integration_limits) << std::endl;
std::cout <<
"The integral computed with Suave is: " << CW.
IntegrateSuave(integration_limits) << std::endl;
std::cout <<
"The integral computed with Divonne is: " << CW.
IntegrateDivonne(integration_limits) << std::endl;
std::cout <<
"The integral computed with Cuhre is: " << CW.
IntegrateCuhre(integration_limits) << std::endl;
}
return 0;
}
Useful generic functions.
int main()
main function to create the logo of the CosmoBolognaLib
const char * what() const noexcept override
the error description
double IntegrateSuave(std::vector< std::vector< double >> integration_limits, const bool parallelize=true)
integrate using the Suave routine
double IntegrateDivonne(std::vector< std::vector< double >> integration_limits, const bool parallelize=true)
integrate using the Divonne routine
double IntegrateCuhre(std::vector< std::vector< double >> integration_limits, const bool parallelize=true)
integrate using the Cuhre routine
double IntegrateVegas(std::vector< std::vector< double >> integration_limits, const bool parallelize=true)
integrate using the Vegas routine