LCOV - code coverage report
Current view: top level - synthesis/MeasurementEquations - Entropy.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 1 5 20.0 %
Date: 2024-11-06 17:42:47 Functions: 1 3 33.3 %

          Line data    Source code
       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: 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_ENTROPY_H
      29             : #define SYNTHESIS_ENTROPY_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 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           4 :   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             :   
     154             :   CEMemModel *cemem_ptr;
     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
     179             :   casacore::Float formEntropy();
     180             :   
     181             :   // calculate the Gradient dot Gradient matrix
     182             :   void formGDG(casacore::Matrix<casacore::Double>& );
     183             :   
     184             :   // calculate the Gradient dot Gradient matrix, calculate Step
     185             :   void formGDGStep(casacore::Matrix<double> & );
     186             :   
     187             :   // calculate Gradient dot Step
     188             :   casacore::Double formGDS();
     189             :   
     190             :   // report the entropy type for a logging message
     191           0 :   void entropyType(casacore::String & str) 
     192           0 :     { 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
     201             :   casacore::Float relaxMin();
     202             : 
     203             :   // each entropy type can have its distinct convergence
     204             :   // criteria
     205             :   casacore::Bool testConvergence();
     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.
     225             :   EntropyEmptiness();
     226             :   
     227             :   // destructor
     228             :   ~EntropyEmptiness();
     229             : 
     230             :   // calculate the entropy for the whole image
     231             :   casacore::Float formEntropy();
     232             :   
     233             :   // calculate the Gradient dot Gradient matrix
     234             :   void formGDG(casacore::Matrix<casacore::Double>& );
     235             :   
     236             :   // calculate the Gradient dot Gradient matrix, calculate Step
     237             :   void formGDGStep(casacore::Matrix<double> & );
     238             :   
     239             :   // calculate Gradient dot Step
     240             :   casacore::Double formGDS();
     241             :   
     242             :   // report the entropy type for a logging message
     243           0 :   void entropyType(casacore::String & str) 
     244           0 :     { 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
     253             :   casacore::Float relaxMin();
     254             : 
     255             :   // each entropy type can have its distinct convergence
     256             :   // criteria
     257             :   casacore::Bool testConvergence();
     258             : 
     259             : 
     260             : protected:
     261             :   
     262             :   EntropyEmptiness(const EntropyEmptiness& );
     263             :   EntropyEmptiness& operator=(const EntropyEmptiness& );
     264             : 
     265             : };
     266             : 
     267             : 
     268             : 
     269             : 
     270             : 
     271             : 
     272             : } //# NAMESPACE CASA - END
     273             : 
     274             : #endif

Generated by: LCOV version 1.16