casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
LinearEquation.h
Go to the documentation of this file.
00001 //# LinearEquation.h: this defines LinearEquation
00002 //# Copyright (C) 1996,1997,1999,2000
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id$
00028 
00029 #ifndef SYNTHESIS_LINEAREQUATION_H
00030 #define SYNTHESIS_LINEAREQUATION_H
00031 
00032 
00033 #include <casa/aips.h>
00034 #include <synthesis/MeasurementEquations/LinearModel.h>
00035 #include <synthesis/MeasurementEquations/ResidualEquation.h>
00036 
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 // <summary> defines a relationship between Domain and Range objects </summary>
00041 
00042 // <use visibility=export>
00043 
00044 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00045 // </reviewed>
00046 
00047 // <prerequisite> 
00048 // This class should be read in conjunction with: 
00049 // <li> <linkto class="LinearModel">LinearModel</linkto>
00050 // <li> <linkto class="ResidualEquation">ResidualEquation</linkto>
00051 // </prerequisite>
00052 //
00053 // <etymology>
00054 //  LinearEquation was originally conceived for implementing linear
00055 //  equations (like Ax=b) but was in hindsight found to be more general.
00056 // </etymology>
00057 //
00058 // <synopsis>
00059 // This abstract class defines the basic functions used for forward
00060 // modelling of measured data of "Range" data type. It defines the
00061 // functions used to transform a model, of "Domain" data type to predicted
00062 // data. It can also compare the predicted data with the measured data and
00063 // return residuals to classes derived from LinearModel which can then be
00064 // used to update the model.
00065 // </synopsis>
00066 //
00067 // <example>
00068 // I'll pass this class into a subroutine as an actual instance of an
00069 // abstract class cannot be constructed. 
00070 // <srcblock>
00071 // void foo(LinearModel< Image<Float> > mod, 
00072 //          LinearEquation<Image<Float>, VisibilitySet>)
00073 // VisibilitySet predictedVisibility;
00074 // eqn.evaluate(predictedVisibility, mod); 
00075 // </srcblock>
00076 // </example>
00077 //
00078 // <motivation>
00079 // This class was originally conceived to be used in implementing
00080 // deconvolution algorithms. I would not be surprised if it found wider
00081 // applicability. 
00082 // </motivation>
00083 //
00084 // <templating arg=Domain>
00085 // I do not see any restrictions on the Domain class. Its up to the derived
00086 // class to handle the the appropriate Domain.
00087 // </templating>
00088 // <templating arg=Range>
00089 // In order to calculate residuals it will probably be necessary for
00090 // subtraction to be defined on the Range class, as well as some way for
00091 // data in the Range data type to be converted back into the Domain data
00092 // type. However it is left up to the derived classes to implement this. 
00093 // </templating>
00094 //
00095 // <thrown>
00096 // This is an interface class and does not contain any implementation (and
00097 // hence does not throw exceptions)
00098 // </thrown>
00099 //
00100 // <todo asof="1996/03/28">
00101 // I expect that additional functions, other than evaluate() and those
00102 // derived from ResidualEquation will be necessary. I have yet to decide if
00103 // they should be defined in this class or derived classes.
00104 // </todo>
00105 
00106 template<class Domain, class Range> class LinearEquation: 
00107   public ResidualEquation<Domain>
00108 {
00109 public:
00110   // A virtual destructor may be necessary for use in derived classes.
00111   virtual ~LinearEquation();
00112 
00113   // This function evaluates the Equation for the specified model.
00114   // It returns False if the result could not be computed.
00115   virtual Bool evaluate(Range & result, 
00116                         const LinearModel<Domain>& model) = 0;
00117 
00118   // evaluate residual
00119   virtual Bool residual(Domain & answer,
00120                         const LinearModel<Domain> & model) = 0;
00121   
00122   // Same as above, but also calculates Chi^2
00123   virtual Bool residual(Domain & answer, Float & chisq,
00124                         const LinearModel<Domain> & model) = 0;
00125 
00126   // Same as above, but also calculates Chi^2
00127   // considering a mask
00128   virtual Bool residual(Domain & answer, Float & chisq,
00129                         Domain & mask,
00130                         const LinearModel<Domain> & model) = 0;
00131 
00132 };
00133 
00134 } //# NAMESPACE CASA - END
00135 
00136 #ifndef AIPS_NO_TEMPLATE_SRC
00137 #include <synthesis/MeasurementEquations/LinearEquation.tcc>
00138 #endif //# AIPS_NO_TEMPLATE_SRC
00139 #endif
00140 
00141