casacore
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: aips2-request@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 //# $Id$
27 
28 #ifndef SCIMATH_LSQAIPS_H
29 #define SCIMATH_LSQAIPS_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/Arrays/Array.h>
34 #include <casacore/casa/Arrays/Vector.h>
35 #include <casacore/casa/Arrays/VectorSTLIterator.h>
36 #include <casacore/scimath/Fitting/LSQFit.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 
42 // <summary>
43 // Interface for Casacore Vectors in least squares fitting
44 // </summary>
45 // <reviewed reviewer="" date="2004/04/01" tests=""
46 // demos="">
47 // </reviewed>
48 
49 // <prerequisite>
50 // <li> <linkto class=LSQFit>LSQFit</linkto> class
51 // </prerequisite>
52 //
53 // <etymology>
54 // From Least SQuares and aips++ (now Casacore)
55 // </etymology>
56 //
57 // <synopsis>
58 // The interface used in the <src>LSQaips</src> class is in terms of
59 // Casacore Vectors directly, rather than an STL iterator (like
60 // <linkto class=VectorSTLIterator>VectorSTLIterator</linkto>) based
61 // on it.
62 //
63 // Its functionality is identical to that of the
64 // <linkto class=LSQFit>LSQFit</linkto> class, although it will be faster to use
65 // the iterator interface directly, since constructing of temporary iterators
66 // can be avoided
67 // </synopsis>
68 //
69 // <example>
70 // See the <src>tLSQaips.cc</src> program for extensive examples.
71 // Note: this class is in an interim state.
72 // </example>
73 //
74 // <motivation>
75 // The class was written to enable easy tranistion from the current Vector
76 // to the Vector::iterator interface.
77 // </motivation>
78 //
79 // <todo asof="2004/04/02">
80 // <li> create all the method interfaces
81 // </todo>
82 
83 class LSQaips : public LSQFit {
84  public:
85 
86  //# Constructors
87  // Construct an object with the number of unknown, knowns and
88  // constraints, and type, using the default collinearity factor and the
89  // default Levenberg-Marquardt adjustment factor
90  // <group>
91  // Assume real
94  // Allow explicit complex/real specification
95  // <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  //# Destructor
112  ~LSQaips() {;}
113 
114  //# Operators
115 
116  //# General Member Functions
117  // Solve normal equations.
118  // The solution will be given in <src>sol</src>.
119  // <group>
120  template <class U>
121  void solve(U *sol) { LSQFit::solve(sol); }
122  template <class U>
123  void solve(std::complex<U> *sol) { LSQFit::solve(sol); }
124  template <class U>
125  void solve(U &sol) { LSQFit::solve(sol); }
126  template <class U>
127  void solve(Vector<U> &sol) {
129  LSQFit::solve(sol.data()); }
130  // </group>
131  // Solve a Levenberg-Marquardt loop. Note that the solution <src>sol</src>
132  // is used both and input and output. No check on the size is done.
133  // <group>
134  template <class U>
136  U *sol, Bool doSVD=False) {
137  return LSQFit::solveLoop(nRank, sol, doSVD); }
138  template <class U>
140  std::complex<U> *sol, Bool doSVD=False) {
141  return LSQFit::solveLoop(nRank, sol, doSVD); }
142  template <class U>
144  U &sol, Bool doSVD=False) {
145  return LSQFit::solveLoop(nRank, sol, doSVD); }
146  template <class U>
148  Vector<U> &sol, Bool doSVD=False);
149  template <class U>
150  Bool solveLoop(Double &fit, uInt &nRank,
151  U *sol, Bool doSVD=False) {
152  return LSQFit::solveLoop(fit, nRank, sol, doSVD); }
153  template <class U>
154  Bool solveLoop(Double &fit, uInt &nRank,
155  std::complex<U> *sol, Bool doSVD=False) {
156  return LSQFit::solveLoop(fit, nRank, sol, doSVD); }
157  template <class U>
158  Bool solveLoop(Double &fit, uInt &nRank,
159  U &sol, Bool doSVD=False) {
160  return LSQFit::solveLoop(fit, nRank, sol, doSVD); }
161  template <class U>
162  Bool solveLoop(Double &fit, uInt &nRank,
163  Vector<U> &sol, Bool doSVD=False);
164  // </group>
165  // Get the covariance matrix. False if an error occurred
166  // (of size <src>nUnknowns * nUnknowns</src>)
167  // <group>
168  template <class U>
169  Bool getCovariance(U *covar) {
170  return LSQFit::getCovariance(covar); }
171  template <class U>
172  Bool getCovariance(std::complex<U> *covar) {
173  return LSQFit::getCovariance(covar); }
174  template <class U>
176  // </group>
177  // Get main diagonal of covariance function (of size <src>nUnknowns</src>)
178  // <group>
179  template <class U>
181  return LSQFit::getErrors(errors); }
182  template <class U>
183  Bool getErrors(std::complex<U> *errors) {
184  return LSQFit::getErrors(errors); }
185  template <class U>
187  return LSQFit::getErrors(errors); }
188  template <class U>
191  return LSQFit::getErrors(errors.data()); }
192  // </group>
193 
194 private:
195 
196  //# Data
197 
198 };
199 
200 
201 } //# NAMESPACE CASACORE - END
202 
203 #ifndef CASACORE_NO_AUTO_TEMPLATES
204 #include <casacore/scimath/Fitting/LSQaips.tcc>
205 #endif //# CASACORE_NO_AUTO_TEMPLATES
206 #endif
Type of complex numeric class indicator
Definition: LSQTraits.h:71
void solve(U *sol)
Solve normal equations.
uInt nUnknowns() const
Get the number of unknowns.
Definition: LSQFit.h:769
Bool solveLoop(uInt &nRank, U *sol, Bool doSVD=False)
Solve a loop in a non-linear set.
LSQFit & operator=(const LSQFit &other)
Assignment (deep copy)
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:856
uInt nConstraints() const
Get the number of constraints.
Definition: LSQFit.h:771
static const String sol
Definition: LSQFit.h:857
Traits for numeric classes used
Definition: LSQTraits.h:97
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:139
LSQaips(uInt nUnknowns, const LSQReal &, uInt nConstraints=0)
Allow explicit complex/real specification.
Definition: LSQaips.h:96
void solve(U &sol)
Definition: LSQaips.h:125
Bool getCovariance(Array< U > &covar)
void solve(Vector< U > &sol)
Definition: LSQaips.h:127
Bool solveLoop(Double &fit, uInt &nRank, U *sol, Bool doSVD=False)
Definition: LSQaips.h:150
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:183
Bool getCovariance(U *covar)
Get the covariance matrix.
Definition: LSQaips.h:169
Bool getErrors(Vector< U > &errors)
Definition: LSQaips.h:189
Bool solveLoop(uInt &nRank, U &sol, Bool doSVD=False)
Definition: LSQaips.h:143
void solve(std::complex< U > *sol)
Definition: LSQaips.h:123
Bool getErrors(U *errors)
Get main diagonal of covariance function (of size nUnknowns)
Definition: LSQaips.h:180
Bool solveLoop(Double &fit, uInt &nRank, std::complex< U > *sol, Bool doSVD=False)
Definition: LSQaips.h:154
Bool solveLoop(uInt &nRank, U *sol, Bool doSVD=False)
Solve a Levenberg-Marquardt loop.
Definition: LSQaips.h:135
Bool getErrors(U &errors)
Definition: LSQaips.h:186
LSQaips & operator=(const LSQaips &other)
Assignment (deep copy)
Definition: LSQaips.h:107
LSQaips(uInt nUnknowns, const LSQComplex &, uInt nConstraints=0)
Definition: LSQaips.h:98
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:92
Bool getCovariance(std::complex< U > *covar)
Definition: LSQaips.h:172
void solve(U *sol)
Solve normal equations.
Definition: LSQaips.h:121
Bool solveLoop(Double &fit, uInt &nRank, U &sol, Bool doSVD=False)
Definition: LSQaips.h:158
const Char * data() const
As pointer to char array
Definition: String.h:559
String & resize(size_type n)
Resize by truncating or extending with copies of c (default Char())
Definition: String.h:361
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Bool False
Definition: aipstype.h:44
unsigned int uInt
Definition: aipstype.h:51
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
double Double
Definition: aipstype.h:55