casa
$Rev:20696$
|
00001 //# IncEntropy.h: this defines the virtual base class for Incremental Entropy 00002 //# Copyright (C) 1996,1997,1998,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 //# $Id$ 00027 00028 #ifndef SYNTHESIS_INCENTROPY_H 00029 #define SYNTHESIS_INCENTROPY_H 00030 00031 #include <casa/aips.h> 00032 #include <lattices/Lattices/Lattice.h> 00033 #include <casa/Arrays/Matrix.h> 00034 #include <casa/Arrays/Vector.h> 00035 #include <casa/Arrays/Array.h> 00036 #include <casa/BasicSL/String.h> 00037 00038 namespace casa { //# NAMESPACE CASA - BEGIN 00039 00040 //forward declaration 00041 class IncCEMemModel; 00042 00043 // <summary>Base class for incremental entropies used by incremental MEM algorithm</summary> 00044 00045 // <use visibility=export> 00046 00047 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00048 // </reviewed> 00049 00050 // <prerequisite> 00051 // <li> IncCEMemModel 00052 // </prerequisite> 00053 // 00054 // <etymology> 00055 // This class is called Entropy because it encapsulates the required 00056 // functionality of the entropy in the CE MEM algorithm. Inc is from 00057 // incremental, as the dirty image specifies an increment on a previous 00058 // major cycle's image, and the entropy is applied to the full 00059 // image + deltaImage. 00060 // </etymology> 00061 // 00062 // <synopsis> 00063 // Provide the generic interface to entropy functions. 00064 // 00065 // We calculate entropy, gradients, and Hessians (diagonal) of the entropy. 00066 // For efficiency reasons, we cannot restrict the methods to these calculations, 00067 // but must also subsume the loops over image pixels in which they are 00068 // used. In this way, the Entropy classes form a tight partnership with 00069 // the MemModel classes, taking over more responcibility than strict 00070 // functional encapsulation requires. 00071 // 00072 // This class heirarchy is used by CEMemModel, which implements 00073 // the Cornwell-Evans Maximum Entropy algorithm. 00074 // 00075 // In the Entropy constructor, we create a pointer to the CEMemModel for 00076 // reference to its Mem image, prior image, and default levels. 00077 // Since each sort of Entropy is a friend of the CEMemModel, it 00078 // has access to its private data. However, we vow here NOT to 00079 // touch it, just to look at it. Could have done read-only access, 00080 // but too lazy. 00081 // 00082 // </synopsis> 00083 // 00084 // <example> 00085 // <srcblock> 00086 // EntropyI myEntropyEngine(myCEMemModel&); 00087 // 00088 // Float theEntropy myEntropyEngine.getEntropy(); 00089 // </srcblock> 00090 // </example> 00091 // 00092 // <motivation> 00093 // This class is needed to encapsulate the methods of different 00094 // functional forms of the entropy, used by Maximum Entropy (MEM) 00095 // deconvolution algorithms. 00096 // </motivation> 00097 // 00098 // 00099 // <todo asof="1998/08/02"> 00100 // <li> Nothing done yet! 00101 // </todo> 00102 00103 00104 // virtual base class 00105 class IncEntropy 00106 { 00107 public: 00108 00109 // The default constructor is good enough, does nothing. 00110 // the MemImage and Prior image are stored in the MemModel. 00111 IncEntropy(); 00112 00113 00114 // A virtual destructor may be necessary for use in derived classes. 00115 virtual ~IncEntropy(); 00116 00117 00118 // calculate the entropy for the whole image 00119 virtual Float formEntropy() = 0; 00120 00121 // calculate the Gradient dot Gradient matrix 00122 virtual void formGDG(Matrix<double> & ) = 0; 00123 00124 // calculate the Gradient dot Gradient matrix, calculate Step 00125 virtual void formGDGStep(Matrix<double> & ) = 0; 00126 00127 // calculate Gradient dot Step 00128 virtual Double formGDS() = 0; 00129 00130 // report the entropy type for a logging message 00131 virtual void entropyType(String &) = 0; 00132 // report the entropy name 00133 virtual void entropyName(String &) = 0; 00134 00135 // set the MemModel 00136 void setMemModel(IncCEMemModel& mmm) { cemem_ptr = &mmm; } 00137 00138 // infoBanner 00139 virtual void infoBanner() = 0; 00140 00141 // infoPerIteration 00142 virtual void infoPerIteration(uInt iteration) = 0; 00143 00144 // are there any constraints on how the Image minimum 00145 // gets relaxed? 00146 virtual Float relaxMin() = 0; 00147 00148 // each entropy type can have its distinct convergence 00149 // criteria 00150 virtual Bool testConvergence() = 0; 00151 00152 protected: 00153 00154 00155 enum GRADTYPE {H=0, C, F, J }; 00156 00157 00158 IncCEMemModel *cemem_ptr; 00159 00160 IncEntropy(const IncEntropy &); 00161 00162 00163 00164 }; 00165 00166 00167 // <summary>Thermodynamic or Information entropy for incremental MEM</summary> 00168 00169 class IncEntropyI : public IncEntropy 00170 { 00171 public: 00172 00173 // This default constructor is good enough for me. 00174 IncEntropyI(); 00175 00176 // destructor 00177 ~IncEntropyI(); 00178 00179 // calculate the entropy for the whole image 00180 Float formEntropy(); 00181 00182 // calculate the Gradient dot Gradient matrix 00183 void formGDG(Matrix<Double>& ); 00184 00185 // calculate the Gradient dot Gradient matrix, calculate Step 00186 void formGDGStep(Matrix<double> & ); 00187 00188 // calculate Gradient dot Step 00189 Double formGDS(); 00190 00191 // report the entropy type for a logging message 00192 void entropyType(String & str) 00193 { str = "entropy type I (information/thermodynamic)"; } 00194 // report the entropy name 00195 void entropyName(String & str) 00196 { str = "ENTROPY"; } 00197 00198 // infoBanner 00199 void infoBanner(); 00200 00201 // infoIteration 00202 void infoPerIteration(uInt iteration); 00203 00204 // relax image Min 00205 Float relaxMin(); 00206 00207 // each entropy type can have its distinct convergence 00208 // criteria 00209 Bool testConvergence(); 00210 00211 protected: 00212 00213 IncEntropyI(const IncEntropyI& ); 00214 IncEntropyI& operator=(const IncEntropyI& ); 00215 00216 }; 00217 00218 00219 00220 // <summary>Emptiness measure for incremental MEM</summary> 00221 class IncEntropyEmptiness : public IncEntropy 00222 { 00223 public: 00224 00225 // This default constructor is good enough for me. 00226 IncEntropyEmptiness(); 00227 00228 // destructor 00229 ~IncEntropyEmptiness(); 00230 00231 // calculate the entropy for the whole image 00232 Float formEntropy(); 00233 00234 // calculate the Gradient dot Gradient matrix 00235 void formGDG(Matrix<Double>& ); 00236 00237 // calculate the Gradient dot Gradient matrix, calculate Step 00238 void formGDGStep(Matrix<double> & ); 00239 00240 // calculate Gradient dot Step 00241 Double formGDS(); 00242 00243 // report the entropy type for a logging message 00244 void entropyType(String & str) 00245 { str = "entropy type U (emptiness)"; } 00246 // report the entropy Name 00247 void entropyName(String & str) 00248 { str = "EMPTINESS"; } 00249 00250 // infoBanner 00251 void infoBanner(); 00252 00253 // infoIteration 00254 void infoPerIteration(uInt iteration); 00255 00256 // relax image Min 00257 Float relaxMin(); 00258 00259 // each entropy type can have its distinct convergence 00260 // criteria 00261 Bool testConvergence(); 00262 00263 protected: 00264 00265 IncEntropyEmptiness(const IncEntropyEmptiness& ); 00266 IncEntropyEmptiness& operator=(const IncEntropyEmptiness& ); 00267 00268 }; 00269 00270 00271 00272 00273 00274 00275 } //# NAMESPACE CASA - END 00276 00277 #endif