casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LinearEquation.h
Go to the documentation of this file.
1 //# LinearEquation.h: this defines LinearEquation
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 //# $Id$
28 
29 #ifndef SYNTHESIS_LINEAREQUATION_H
30 #define SYNTHESIS_LINEAREQUATION_H
31 
32 
33 #include <casa/aips.h>
36 
37 
38 namespace casa { //# NAMESPACE CASA - BEGIN
39 
40 // <summary> defines a relationship between Domain and Range objects </summary>
41 
42 // <use visibility=export>
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="ResidualEquation">ResidualEquation</linkto>
51 // </prerequisite>
52 //
53 // <etymology>
54 // LinearEquation was originally conceived for implementing linear
55 // equations (like Ax=b) but was in hindsight found to be more general.
56 // </etymology>
57 //
58 // <synopsis>
59 // This abstract class defines the basic functions used for forward
60 // modelling of measured data of "Range" data type. It defines the
61 // functions used to transform a model, of "Domain" data type to predicted
62 // data. It can also compare the predicted data with the measured data and
63 // return residuals to classes derived from LinearModel which can then be
64 // used to update the model.
65 // </synopsis>
66 //
67 // <example>
68 // I'll pass this class into a subroutine as an actual instance of an
69 // abstract class cannot be constructed.
70 // <srcblock>
71 // void foo(LinearModel< Image<casacore::Float> > mod,
72 // LinearEquation<Image<casacore::Float>, VisibilitySet>)
73 // VisibilitySet predictedVisibility;
74 // eqn.evaluate(predictedVisibility, mod);
75 // </srcblock>
76 // </example>
77 //
78 // <motivation>
79 // This class was originally conceived to be used in implementing
80 // deconvolution algorithms. I would not be surprised if it found wider
81 // applicability.
82 // </motivation>
83 //
84 // <templating arg=Domain>
85 // I do not see any restrictions on the Domain class. Its up to the derived
86 // class to handle the the appropriate Domain.
87 // </templating>
88 // <templating arg=Range>
89 // In order to calculate residuals it will probably be necessary for
90 // subtraction to be defined on the Range class, as well as some way for
91 // data in the Range data type to be converted back into the Domain data
92 // type. However it is left up to the derived classes to implement this.
93 // </templating>
94 //
95 // <thrown>
96 // This is an interface class and does not contain any implementation (and
97 // hence does not throw exceptions)
98 // </thrown>
99 //
100 // <todo asof="1996/03/28">
101 // I expect that additional functions, other than evaluate() and those
102 // derived from ResidualEquation will be necessary. I have yet to decide if
103 // they should be defined in this class or derived classes.
104 // </todo>
105 
106 template<class Domain, class Range> class LinearEquation:
107  public ResidualEquation<Domain>
108 {
109 public:
110  // A virtual destructor may be necessary for use in derived classes.
111  virtual ~LinearEquation();
112 
113  // This function evaluates the Equation for the specified model.
114  // It returns false if the result could not be computed.
115  virtual casacore::Bool evaluate(Range & result,
116  const LinearModel<Domain>& model) = 0;
117 
118  // evaluate residual
119  virtual casacore::Bool residual(Domain & answer,
120  const LinearModel<Domain> & model) = 0;
121 
122  // Same as above, but also calculates Chi^2
123  virtual casacore::Bool residual(Domain & answer, casacore::Float & chisq,
124  const LinearModel<Domain> & model) = 0;
125 
126  // Same as above, but also calculates Chi^2
127  // considering a mask
128  virtual casacore::Bool residual(Domain & answer, casacore::Float & chisq,
129  Domain & mask,
130  const LinearModel<Domain> & model) = 0;
131 
132 };
133 
134 } //# NAMESPACE CASA - END
135 
136 #ifndef AIPS_NO_TEMPLATE_SRC
137 #include <synthesis/MeasurementEquations/LinearEquation.tcc>
138 #endif //# AIPS_NO_TEMPLATE_SRC
139 #endif
140 
141 
virtual casacore::Bool evaluate(Range &result, const LinearModel< Domain > &model)=0
This function evaluates the Equation for the specified model.
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
Interface class containing functions returning &quot;Domain&quot; type.
Definition: Deconvolver.h:56
virtual casacore::Bool residual(Domain &answer, const LinearModel< Domain > &model)=0
evaluate residual
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
float Float
Definition: aipstype.h:54
defines a relationship between Domain and Range objects
virtual ~LinearEquation()
A virtual destructor may be necessary for use in derived classes.
Provides a model for use in model fitting applications.