BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Fit::ObjectiveFunctionAdapter Class Reference
Collaboration diagram for Fit::ObjectiveFunctionAdapter:

Public Member Functions

 ObjectiveFunctionAdapter ()
 
 ~ObjectiveFunctionAdapter ()
 
const RootScalarFunctionrootObjectiveFunction (fcn_scalar_t fcn, const Parameters &parameters)
 
const RootResidualFunctionrootResidualFunction (fcn_residual_t fcn, const Parameters &parameters)
 
int numberOfCalls () const
 
int numberOfGradientCalls () const
 

Private Attributes

std::unique_ptr< IFunctionAdapterm_adapter
 

Detailed Description

Converts user objective function to function ROOT expects.

Handles time of life of function objects.

Definition at line 33 of file ObjectiveFunctionAdapter.h.

Constructor & Destructor Documentation

◆ ObjectiveFunctionAdapter()

ObjectiveFunctionAdapter::ObjectiveFunctionAdapter ( )
default

◆ ~ObjectiveFunctionAdapter()

ObjectiveFunctionAdapter::~ObjectiveFunctionAdapter ( )
default

Member Function Documentation

◆ rootObjectiveFunction()

const RootScalarFunction * ObjectiveFunctionAdapter::rootObjectiveFunction ( fcn_scalar_t  fcn,
const Parameters parameters 
)

Definition at line 28 of file ObjectiveFunctionAdapter.cpp.

29 {
30  std::unique_ptr<ScalarFunctionAdapter> temp_adapter(new ScalarFunctionAdapter(fcn, parameters));
31  auto result = temp_adapter->rootObjectiveFunction();
32  m_adapter.reset(temp_adapter.release());
33  return result;
34 }
std::unique_ptr< IFunctionAdapter > m_adapter
Converts user objective function to chi2 like function which ROOT expects.

References m_adapter.

◆ rootResidualFunction()

const RootResidualFunction * ObjectiveFunctionAdapter::rootResidualFunction ( fcn_residual_t  fcn,
const Parameters parameters 
)

Definition at line 37 of file ObjectiveFunctionAdapter.cpp.

38 {
39  std::unique_ptr<ResidualFunctionAdapter> temp_adapter(
40  new ResidualFunctionAdapter(fcn, parameters));
41  auto result = temp_adapter->rootResidualFunction();
42  m_adapter.reset(temp_adapter.release());
43  return result;
44 }
Provides RootResidualFunction which will be minimizer by ROOT.

References m_adapter.

◆ numberOfCalls()

int ObjectiveFunctionAdapter::numberOfCalls ( ) const

Definition at line 46 of file ObjectiveFunctionAdapter.cpp.

47 {
48  return m_adapter ? m_adapter->numberOfCalls() : 0;
49 }

References m_adapter.

◆ numberOfGradientCalls()

int ObjectiveFunctionAdapter::numberOfGradientCalls ( ) const

Definition at line 51 of file ObjectiveFunctionAdapter.cpp.

52 {
53  return m_adapter ? m_adapter->numberOfGradientCalls() : 0;
54 }

References m_adapter.

Member Data Documentation

◆ m_adapter

std::unique_ptr<IFunctionAdapter> Fit::ObjectiveFunctionAdapter::m_adapter
private

The documentation for this class was generated from the following files: