casacore
Loading...
Searching...
No Matches
LSQaips.h
Go to the documentation of this file.
1// # LSQaips.h: Interface for Casacore Vectors in least squares fitting
2// # Copyright (C) 1999,2000,2001,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_LSQAIPS_H
27#define SCIMATH_LSQAIPS_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/Array.h>
32#include <casacore/casa/Arrays/Vector.h>
33#include <casacore/casa/Arrays/VectorSTLIterator.h>
34#include <casacore/scimath/Fitting/LSQFit.h>
35
36namespace casacore { // # NAMESPACE CASACORE - BEGIN
37
38// # Forward Declarations
39
40// <summary>
41// Interface for Casacore Vectors in least squares fitting
42// </summary>
43// <reviewed reviewer="" date="2004/04/01" tests=""
44// demos="">
45// </reviewed>
46
47// <prerequisite>
48// <li> <linkto class=LSQFit>LSQFit</linkto> class
49// </prerequisite>
50//
51// <etymology>
52// From Least SQuares and aips++ (now Casacore)
53// </etymology>
54//
55// <synopsis>
56// The interface used in the <src>LSQaips</src> class is in terms of
57// Casacore Vectors directly, rather than an STL iterator (like
58// <linkto class=VectorSTLIterator>VectorSTLIterator</linkto>) based
59// on it.
60//
61// Its functionality is identical to that of the
62// <linkto class=LSQFit>LSQFit</linkto> class, although it will be faster to use
63// the iterator interface directly, since constructing of temporary iterators
64// can be avoided
65// </synopsis>
66//
67// <example>
68// See the <src>tLSQaips.cc</src> program for extensive examples.
69// Note: this class is in an interim state.
70// </example>
71//
72// <motivation>
73// The class was written to enable easy tranistion from the current Vector
74// to the Vector::iterator interface.
75// </motivation>
76//
77// <todo asof="2004/04/02">
78// <li> create all the method interfaces
79// </todo>
80
81class LSQaips : public LSQFit {
82 public:
83 // # Constructors
84 // Construct an object with the number of unknown, knowns and
85 // constraints, and type, using the default collinearity factor and the
86 // default Levenberg-Marquardt adjustment factor
87 // <group>
88 // Assume real
90 // Allow explicit complex/real specification
91 // <group>
100 // </group>
101 // </group>
102 // Default constructor (empty, real, only usable after a set(nUnknowns))
103 LSQaips() : LSQFit() { ; }
104 // Copy constructor (deep copy)
105 LSQaips(const LSQaips &other) : LSQFit(other) { ; }
106 // Assignment (deep copy)
107 LSQaips &operator=(const LSQaips &other) {
108 if (this != &other) LSQFit::operator=(other);
109 return *this;
110 }
111
112 // # Destructor
113 ~LSQaips() { ; }
114
115 // # Operators
116
117 // # General Member Functions
118 // Solve normal equations.
119 // The solution will be given in <src>sol</src>.
120 // <group>
121 template <class U>
122 void solve(U *sol) {
124 }
125 template <class U>
126 void solve(std::complex<U> *sol) {
128 }
129 template <class U>
130 void solve(U &sol) {
132 }
133 template <class U>
135 sol.resize(nUnknowns() / LSQTraits<U>::size);
136 LSQFit::solve(sol.data());
137 }
138 // </group>
139 // Solve a Levenberg-Marquardt loop. Note that the solution <src>sol</src>
140 // is used both and input and output. No check on the size is done.
141 // <group>
142 template <class U>
143 Bool solveLoop(uInt &nRank, U *sol, Bool doSVD = False) {
144 return LSQFit::solveLoop(nRank, sol, doSVD);
145 }
146 template <class U>
147 Bool solveLoop(uInt &nRank, std::complex<U> *sol, Bool doSVD = False) {
148 return LSQFit::solveLoop(nRank, sol, doSVD);
149 }
150 template <class U>
151 Bool solveLoop(uInt &nRank, U &sol, Bool doSVD = False) {
152 return LSQFit::solveLoop(nRank, sol, doSVD);
153 }
154 template <class U>
156 template <class U>
157 Bool solveLoop(Double &fit, uInt &nRank, U *sol, Bool doSVD = False) {
158 return LSQFit::solveLoop(fit, nRank, sol, doSVD);
159 }
160 template <class U>
161 Bool solveLoop(Double &fit, uInt &nRank, std::complex<U> *sol, Bool doSVD = False) {
162 return LSQFit::solveLoop(fit, nRank, sol, doSVD);
163 }
164 template <class U>
165 Bool solveLoop(Double &fit, uInt &nRank, U &sol, Bool doSVD = False) {
166 return LSQFit::solveLoop(fit, nRank, sol, doSVD);
167 }
168 template <class U>
169 Bool solveLoop(Double &fit, uInt &nRank, Vector<U> &sol, Bool doSVD = False);
170 // </group>
171 // Get the covariance matrix. False if an error occurred
172 // (of size <src>nUnknowns * nUnknowns</src>)
173 // <group>
174 template <class U>
175 Bool getCovariance(U *covar) {
176 return LSQFit::getCovariance(covar);
177 }
178 template <class U>
179 Bool getCovariance(std::complex<U> *covar) {
180 return LSQFit::getCovariance(covar);
181 }
182 template <class U>
184 // </group>
185 // Get main diagonal of covariance function (of size <src>nUnknowns</src>)
186 // <group>
187 template <class U>
190 }
191 template <class U>
192 Bool getErrors(std::complex<U> *errors) {
194 }
195 template <class U>
198 }
199 template <class U>
204 // </group>
205
206 private:
207 // # Data
208};
209
210} // namespace casacore
211
212#ifndef CASACORE_NO_AUTO_TEMPLATES
213#include <casacore/scimath/Fitting/LSQaips.tcc>
214#endif // # CASACORE_NO_AUTO_TEMPLATES
215#endif
Type of complex numeric class indicator.
Definition LSQTraits.h:69
void solve(U *sol)
Solve normal equations.
uInt nUnknowns() const
Get the number of unknowns.
Definition LSQFit.h:715
Bool solveLoop(uInt &nRank, U *sol, Bool doSVD=False)
Solve a loop in a non-linear set.
Bool getCovariance(U *covar)
Get the covariance matrix (of size nUnknowns * nUnknowns).
Bool getErrors(U *errors)
Get main diagonal of covariance function (of size nUnknowns).
static const String errors
Definition LSQFit.h:801
uInt nConstraints() const
Get the number of constraints.
Definition LSQFit.h:717
LSQFit(uInt nUnknowns, uInt nConstraints=0)
Construct an object with the number of unknowns and constraints, using the default collinearity facto...
static const String sol
Definition LSQFit.h:802
LSQFit & operator=(const LSQFit &other)
Assignment (deep copy).
LSQaips(const LSQaips &other)
Copy constructor (deep copy).
Definition LSQaips.h:105
Bool solveLoop(uInt &nRank, std::complex< U > *sol, Bool doSVD=False)
Definition LSQaips.h:147
LSQaips(uInt nUnknowns, const LSQReal &, uInt nConstraints=0)
Allow explicit complex/real specification.
Definition LSQaips.h:92
void solve(U &sol)
Definition LSQaips.h:130
Bool getCovariance(Array< U > &covar)
void solve(Vector< U > &sol)
Definition LSQaips.h:134
Bool solveLoop(Double &fit, uInt &nRank, U *sol, Bool doSVD=False)
Definition LSQaips.h:157
LSQaips()
Default constructor (empty, real, only usable after a set(nUnknowns)).
Definition LSQaips.h:103
Bool solveLoop(Double &fit, uInt &nRank, Vector< U > &sol, Bool doSVD=False)
Bool getErrors(std::complex< U > *errors)
Definition LSQaips.h:192
Bool getCovariance(U *covar)
Get the covariance matrix.
Definition LSQaips.h:175
Bool getErrors(Vector< U > &errors)
Definition LSQaips.h:200
Bool solveLoop(uInt &nRank, U &sol, Bool doSVD=False)
Definition LSQaips.h:151
void solve(std::complex< U > *sol)
Definition LSQaips.h:126
LSQaips & operator=(const LSQaips &other)
Assignment (deep copy).
Definition LSQaips.h:107
Bool getErrors(U *errors)
Get main diagonal of covariance function (of size nUnknowns).
Definition LSQaips.h:188
Bool solveLoop(Double &fit, uInt &nRank, std::complex< U > *sol, Bool doSVD=False)
Definition LSQaips.h:161
Bool solveLoop(uInt &nRank, U *sol, Bool doSVD=False)
Solve a Levenberg-Marquardt loop.
Definition LSQaips.h:143
Bool getErrors(U &errors)
Definition LSQaips.h:196
LSQaips(uInt nUnknowns, const LSQComplex &, uInt nConstraints=0)
Definition LSQaips.h:96
Bool solveLoop(uInt &nRank, Vector< U > &sol, Bool doSVD=False)
LSQaips(uInt nUnknowns, uInt nConstraints=0)
Construct an object with the number of unknown, knowns and constraints, and type, using the default c...
Definition LSQaips.h:89
Bool getCovariance(std::complex< U > *covar)
Definition LSQaips.h:179
void solve(U *sol)
Solve normal equations.
Definition LSQaips.h:122
Bool solveLoop(Double &fit, uInt &nRank, U &sol, Bool doSVD=False)
Definition LSQaips.h:165
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
double Double
Definition aipstype.h:53