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