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
84 //# Constructors
85 // Construct an object with the number of unknown, knowns and
86 // constraints, and type, using the default collinearity factor and the
87 // default Levenberg-Marquardt adjustment factor
88 // <group>
89 // Assume real
92 // Allow explicit complex/real specification
93 // <group>
98 // </group>
99 // </group>
100 // Default constructor (empty, real, only usable after a set(nUnknowns))
101 LSQaips() : LSQFit() {;}
102 // Copy constructor (deep copy)
103 LSQaips(const LSQaips &other) : LSQFit(other) {;}
104 // Assignment (deep copy)
105 LSQaips &operator=(const LSQaips &other) {
106 if (this != &other) LSQFit::operator=(other);
107 return *this; }
108
109 //# Destructor
111
112 //# Operators
113
114 //# General Member Functions
115 // Solve normal equations.
116 // The solution will be given in <src>sol</src>.
117 // <group>
118 template <class U>
119 void solve(U *sol) { LSQFit::solve(sol); }
120 template <class U>
121 void solve(std::complex<U> *sol) { LSQFit::solve(sol); }
122 template <class U>
123 void solve(U &sol) { LSQFit::solve(sol); }
124 template <class U>
128 // </group>
129 // Solve a Levenberg-Marquardt loop. Note that the solution <src>sol</src>
130 // is used both and input and output. No check on the size is done.
131 // <group>
132 template <class U>
134 U *sol, Bool doSVD=False) {
135 return LSQFit::solveLoop(nRank, sol, doSVD); }
136 template <class U>
138 std::complex<U> *sol, Bool doSVD=False) {
139 return LSQFit::solveLoop(nRank, sol, doSVD); }
140 template <class U>
142 U &sol, Bool doSVD=False) {
143 return LSQFit::solveLoop(nRank, sol, doSVD); }
144 template <class U>
146 Vector<U> &sol, Bool doSVD=False);
147 template <class U>
148 Bool solveLoop(Double &fit, uInt &nRank,
149 U *sol, Bool doSVD=False) {
150 return LSQFit::solveLoop(fit, nRank, sol, doSVD); }
151 template <class U>
152 Bool solveLoop(Double &fit, uInt &nRank,
153 std::complex<U> *sol, Bool doSVD=False) {
154 return LSQFit::solveLoop(fit, nRank, sol, doSVD); }
155 template <class U>
156 Bool solveLoop(Double &fit, uInt &nRank,
157 U &sol, Bool doSVD=False) {
158 return LSQFit::solveLoop(fit, nRank, sol, doSVD); }
159 template <class U>
160 Bool solveLoop(Double &fit, uInt &nRank,
161 Vector<U> &sol, Bool doSVD=False);
162 // </group>
163 // Get the covariance matrix. False if an error occurred
164 // (of size <src>nUnknowns * nUnknowns</src>)
165 // <group>
166 template <class U>
167 Bool getCovariance(U *covar) {
168 return LSQFit::getCovariance(covar); }
169 template <class U>
170 Bool getCovariance(std::complex<U> *covar) {
171 return LSQFit::getCovariance(covar); }
172 template <class U>
174 // </group>
175 // Get main diagonal of covariance function (of size <src>nUnknowns</src>)
176 // <group>
177 template <class U>
180 template <class U>
181 Bool getErrors(std::complex<U> *errors) {
182 return LSQFit::getErrors(errors); }
183 template <class U>
186 template <class U>
190 // </group>
191
192private:
193
194 //# Data
195
196};
197
198
199} //# NAMESPACE CASACORE - END
200
201#ifndef CASACORE_NO_AUTO_TEMPLATES
202#include <casacore/scimath/Fitting/LSQaips.tcc>
203#endif //# CASACORE_NO_AUTO_TEMPLATES
204#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:767
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:854
uInt nConstraints() const
Get the number of constraints.
Definition LSQFit.h:769
static const String sol
Definition LSQFit.h:855
LSQFit & operator=(const LSQFit &other)
Assignment (deep copy)
Traits for numeric classes used
Definition LSQTraits.h:95
LSQaips(const LSQaips &other)
Copy constructor (deep copy)
Definition LSQaips.h:103
Bool solveLoop(uInt &nRank, std::complex< U > *sol, Bool doSVD=False)
Definition LSQaips.h:137
LSQaips(uInt nUnknowns, const LSQReal &, uInt nConstraints=0)
Allow explicit complex/real specification.
Definition LSQaips.h:94
void solve(U &sol)
Definition LSQaips.h:123
Bool getCovariance(Array< U > &covar)
void solve(Vector< U > &sol)
Definition LSQaips.h:125
Bool solveLoop(Double &fit, uInt &nRank, U *sol, Bool doSVD=False)
Definition LSQaips.h:148
LSQaips()
Default constructor (empty, real, only usable after a set(nUnknowns))
Definition LSQaips.h:101
Bool solveLoop(Double &fit, uInt &nRank, Vector< U > &sol, Bool doSVD=False)
Bool getErrors(std::complex< U > *errors)
Definition LSQaips.h:181
Bool getCovariance(U *covar)
Get the covariance matrix.
Definition LSQaips.h:167
Bool getErrors(Vector< U > &errors)
Definition LSQaips.h:187
Bool solveLoop(uInt &nRank, U &sol, Bool doSVD=False)
Definition LSQaips.h:141
void solve(std::complex< U > *sol)
Definition LSQaips.h:121
LSQaips & operator=(const LSQaips &other)
Assignment (deep copy)
Definition LSQaips.h:105
Bool getErrors(U *errors)
Get main diagonal of covariance function (of size nUnknowns)
Definition LSQaips.h:178
Bool solveLoop(Double &fit, uInt &nRank, std::complex< U > *sol, Bool doSVD=False)
Definition LSQaips.h:152
Bool solveLoop(uInt &nRank, U *sol, Bool doSVD=False)
Solve a Levenberg-Marquardt loop.
Definition LSQaips.h:133
Bool getErrors(U &errors)
Definition LSQaips.h:184
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:90
Bool getCovariance(std::complex< U > *covar)
Definition LSQaips.h:170
void solve(U *sol)
Solve normal equations.
Definition LSQaips.h:119
Bool solveLoop(Double &fit, uInt &nRank, U &sol, Bool doSVD=False)
Definition LSQaips.h:156
const Char * data() const
As pointer to char array
Definition String.h:557
String & resize(size_type n)
Resize by truncating or extending with copies of c (default Char())
Definition String.h:359
this file contains all the compiler specific defines
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