casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FittingProxy.h
Go to the documentation of this file.
00001 //# DittingProxy.h: This class gives object access to Fitting
00002 //# Copyright (C) 2006
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This program is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU General Public License as published by the Free
00007 //# Software Foundation; either version 2 of the License, or (at your option)
00008 //# any later version.
00009 //#
00010 //# This program 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 General Public License for
00013 //# more details.
00014 //#
00015 //# You should have received a copy of the GNU General Public License along
00016 //# with this program; if not, write to the Free Software Foundation, Inc.,
00017 //# 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 //# $Id: FittingProxy.h 19692 2006-10-11 05:39:32Z mmarquar $
00027 
00028 #ifndef SCIMATH_FITTINGPROXY_H
00029 #define SCIMATH_FITTINGPROXY_H
00030 
00031 //# Includes
00032 
00033 #include <casa/aips.h>
00034 #include <casa/Containers/Record.h>
00035 
00036 #include <casa/namespace.h>
00037 //# Forward declarations
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039   class String;
00040   template<class T> class GenericL2Fit;
00041   template<class T> class Vector;
00042 } //# NAMESPACE CASA - END
00043 
00044 // <summary> This class gives Proxy to Fitting connection</summary>
00045 
00046 // <use visibility=export>
00047 
00048 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00049 // </reviewed>
00050 
00051 // <prerequisite>
00052 //   <li> <linkto module=Fitting>Fitting</linkto>
00053 // </prerequisite>
00054 
00055 // <etymology>
00056 // Distributed Object and fitting
00057 // </etymology>
00058 
00059 // <synopsis>
00060 // The class makes the connection between the
00061 // <linkto module=Fitting>Fitting</linkto> module and 
00062 // other object system. It provides a series of proxy callable
00063 // methods. See Aips++ Note 197 for details. <br>
00064 // Operations supported
00065 // are all the fitting methods supported in the Fitting module
00066 // </synopsis>
00067 
00068 // <example>
00069 // </example>
00070 
00071 // <motivation>
00072 // To provide a direct user interface between the user and 
00073 // <linkto module=Fitting>Fitting</linkto> related calculations.
00074 // </motivation>
00075 
00076 // <todo asof="2004/08/30">
00077 //  <li> Nothing I know of
00078 // </todo>
00079 
00080 class FittingProxy  {
00081 
00082 public:
00083   //# Standard constructors/destructors
00084   FittingProxy();
00085   virtual ~FittingProxy();
00086 
00087   Int getid();
00088   Record getstate(Int id);
00089   Bool init(Int id, Int n, Int tp, Double colfac, Double lmfac);
00090   Bool done(Int id);
00091   Bool reset(Int id);
00092   Bool set(Int id, Int nin, Int tpin, Double colfac, Double lmfac);
00093   Record functional(Int id, const Record& fnc, 
00094                     const Vector<Double>& xval,
00095                     const Vector<Double>& yval, 
00096                     const Vector<Double>& wt,
00097                     Int mxit, const Record& constraint);
00098   Record linear(Int id, const Record& fnc, 
00099                 const Vector<Double>& xval,
00100                 const Vector<Double>& yval, 
00101                 const Vector<Double>& wt,
00102                 const Record& constraint);
00103   Record cxfunctional(Int id, const Record& fnc, 
00104                       const Vector<DComplex>& xval,
00105                       const Vector<DComplex>& yval, 
00106                       const Vector<DComplex>& wt,
00107                       Int mxit, const Record& constraint);
00108   Record cxlinear(Int id, const Record& fnc, 
00109                   const Vector<DComplex>& xval,
00110                   const Vector<DComplex>& yval, 
00111                   const Vector<DComplex>& wt,
00112                   const Record& constraint);
00113   
00114 private:
00115   // Class to aid in distributing different fitters
00116   class FitType {
00117   public:
00118     //# Constructors
00119     // Default constructor: no method known
00120     FitType();
00121     // Destructor
00122     ~FitType();
00123     //# Method
00124     // Set a fitter pointer (real or complex)
00125     // <group>
00126     void setFitter   (GenericL2Fit<Double> *ptr);
00127     void setFitterCX (GenericL2Fit<DComplex> *ptr);
00128     // </group>
00129     // Get a fitter pointer (real or complex)
00130     // <group>
00131     GenericL2Fit<Double>   *const &getFitter() const;
00132     GenericL2Fit<DComplex> *const &getFitterCX() const;
00133     // </group>
00134     // Set the status
00135     void setStatus(Int n, Int typ, Double colfac, Double lmfac);
00136     // Get the number of terms in condition equation
00137     Int getNceq() const { return nceq_p;} ;
00138     // Get the number of unknowns
00139     Int getN() const { return n_p;} ;
00140     // Get the number of real unknowns
00141     Int getNreal() const { return nreal_p;} ;
00142     // Get the type
00143     Int getType() const { return typ_p;} ;
00144     // Get the collinearity factor
00145     Double getColfac() const { return colfac_p;} ;
00146     // Get the Levenberg-Marquardt factor
00147     Double getLMfac() const { return lmfac_p;} ;
00148     // Set solution done or not
00149     void setSolved(Bool solved);
00150     // Solution done?
00151     Bool getSolved() const { return soldone_p;} ;
00152   private:
00153     // Copy constructor: not implemented
00154     FitType(const FitType &other); 
00155     // Assignment: not implemented
00156     FitType &operator=(const FitType &other);
00157     //# Data
00158     // Pointer to a Fitting Machine: real or complex
00159     // <group>
00160     casa::GenericL2Fit<Double> *fitter_p;
00161     casa::GenericL2Fit<DComplex> *fitterCX_p;
00162     // </group>
00163     // Number of unknowns
00164     Int n_p;
00165     // Number of terms in condition equation
00166     Int nceq_p;
00167     // Number of real unknowns
00168     Int nreal_p;
00169     // Type
00170     Int typ_p;
00171     // Collinearity factor
00172     Double colfac_p;
00173     // Levenberg-Marquardt factor
00174     Double lmfac_p;
00175     // Solution done?
00176     Bool soldone_p;
00177     // System's rank deficiency
00178     uInt nr_p;
00179   };
00180   //# Member functions
00181   //# Data
00182   // Number of FitType obkects present
00183   uInt nFitter_p;
00184   // List of FitTypes
00185   FitType **list_p;
00186 };
00187 
00188 
00189 #endif