MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
Integrator.hh
1
4//
5// This file is part of MARLEY (Model of Argon Reaction Low Energy Yields)
6//
7// MARLEY is free software: you can redistribute it and/or modify it under the
8// terms of version 3 of the GNU General Public License as published by the
9// Free Software Foundation.
10//
11// For the full text of the license please see COPYING or
12// visit http://opensource.org/licenses/GPL-3.0
13//
14// Please respect the MCnet academic usage guidelines. See GUIDELINES
15// or visit https://www.montecarlonet.org/GUIDELINES for details.
16
17#pragma once
18#include <functional>
19#include <vector>
20
21#include "marley/marley_utils.hh"
22
23namespace marley {
24
28 class Integrator {
29 public:
30
34 Integrator(size_t num = N_DEFAULT_);
35
41 double num_integrate(const std::function<double(double)>& f,
42 double a, double b) const;
43
44 private:
45
47 size_t N_;
48
50 std::vector<double> weights_;
51
53 std::vector<double> offsets_;
54
55 static constexpr size_t N_DEFAULT_ = 20;
56 };
57
58}
double num_integrate(const std::function< double(double)> &f, double a, double b) const
Numerically integrate an arbitrary 1D function.
Definition Integrator.cc:47
Integrator(size_t num=N_DEFAULT_)
Create a Clenshaw-Curtis quadrature integrator that uses 2*num sampling points.
Definition Integrator.cc:22