SourceXtractorPlusPlus  0.12
Please provide a description of the project.
Public Member Functions | Private Types | Private Attributes | List of all members
ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator > Class Template Reference

ResidualBlockProvider for weighted comparison between data and a model. More...

#include <DataVsModelResiduals.h>

Inheritance diagram for ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >:
[legend]
Collaboration diagram for ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >:
[legend]

Public Member Functions

 DataVsModelResiduals (DataType data, ModelType model, WeightType weight, Comparator comparator)
 Constructs a new instance of DataVsModelResiduals. More...
 
virtual ~DataVsModelResiduals ()
 Destructor. More...
 
std::size_t numberOfResiduals () const override
 
void populateResidualBlock (IterType output_iter) override
 Updates the values where the iterator points with the residuals. More...
 
- Public Member Functions inherited from ModelFitting::ResidualBlockProvider
virtual ~ResidualBlockProvider ()=default
 Destructor. More...
 

Private Types

using DataTraits = DataVsModelInputTraits< DataType >
 
using ModelTraits = DataVsModelInputTraits< ModelType >
 
using WeightTraits = DataVsModelInputTraits< WeightType >
 

Private Attributes

DataType m_data
 
ModelType m_model
 
WeightType m_weight
 
Comparator m_comparator
 
std::size_t m_residual_no
 

Additional Inherited Members

- Public Types inherited from ModelFitting::ResidualBlockProvider
using IterType = double *
 

Detailed Description

template<typename DataType, typename ModelType, typename WeightType, typename Comparator>
class ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >

ResidualBlockProvider for weighted comparison between data and a model.

The residuals are computed using the following equation:

\[ r_i = g_{(d_i, m_i, w_i)} \]

where:

This class is designed to be as flexible as possible, so it can be used for comparing a wide range or data types (arrays, images, etc), with different cost functions. This flexibility is achieved in two ways.

First, the cost method (the way the residuals are computed) can be defined by the user by using the Comparator template parameter. The Comparator can be any type which behaves like a function (function pointer, functor, lambda, etc) as long as it has the signature void(double d, double m, double w).

Second, the types of the classes which provide the data, model and weight values are all templated, so any type can be used. To be fully flexible, the DataVsModelResiduals class does not access directly these type methods to not imply any restrictions on the possible container types. Instead, it uses the DataVsModelInputTraits class, which is responsible for redirecting the calls to the underlying type. Note that the default implementation of this class covers all the STL containers, so they can be used out-of-the-box. To use incompatible underlying types, one just needs to create a specialization of the DataVsModelInputTraits (see the DataVsModelInputTraits documentation for more details).

Template Parameters
DataTypeThe type used for accessing the data point values
ModelTypeThe type used for accessing the model values
WeightTypeThe type used for accessing the weight values
ComparatorThe function type to use for computing the residuals

Definition at line 78 of file DataVsModelResiduals.h.

Member Typedef Documentation

◆ DataTraits

template<typename DataType , typename ModelType , typename WeightType , typename Comparator >
using ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >::DataTraits = DataVsModelInputTraits<DataType>
private

Definition at line 82 of file DataVsModelResiduals.h.

◆ ModelTraits

template<typename DataType , typename ModelType , typename WeightType , typename Comparator >
using ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >::ModelTraits = DataVsModelInputTraits<ModelType>
private

Definition at line 83 of file DataVsModelResiduals.h.

◆ WeightTraits

template<typename DataType , typename ModelType , typename WeightType , typename Comparator >
using ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >::WeightTraits = DataVsModelInputTraits<WeightType>
private

Definition at line 84 of file DataVsModelResiduals.h.

Constructor & Destructor Documentation

◆ DataVsModelResiduals()

template<typename DataType , typename ModelType , typename WeightType , typename Comparator >
ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >::DataVsModelResiduals ( DataType  data,
ModelType  model,
WeightType  weight,
Comparator  comparator 
)

Constructs a new instance of DataVsModelResiduals.

The DataVsModelResiduals keeps internally copies of all the parameters of the constructor. Modifications done after the DataVsModelResiduals is created will not be visible by the DataVsModelResiduals instance.

Parameters
dataThe data to compute the residuals for
modelThe model values for the same points as the data
weightThe weights of the data points
comparatorThe function to use for computing the residuals
Exceptions
ElementsExceptionIf the data, model or weight have different sizes

◆ ~DataVsModelResiduals()

template<typename DataType , typename ModelType , typename WeightType , typename Comparator >
virtual ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >::~DataVsModelResiduals ( )
virtual

Destructor.

Member Function Documentation

◆ numberOfResiduals()

template<typename DataType , typename ModelType , typename WeightType , typename Comparator >
std::size_t ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >::numberOfResiduals ( ) const
overridevirtual

Returns the number of residuals produced by this residual provider (same as the number of data points)

Implements ModelFitting::ResidualBlockProvider.

◆ populateResidualBlock()

template<typename DataType , typename ModelType , typename WeightType , typename Comparator >
void ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >::populateResidualBlock ( IterType  output_iter)
overridevirtual

Updates the values where the iterator points with the residuals.

Implements ModelFitting::ResidualBlockProvider.

Member Data Documentation

◆ m_comparator

template<typename DataType , typename ModelType , typename WeightType , typename Comparator >
Comparator ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >::m_comparator
private

Definition at line 124 of file DataVsModelResiduals.h.

◆ m_data

template<typename DataType , typename ModelType , typename WeightType , typename Comparator >
DataType ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >::m_data
private

Definition at line 121 of file DataVsModelResiduals.h.

◆ m_model

template<typename DataType , typename ModelType , typename WeightType , typename Comparator >
ModelType ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >::m_model
private

Definition at line 122 of file DataVsModelResiduals.h.

◆ m_residual_no

template<typename DataType , typename ModelType , typename WeightType , typename Comparator >
std::size_t ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >::m_residual_no
private

Definition at line 125 of file DataVsModelResiduals.h.

◆ m_weight

template<typename DataType , typename ModelType , typename WeightType , typename Comparator >
WeightType ModelFitting::DataVsModelResiduals< DataType, ModelType, WeightType, Comparator >::m_weight
private

Definition at line 123 of file DataVsModelResiduals.h.


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