casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ResidualEquation.h
Go to the documentation of this file.
1 //# ResidualEquation.h: this defines ResidualEquation
2 //# Copyright (C) 1996,1997,1999,2000
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 //#
27 //#
28 //# $Id$
29 
30 #ifndef SYNTHESIS_RESIDUALEQUATION_H
31 #define SYNTHESIS_RESIDUALEQUATION_H
32 
33 #include <casa/aips.h>
35 
36 namespace casa { //# NAMESPACE CASA - BEGIN
37 
38 template<class Domain> class LinearModel;
39 
40 // <summary>Interface class containing functions returning "Domain" type</summary>
41 
42 // <use visibility=local>
43 
44 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
45 // </reviewed>
46 
47 // <prerequisite>
48 // This class should be read in conjunction with:
49 // <li> <linkto class="LinearModel">LinearModel</linkto>
50 // <li> <linkto class="LinearEquation">LinearEquation</linkto>
51 // </prerequisite>
52 //
53 // <etymology>
54 // ResidualEquation reflects the fact that the residual() function was the
55 // first, and perhaps most important member of the class.
56 // </etymology>
57 //
58 // <synopsis>
59 // ResidualEquation is an abstract interface class into the more extensive
60 // LinearEquation class. It is composed of the subset of functions from
61 // LinearEquation which return objects of the "Domain", type. These objects
62 // can be used by the solve() function in the LinearModel to determine a new
63 // model. The separation of the ResidualEquation functions isolates the
64 // model, of type "Domain" from knowing what the data "Range", used by the
65 // LinearEquation class is.
66 // </synopsis>
67 //
68 // <example>
69 // Suppose we have a simple class that has a vector model and knows (using
70 // the solve() function) how to update this vector if it is told the error
71 // betweeen the measured data and a model of the data produced using the
72 // current vector.
73 // <srcblock>
74 // SimpleModel< casacore::Vector<casacore::Float> > simplemodel;
75 // </srcblock>
76 //
77 // Suppose we also have a big complicated equation that does
78 // the forward modelling from vectors to some arbitrary class;
79 //
80 // <srcblock>
81 // FancyEquation<casacore::Vector<casacore::Float>, VisibilitySet> eqn;
82 // </srcblock>
83 //
84 // Then Simplemodel class does not need to know anything about the
85 // VisibilitySet class as it knows that the FancyEquation class will have
86 // (via inheritence) a ResidualEquation interface which returns vectors,
87 // so that it can use code like:
88 // <srcblock>
89 // casacore::Vector<casacore::Float> error;
90 // if (eqn.residual(*this, error)){
91 // use the error to determine a new model
92 // }
93 // </srcblock>
94 // as part of the solve function.
95 // </example>
96 //
97 // <motivation>
98 // The main reason for the existence of this class is to isolate the type of
99 // the model ("Domain" type) from knowing what the "Range" of the equation is.
100 // </motivation>
101 //
102 // <templating arg=Domain>
103 // The template determines the type used to return the results for all the
104 // functions in this class. So even complicated template arguements should
105 // be OK.
106 // </templating>
107 //
108 // <thrown>
109 // This is an interface class and does not contain any implementation (and
110 // hence does not throw exceptions)
111 // </thrown>
112 //
113 // <todo asof="1996/03/29">
114 // <li> decide whether to add a derivative function
115 // <li> decide whether functions which return scalars should also be in
116 // this class
117 // </todo>
118 
119 template<class Domain> class ResidualEquation
120 {
121 public:
122  // A virtual destructor may be necessary for use in derived classes.
123  virtual ~ResidualEquation();
124 
125  // The canonical member of this class defines a function which
126  // gives the residual when the model is propagated through the
127  // equation and compared with the data. It returns false if the answer
128  // could not be computed.
129  virtual casacore::Bool residual(Domain & answer,
130  const LinearModel<Domain> & model) = 0;
131 
132  // Same as above, but also calculates Chi^2 (rms of residual image)
133  virtual casacore::Bool residual(Domain & answer, casacore::Float & chisq,
134  const LinearModel<Domain> & model) = 0;
135 
136  // Same as above, but also calculates Chi^2 (rms of residual image)
137  // considering a mask image
138  virtual casacore::Bool residual(Domain & answer, casacore::Float & chisq,
139  Domain & mask,
140  const LinearModel<Domain> & model) = 0;
141 
142  // A proposal for another member of this class which returns the
143  // derivative of the equation with respect to the current model.
144  // virtual casacore::Bool derivative(const LinearModel<Domain> & model,
145  // Domain & answer) = 0;
146 
147 
148 };
149 
150 
151 } //# NAMESPACE CASA - END
152 
153 #ifndef AIPS_NO_TEMPLATE_SRC
154 #include <synthesis/MeasurementEquations/ResidualEquation.tcc>
155 #endif //# AIPS_NO_TEMPLATE_SRC
156 #endif
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
virtual ~ResidualEquation()
A virtual destructor may be necessary for use in derived classes.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual casacore::Bool residual(Domain &answer, const LinearModel< Domain > &model)=0
The canonical member of this class defines a function which gives the residual when the model is prop...
float Float
Definition: aipstype.h:54