BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ScalarFunctionAdapter.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Fit/RootAdapter/ScalarFunctionAdapter.h
6 //! @brief Defines class ScalarFunctionAdapter.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
15 #ifndef BORNAGAIN_FIT_ROOTADAPTER_SCALARFUNCTIONADAPTER_H
16 #define BORNAGAIN_FIT_ROOTADAPTER_SCALARFUNCTIONADAPTER_H
17 
19 #include "Fit/Kernel/KernelTypes.h"
20 #include "Fit/Kernel/Parameters.h"
21 #include <functional>
22 #include <memory>
23 #include <vector>
24 
25 class RootScalarFunction;
26 
27 namespace Fit
28 {
29 
30 //! Converts user objective function to chi2 like function which ROOT expects.
31 
32 //! More precisely, ROOT call to std::function<double(const double*)> will cause
33 //! the call of user function std::function<double(std::vector<double>)>, where
34 //! function input parameters will be current values fit parameters.
35 
37 {
38 public:
39  ScalarFunctionAdapter(fcn_scalar_t func, const Parameters& parameters);
40 
42 
43 private:
44  fcn_scalar_t m_fcn; // user function to minimize
46  std::unique_ptr<RootScalarFunction> m_root_objective;
47 };
48 
49 } // namespace Fit
50 
51 #endif // BORNAGAIN_FIT_ROOTADAPTER_SCALARFUNCTIONADAPTER_H
Defines class IFunctionAdapter.
Defines common types for fitting library.
std::function< double(const Fit::Parameters &)> fcn_scalar_t
Definition: KernelTypes.h:37
Defines class Parameters.
Base class for objective function adapters, which converts user functions to minimize into the functi...
A collection of fit parameters.
Definition: Parameters.h:28
Converts user objective function to chi2 like function which ROOT expects.
ScalarFunctionAdapter(fcn_scalar_t func, const Parameters &parameters)
const RootScalarFunction * rootObjectiveFunction()
std::unique_ptr< RootScalarFunction > m_root_objective
The chi2 function for use in minimizers.
Objective function types.