Cortex  10.0.0-a4
Public Types | Public Member Functions | Protected Attributes | List of all members
IECore::LevenbergMarquardt< T, ErrorFn, Traits > Class Template Reference

#include <LevenbergMarquardt.h>

Inherits noncopyable.

Public Types

enum  Status {
  Success, Degenerate, CallLimit, FailedFTol,
  FailedXTol, FailedGTol
}
 
typedef T ValueType
 
typedef ErrorFn ErrorFunctionType
 
typedef Traits< T > TraitsType
 

Public Member Functions

void setParameters (T ftol=Traits< T >::tolerance(), T xtol=Traits< T >::tolerance(), T gtol=Traits< T >::tolerance(), T epsilon=Traits< T >::machinePrecision(), T stepBound=T(100))
 
void getParameters (T &ftol, T &xtol, T &gtol, T &epsilon, T &stepBound) const
 
void setMaxCalls (unsigned maxCalls)
 
unsigned getMaxCalls () const
 
Status solve (typename TypedData< std::vector< T > >::Ptr parameters, ErrorFn &fn)
 Updates parameters in place. Returns true on success.
 

Protected Attributes

m_ftol
 
m_xtol
 
m_gtol
 
m_epsilon
 
m_stepBound
 
unsigned int m_maxCalls
 
unsigned int m_numCalls
 
unsigned int m_m
 
unsigned int m_n
 

Detailed Description

template<typename T, typename ErrorFn, template< typename > class Traits = DefaultLevenbergMarquardtTraits>
class IECore::LevenbergMarquardt< T, ErrorFn, Traits >

Performs Levenberg-Marquardt minimisation of the given parameters and user-supplied objective function. Based on public domain routines.

ErrorFn should be a model of:

template<typename T> class DefaultErrorFn { BOOST_STATIC_ASSERT( boost::is_floating_point<T>::value );

public :

 /// "errors" is already sized to the correct length, it just needs filling in. Changing the length of either parameter within this
 /// function is prohibited, and leads to undefined behaviour.
    void operator()(
            typename TypedData< std::vector<T> >::ConstPtr parameters,
            typename TypedData< std::vector<T> >::Ptr errors
    );

    unsigned numErrors() const;

};

Traits should be a model of template<typename T> class Traits { static T machinePrecision(); // machine epsilon static T sqrtMin(); /// sqrt of the smallest representable number static T sqrtMax(); /// sqrt of the largest representable number static T tolerance(); /// user defined tolerance };

Todo:

Use max iterations instead of maxCalls on the error function.

No need for TypedData. Template on vector iterators instead.

Consider to pass the parameter changed when building the Jacobian. Most of the problems would not affect all the outputs when just one parameter changes. Some space for considerable optimization there.


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