1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Fit/Residual/RootResidualFunction.h
//! @brief Declares class RootResidualFunction.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifdef SWIG
#error no need to expose this header to Swig
#endif // SWIG
#ifndef BORNAGAIN_FIT_RESIDUAL_ROOTRESIDUALFUNCTION_H
#define BORNAGAIN_FIT_RESIDUAL_ROOTRESIDUALFUNCTION_H
#include "Fit/Minimizer/Types.h"
#ifndef _WIN32
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#include <Math/FitMethodFunction.h>
#ifndef _WIN32
#pragma GCC diagnostic pop
#endif
//! Minimizer function with access to single data element residuals,
//! required by Fumili2 and GSLMultiMin minimizers.
class RootResidualFunction : public ROOT::Math::FitMethodFunction {
public:
using Type_t = ROOT::Math::BasicFitMethodFunction<ROOT::Math::IMultiGenFunction>::Type_t;
//! Constructs RootResidualFunction
RootResidualFunction(const scalar_function_t& objective_fun,
const gradient_function_t& gradient_fun, size_t npars, size_t ndatasize);
Type_t Type() const override;
ROOT::Math::IMultiGenFunction* Clone() const override;
//! Evaluation of single data element residual. Will be called by ROOT minimizer.
double DataElement(const double* pars, unsigned int index,
double* gradients = nullptr) const override;
private:
//! evaluation of chi2
double DoEval(const double* pars) const override;
scalar_function_t m_objective_fun; //!< User function to get value to minimizer.
gradient_function_t m_gradient_fun; //!< User function to get residual and gradients.
size_t m_npars;
size_t m_datasize;
};
#endif // BORNAGAIN_FIT_RESIDUAL_ROOTRESIDUALFUNCTION_H
|