BornAgain  1.19.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 reflection and scattering
4 //
5 //! @file Fit/Adapter/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 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_FIT_ADAPTER_SCALARFUNCTIONADAPTER_H
21 #define BORNAGAIN_FIT_ADAPTER_SCALARFUNCTIONADAPTER_H
22 
24 #include "Fit/Minimizer/Types.h"
25 #include "Fit/Param/Parameters.h"
26 #include <functional>
27 #include <memory>
28 #include <vector>
29 
30 class RootScalarFunction;
31 
32 namespace mumufit {
33 
34 //! Converts user objective function to chi2 like function which ROOT expects.
35 
36 //! More precisely, ROOT call to std::function<double(const double*)> will cause
37 //! the call of user function std::function<double(std::vector<double>)>, where
38 //! function input parameters will be current values fit parameters.
39 
41 public:
42  ScalarFunctionAdapter(fcn_scalar_t func, const Parameters& parameters);
43 
45 
46 private:
47  fcn_scalar_t m_fcn; // user function to minimize
49  std::unique_ptr<RootScalarFunction> m_root_objective;
50 };
51 
52 } // namespace mumufit
53 
54 #endif // BORNAGAIN_FIT_ADAPTER_SCALARFUNCTIONADAPTER_H
55 #endif // USER_API
Defines interface IFunctionAdapter.
Defines class Parameters.
Defines common types for fitting library.
std::function< double(const mumufit::Parameters &)> fcn_scalar_t
Definition: Types.h:39
The chi2 function for use in minimizers.
Base class for objective function adapters, which converts user functions to minimize into the functi...
A collection of fit parameters.
Definition: Parameters.h:26
Converts user objective function to chi2 like function which ROOT expects.
std::unique_ptr< RootScalarFunction > m_root_objective
ScalarFunctionAdapter(fcn_scalar_t func, const Parameters &parameters)
const RootScalarFunction * rootObjectiveFunction()
The multi-library, multi-algorithm fit wrapper library.