cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
Derivator.h
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2022-2024 Laurent Forthomme
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef CepGen_Utils_Derivator_h
20#define CepGen_Utils_Derivator_h
21
24
25namespace cepgen {
26 namespace utils {
27 class Derivator : public NamedModule<Derivator> {
28 public:
29 explicit Derivator(const ParametersList& params) : NamedModule(params), h_(steer<double>("h")) {}
30
32 auto desc = ParametersDescription();
33 desc.add<double>("h", 1.e-2).setDescription("step size");
34 return desc;
35 }
36
41 inline double derivate(const std::function<double(double)>& func, double x, double h = -1.) const {
42 return derivate(Function1D(func), x, h);
43 }
48 virtual double derivate(const Function1D& func, double x, double h = -1.) const = 0;
49
50 protected:
51 const double h_;
52 };
53 } // namespace utils
54} // namespace cepgen
55
56#endif
Base runtime module object.
Definition NamedModule.h:28
A description object for parameters collection.
T steer(const std::string &key) const
Retrieve a parameters as previously steered.
Definition Steerable.h:39
double derivate(const std::function< double(double)> &func, double x, double h=-1.) const
Evaluate the derivative of a function at a given value.
Definition Derivator.h:41
static ParametersDescription description()
Definition Derivator.h:31
virtual double derivate(const Function1D &func, double x, double h=-1.) const =0
Evaluate the derivative of a function at a given value.
Derivator(const ParametersList &params)
Definition Derivator.h:29
Wrapper to a 1-dimensional function with optional parameters.
Common namespace for this Monte Carlo generator.