Line data Source code
1 : //# IncEntropy.h: this defines the virtual base class for Incremental Entropy 2 : //# Copyright (C) 1996,1997,1998,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: casa-feedback@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 : //# $Id$ 27 : 28 : #ifndef SYNTHESIS_INCENTROPY_H 29 : #define SYNTHESIS_INCENTROPY_H 30 : 31 : #include <casacore/casa/aips.h> 32 : #include <casacore/lattices/Lattices/Lattice.h> 33 : #include <casacore/casa/Arrays/Matrix.h> 34 : #include <casacore/casa/Arrays/Vector.h> 35 : #include <casacore/casa/Arrays/Array.h> 36 : #include <casacore/casa/BasicSL/String.h> 37 : 38 : namespace casa { //# NAMESPACE CASA - BEGIN 39 : 40 : //forward declaration 41 : class IncCEMemModel; 42 : 43 : // <summary>Base class for incremental entropies used by incremental MEM algorithm</summary> 44 : 45 : // <use visibility=export> 46 : 47 : // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 48 : // </reviewed> 49 : 50 : // <prerequisite> 51 : // <li> IncCEMemModel 52 : // </prerequisite> 53 : // 54 : // <etymology> 55 : // This class is called Entropy because it encapsulates the required 56 : // functionality of the entropy in the CE MEM algorithm. Inc is from 57 : // incremental, as the dirty image specifies an increment on a previous 58 : // major cycle's image, and the entropy is applied to the full 59 : // image + deltaImage. 60 : // </etymology> 61 : // 62 : // <synopsis> 63 : // Provide the generic interface to entropy functions. 64 : // 65 : // We calculate entropy, gradients, and Hessians (diagonal) of the entropy. 66 : // For efficiency reasons, we cannot restrict the methods to these calculations, 67 : // but must also subsume the loops over image pixels in which they are 68 : // used. In this way, the Entropy classes form a tight partnership with 69 : // the MemModel classes, taking over more responcibility than strict 70 : // functional encapsulation requires. 71 : // 72 : // This class heirarchy is used by CEMemModel, which implements 73 : // the Cornwell-Evans Maximum Entropy algorithm. 74 : // 75 : // In the Entropy constructor, we create a pointer to the CEMemModel for 76 : // reference to its Mem image, prior image, and default levels. 77 : // Since each sort of Entropy is a friend of the CEMemModel, it 78 : // has access to its private data. However, we vow here NOT to 79 : // touch it, just to look at it. Could have done read-only access, 80 : // but too lazy. 81 : // 82 : // </synopsis> 83 : // 84 : // <example> 85 : // <srcblock> 86 : // EntropyI myEntropyEngine(myCEMemModel&); 87 : // 88 : // casacore::Float theEntropy myEntropyEngine.getEntropy(); 89 : // </srcblock> 90 : // </example> 91 : // 92 : // <motivation> 93 : // This class is needed to encapsulate the methods of different 94 : // functional forms of the entropy, used by Maximum Entropy (MEM) 95 : // deconvolution algorithms. 96 : // </motivation> 97 : // 98 : // 99 : // <todo asof="1998/08/02"> 100 : // <li> Nothing done yet! 101 : // </todo> 102 : 103 : 104 : // virtual base class 105 : class IncEntropy 106 : { 107 : public: 108 : 109 : // The default constructor is good enough, does nothing. 110 : // the MemImage and Prior image are stored in the MemModel. 111 : IncEntropy(); 112 : 113 : 114 : // A virtual destructor may be necessary for use in derived classes. 115 : virtual ~IncEntropy(); 116 : 117 : 118 : // calculate the entropy for the whole image 119 : virtual casacore::Float formEntropy() = 0; 120 : 121 : // calculate the Gradient dot Gradient matrix 122 : virtual void formGDG(casacore::Matrix<double> & ) = 0; 123 : 124 : // calculate the Gradient dot Gradient matrix, calculate Step 125 : virtual void formGDGStep(casacore::Matrix<double> & ) = 0; 126 : 127 : // calculate Gradient dot Step 128 : virtual casacore::Double formGDS() = 0; 129 : 130 : // report the entropy type for a logging message 131 : virtual void entropyType(casacore::String &) = 0; 132 : // report the entropy name 133 : virtual void entropyName(casacore::String &) = 0; 134 : 135 : // set the MemModel 136 0 : void setMemModel(IncCEMemModel& mmm) { cemem_ptr = &mmm; } 137 : 138 : // infoBanner 139 : virtual void infoBanner() = 0; 140 : 141 : // infoPerIteration 142 : virtual void infoPerIteration(casacore::uInt iteration) = 0; 143 : 144 : // are there any constraints on how the Image minimum 145 : // gets relaxed? 146 : virtual casacore::Float relaxMin() = 0; 147 : 148 : // each entropy type can have its distinct convergence 149 : // criteria 150 : virtual casacore::Bool testConvergence() = 0; 151 : 152 : protected: 153 : 154 : 155 : enum GRADTYPE {H=0, C, F, J }; 156 : 157 : 158 : IncCEMemModel *cemem_ptr; 159 : 160 : IncEntropy(const IncEntropy &); 161 : 162 : 163 : 164 : }; 165 : 166 : 167 : // <summary>Thermodynamic or Information entropy for incremental MEM</summary> 168 : 169 : class IncEntropyI : public IncEntropy 170 : { 171 : public: 172 : 173 : // This default constructor is good enough for me. 174 : IncEntropyI(); 175 : 176 : // destructor 177 : ~IncEntropyI(); 178 : 179 : // calculate the entropy for the whole image 180 : casacore::Float formEntropy(); 181 : 182 : // calculate the Gradient dot Gradient matrix 183 : void formGDG(casacore::Matrix<casacore::Double>& ); 184 : 185 : // calculate the Gradient dot Gradient matrix, calculate Step 186 : void formGDGStep(casacore::Matrix<double> & ); 187 : 188 : // calculate Gradient dot Step 189 : casacore::Double formGDS(); 190 : 191 : // report the entropy type for a logging message 192 0 : void entropyType(casacore::String & str) 193 0 : { str = "entropy type I (information/thermodynamic)"; } 194 : // report the entropy name 195 0 : void entropyName(casacore::String & str) 196 0 : { str = "ENTROPY"; } 197 : 198 : // infoBanner 199 : void infoBanner(); 200 : 201 : // infoIteration 202 : void infoPerIteration(casacore::uInt iteration); 203 : 204 : // relax image Min 205 : casacore::Float relaxMin(); 206 : 207 : // each entropy type can have its distinct convergence 208 : // criteria 209 : casacore::Bool testConvergence(); 210 : 211 : protected: 212 : 213 : IncEntropyI(const IncEntropyI& ); 214 : IncEntropyI& operator=(const IncEntropyI& ); 215 : 216 : }; 217 : 218 : 219 : 220 : // <summary>Emptiness measure for incremental MEM</summary> 221 : class IncEntropyEmptiness : public IncEntropy 222 : { 223 : public: 224 : 225 : // This default constructor is good enough for me. 226 : IncEntropyEmptiness(); 227 : 228 : // destructor 229 : ~IncEntropyEmptiness(); 230 : 231 : // calculate the entropy for the whole image 232 : casacore::Float formEntropy(); 233 : 234 : // calculate the Gradient dot Gradient matrix 235 : void formGDG(casacore::Matrix<casacore::Double>& ); 236 : 237 : // calculate the Gradient dot Gradient matrix, calculate Step 238 : void formGDGStep(casacore::Matrix<double> & ); 239 : 240 : // calculate Gradient dot Step 241 : casacore::Double formGDS(); 242 : 243 : // report the entropy type for a logging message 244 0 : void entropyType(casacore::String & str) 245 0 : { str = "entropy type U (emptiness)"; } 246 : // report the entropy Name 247 0 : void entropyName(casacore::String & str) 248 0 : { str = "EMPTINESS"; } 249 : 250 : // infoBanner 251 : void infoBanner(); 252 : 253 : // infoIteration 254 : void infoPerIteration(casacore::uInt iteration); 255 : 256 : // relax image Min 257 : casacore::Float relaxMin(); 258 : 259 : // each entropy type can have its distinct convergence 260 : // criteria 261 : casacore::Bool testConvergence(); 262 : 263 : protected: 264 : 265 : IncEntropyEmptiness(const IncEntropyEmptiness& ); 266 : IncEntropyEmptiness& operator=(const IncEntropyEmptiness& ); 267 : 268 : }; 269 : 270 : 271 : 272 : 273 : 274 : 275 : } //# NAMESPACE CASA - END 276 : 277 : #endif