Skip to content

Port of the multi-dimensional adaptive integration library cubature to C++.

License

Notifications You must be signed in to change notification settings

duanebyer/cubature-cpp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cubature-cpp

This is a C++ port of the cubature library, adapted for use in the sidis event generator. Currently, this port has several limitations compared to the original library:

  • Only scalar integrands are supported (no vector integrands).
  • Only the h-adaptive algorithm is supported.
  • The dimension of the integrated region must be selected at compile time.

It also has some new features:

  • Support for C++ closures and functor objects.
  • User-specified real number types.

For more information, visit the original cubature project.

Build

The library is provided in a header-only form, so you can place cubature.hpp and cubature.ipp in your include directory to start using it. Alternatively, build and install using CMake.

Usage

As a simple example:

#include <cubature.hpp>

// ...
cubature::ErrEst<double> res = cubature::cubature(
	[&](cubature::Point<3, double> x) {
		return std::sin(x[0]) * std::cos(x[1]) * x[2] * x[2];
	},
	cubature::Point<3, double>{ xmin, ymin, zmin },
	cubature::Point<3, double>{ xmax, ymax, zmax },
	max_eval, req_abs_err, req_rel_err);
std::cout << "Integral: " << res.val << std::endl;
std::cout << "Error: " << res.err << std::endl;
// ...

A vectorized interface is also supported. To use it, call cubature_v with a functor of the signature:

functor(std::size_t num_points, cubature::Point3<N, R>* points, R* vals);

About

Port of the multi-dimensional adaptive integration library cubature to C++.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 96.7%
  • CMake 3.3%