casacore
Loading...
Searching...
No Matches
NonLinearFitLM.h
Go to the documentation of this file.
1//# NonLinearFitLM.h: Solve non-linear fit using Levenberg-Marquardt method.
2//# Copyright (C) 1995,1999-2002,2004,2006
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: casa-feedback@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25
26#ifndef SCIMATH_NONLINEARFITLM_H
27#define SCIMATH_NONLINEARFITLM_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/scimath/Fitting/NonLinearFit.h>
32namespace casacore { //# begin namespace casa
33//# Forward declarations
34
35//
36// <summary>
37// Solve non-linear fit with Levenberg-Marquardt method.
38// </summary>
39//
40// <reviewed reviewer="wbrouw" date="2004/06/15" tests="tNonLinearFitLM.cc"
41// demos="">
42// </reviewed>
43//
44// <prerequisite>
45// <li> <linkto class="NonLinearFit">NonLinearFit</linkto>
46// <li> <linkto module="Fitting">Fitting</linkto>
47// </prerequisite>
48//
49// <etymology>
50// This class uses the Levenberg-Marquardt method to solve the non-linear
51// least-squares fit problem hence NonLinearFitLM
52// </etymology>
53//
54// <synopsis>
55// NOTE: Constraints added. Documentation out of date at moment, check
56// the tLinearFitSVD and tNonLinearFirLM programs for examples.
57//
58// See the <linkto class=NonLinearFit>NonLinearFit</linkto> class for a
59// general description.
60//
61// This class is derived from the general NonLinearFit class. It does
62// a non-linear least-squares fit using the Levenberg-Marquardt method.
63//
64// See Numerical Recipes for more information
65// on the Levenberg-Marquardt method.
66// </synopsis>
67//
68// <templating arg=T>
69// <li> Float
70// <li> Double
71// <li> Complex
72// <li> DComplex
73// </templating>
74//
75// <motivation>
76// Levenberg-Marquardt method is a standard method for non-linear
77// least-squares fits. It works well in practice over a wide range of
78// problems.
79// </motivation>
80//
81// <example>
82// </example>
83
84template<class T> class NonLinearFitLM : public NonLinearFit<T>
85{
86public:
87 //# Constructors
88 // Create a fitter: the normal way to generate a fitter object. Necessary
89 // data will be deduced from the Functional provided with
90 // <src>setFunction()</src>.
91 // Optionally, a fitter with SVD behaviour
92 explicit NonLinearFitLM(Bool svd=False);
93 // Copy constructor (deep copy)
95 // Assignment (deep copy)
97
98 // Destructor
99 virtual ~NonLinearFitLM();
100
101protected:
102 //# Member functions
103 // Generalised fitter
104 virtual Bool fitIt
106 const Array<typename FunctionTraits<T>::BaseType> &x,
107 const Vector<typename FunctionTraits<T>::BaseType> &y,
108 const Vector<typename FunctionTraits<T>::BaseType> *const sigma,
109 const Vector<Bool> *const mask=0);
110
111private:
112 //# Data
113 // The parameter that makes this the Levenberg-Marquardt method.
115 // The current fit state
117
118protected:
119 //# Make members of parent classes known.
123 using NonLinearFit<T>::pCount_p;
125 using NonLinearFit<T>::sol_p;
126 using NonLinearFit<T>::solved_p;
127 using NonLinearFit<T>::nr_p;
128 using NonLinearFit<T>::svd_p;
129 using NonLinearFit<T>::condEq_p;
130 using NonLinearFit<T>::err_p;
131 using NonLinearFit<T>::errors_p;
132 using NonLinearFit<T>::valder_p;
136 using NonLinearFit<T>::isReady;
137};
138
139} //# End namespace casacore
140#ifndef CASACORE_NO_AUTO_TEMPLATES
141#include <casacore/scimath/Fitting/NonLinearFitLM.tcc>
142#endif //# CASACORE_NO_AUTO_TEMPLATES
143#endif
T BaseType
Template base type.
Bool solved_p
Have solution.
void fillSVDConstraints()
Get the SVD constraints.
uInt nr_p
The rank of the solution.
Vector< typename FunctionTraits< T >::BaseType > condEq_p
Condition equation parameters (for number of adjustable parameters)
Vector< typename FunctionTraits< T >::BaseType > err_p
Local error area.
void buildConstraint()
Build the constraint equations.
uInt pCount_p
Number of available parameters.
Vector< typename FunctionTraits< T >::BaseType > sol_p
Local solution area.
Bool svd_p
SVD indicator.
Bool errors_p
Have errors.
Function< typename FunctionTraits< T >::DiffType, typename FunctionTraits< T >::DiffType > * ptr_derive_p
Function to use in evaluating condition equation.
FunctionTraits< T >::DiffType valder_p
Local value and derivatives.
void setMaskedParameterValues(const Vector< typename FunctionTraits< T >::BaseType > &parms)
LSQFit::ReadyCode isReady() const
Ask the state of the non-linear solutions.
Definition LSQFit.h:747
static const String sol
Definition LSQFit.h:855
Double fitit_p
The current fit state.
NonLinearFitLM & operator=(const NonLinearFitLM &other)
Assignment (deep copy)
Double lamda_p
The parameter that makes this the Levenberg-Marquardt method.
NonLinearFitLM(Bool svd=False)
Create a fitter: the normal way to generate a fitter object.
virtual Bool fitIt(Vector< typename FunctionTraits< T >::BaseType > &sol, const Array< typename FunctionTraits< T >::BaseType > &x, const Vector< typename FunctionTraits< T >::BaseType > &y, const Vector< typename FunctionTraits< T >::BaseType > *const sigma, const Vector< Bool > *const mask=0)
Generalised fitter.
virtual ~NonLinearFitLM()
Destructor.
NonLinearFitLM(const NonLinearFitLM &other)
Copy constructor (deep copy)
uInt curiter_p
Current iteration number.
uInt maxiter_p
Maximum number of iterations.
Bool converge_p
Has fit converged.
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
double Double
Definition aipstype.h:53