casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IncEntropy.h
Go to the documentation of this file.
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: 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_INCENTROPY_H
29 #define SYNTHESIS_INCENTROPY_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 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
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  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 
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
181 
182  // calculate the Gradient dot Gradient matrix
184 
185  // calculate the Gradient dot Gradient matrix, calculate Step
187 
188  // calculate Gradient dot Step
190 
191  // report the entropy type for a logging message
193  { str = "entropy type I (information/thermodynamic)"; }
194  // report the entropy name
196  { str = "ENTROPY"; }
197 
198  // infoBanner
199  void infoBanner();
200 
201  // infoIteration
202  void infoPerIteration(casacore::uInt iteration);
203 
204  // relax image Min
206 
207  // each entropy type can have its distinct convergence
208  // criteria
210 
211 protected:
212 
213  IncEntropyI(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.
227 
228  // destructor
230 
231  // calculate the entropy for the whole image
233 
234  // calculate the Gradient dot Gradient matrix
236 
237  // calculate the Gradient dot Gradient matrix, calculate Step
239 
240  // calculate Gradient dot Step
242 
243  // report the entropy type for a logging message
245  { str = "entropy type U (emptiness)"; }
246  // report the entropy Name
248  { str = "EMPTINESS"; }
249 
250  // infoBanner
251  void infoBanner();
252 
253  // infoIteration
254  void infoPerIteration(casacore::uInt iteration);
255 
256  // relax image Min
258 
259  // each entropy type can have its distinct convergence
260  // criteria
262 
263 protected:
264 
267 
268 };
269 
270 
271 
272 
273 
274 
275 } //# NAMESPACE CASA - END
276 
277 #endif
virtual casacore::Bool testConvergence()=0
each entropy type can have its distinct convergence criteria
virtual void entropyType(casacore::String &)=0
report the entropy type for a logging message
IncEntropyEmptiness & operator=(const IncEntropyEmptiness &)
IncEntropyI & operator=(const IncEntropyI &)
casacore::Float formEntropy()
calculate the entropy for the whole image
void infoBanner()
infoBanner
performs MEM algorithm incrementally
void formGDG(casacore::Matrix< casacore::Double > &)
calculate the Gradient dot Gradient matrix
void infoPerIteration(casacore::uInt iteration)
infoIteration
IncEntropy()
The default constructor is good enough, does nothing.
virtual casacore::Float formEntropy()=0
calculate the entropy for the whole image
casacore::Double formGDS()
calculate Gradient dot Step
~IncEntropyEmptiness()
destructor
IncCEMemModel * cemem_ptr
Definition: IncEntropy.h:158
void formGDG(casacore::Matrix< casacore::Double > &)
calculate the Gradient dot Gradient matrix
A 2-D Specialization of the Array class.
void formGDGStep(casacore::Matrix< double > &)
calculate the Gradient dot Gradient matrix, calculate Step
IncEntropyI()
This default constructor is good enough for me.
casacore::Float relaxMin()
relax image Min
virtual void entropyName(casacore::String &)=0
report the entropy name
casacore::Bool testConvergence()
each entropy type can have its distinct convergence criteria
virtual void infoBanner()=0
infoBanner
virtual void formGDGStep(casacore::Matrix< double > &)=0
calculate the Gradient dot Gradient matrix, calculate Step
virtual casacore::Double formGDS()=0
calculate Gradient dot Step
Emptiness measure for incremental MEM.
Definition: IncEntropy.h:222
void formGDGStep(casacore::Matrix< double > &)
calculate the Gradient dot Gradient matrix, calculate Step
virtual void formGDG(casacore::Matrix< double > &)=0
calculate the Gradient dot Gradient matrix
double Double
Definition: aipstype.h:55
void infoBanner()
infoBanner
virtual void infoPerIteration(casacore::uInt iteration)=0
infoPerIteration
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Thermodynamic or Information entropy for incremental MEM.
Definition: IncEntropy.h:169
void setMemModel(IncCEMemModel &mmm)
set the MemModel
Definition: IncEntropy.h:136
casacore::Bool testConvergence()
each entropy type can have its distinct convergence criteria
float Float
Definition: aipstype.h:54
IncEntropyEmptiness()
This default constructor is good enough for me.
virtual ~IncEntropy()
A virtual destructor may be necessary for use in derived classes.
~IncEntropyI()
destructor
casacore::Float formEntropy()
calculate the entropy for the whole image
virtual casacore::Float relaxMin()=0
are there any constraints on how the Image minimum gets relaxed?
Base class for incremental entropies used by incremental MEM algorithm.
Definition: IncEntropy.h:105
void infoPerIteration(casacore::uInt iteration)
infoIteration
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void entropyName(casacore::String &str)
report the entropy name
Definition: IncEntropy.h:195
casacore::Float relaxMin()
relax image Min
casacore::Double formGDS()
calculate Gradient dot Step
void entropyType(casacore::String &str)
report the entropy type for a logging message
Definition: IncEntropy.h:192
void entropyType(casacore::String &str)
report the entropy type for a logging message
Definition: IncEntropy.h:244
unsigned int uInt
Definition: aipstype.h:51
void entropyName(casacore::String &str)
report the entropy Name
Definition: IncEntropy.h:247