Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

chist.h

00001 //==========================================================================
00002 //
00003 //   CHIST.H - header for
00004 //                             OMNeT++
00005 //            Discrete System Simulation in C++
00006 //
00007 //
00008 //  Declaration of the following classes:
00009 //    cHistogramBase        : common base class for histogram classes
00010 //      cEqdHistogramBase   : Equi-distant histograms
00011 //        cLongHistogram    : long int distribution
00012 //        cDoubleHistogram  : double distribution
00013 //
00014 //==========================================================================
00015 
00016 #ifndef __CHIST_H
00017 #define __CHIST_H
00018 
00019 #include <iostream.h>
00020 #include "cdensity.h"
00021 
00022 //==========================================================================
00023 
00030 class SIM_API cHistogramBase : public cDensityEstBase
00031 {
00032   protected:
00033     int num_cells;        // nr. of categories
00034     unsigned *cellv;      // array of counters
00035 
00036   public:
00039 
00043     cHistogramBase(const cHistogramBase& r) : cDensityEstBase(r)
00044         {setName(r.name());cellv=NULL;operator=(r);}
00045 
00049     cHistogramBase(const char *name, int numcells);
00050 
00054     virtual ~cHistogramBase();
00055 
00059     cHistogramBase& operator=(const cHistogramBase& res);
00061 
00064 
00068     virtual const char *className() const {return "cHistogramBase";}
00069 
00070     /* No dup() because this is an abstract class. */
00071 
00077     virtual int netPack();
00078 
00084     virtual int netUnpack();
00086 
00089 
00093     virtual void clearResult();
00094 
00099     virtual void transform();
00100 
00104     virtual int cells() const;
00105 
00109     virtual void saveToFile(FILE *) const; //--LG
00110 
00114     virtual void loadFromFile(FILE *);  //--LG
00116 };
00117 
00118 //==========================================================================
00119 
00125 class SIM_API cEqdHistogramBase : public cHistogramBase //--LG
00126 {
00127   protected:
00128     double cellsize;            // cell/category  sizes
00129 
00130   public:
00133 
00137     cEqdHistogramBase(const cEqdHistogramBase& r) : cHistogramBase(r)
00138         {setName(r.name());operator=(r);}
00139 
00143     explicit cEqdHistogramBase(const char *name=NULL, int numcells=10);
00144 
00148     cEqdHistogramBase& operator=(const cEqdHistogramBase& res);
00150 
00153 
00157     virtual const char *className() const {return "cEqdHistogramBase";}
00158 
00159     /* No dup() because this is an abstract class. */
00160 
00166     virtual int netPack();
00167 
00173     virtual int netUnpack();
00175 
00176   protected:
00181     virtual void collectTransformed(double val);
00182 
00187     virtual void setupRange();
00188 
00189   public:
00192 
00196     virtual double basepoint(int k) const;
00197 
00201     virtual double cell(int k) const;
00202 
00206     virtual double pdf(double x) const; // --LG
00207 
00211     virtual double cdf(double x) const; // --LG
00212 
00216     virtual void saveToFile(FILE *) const; //--LG
00217 
00221     virtual void loadFromFile(FILE *);  //--LG
00223 };
00224 
00225 //==========================================================================
00226 
00246 class SIM_API cLongHistogram : public cEqdHistogramBase
00247 {
00248   public:
00251 
00255     cLongHistogram(const cLongHistogram& r) : cEqdHistogramBase(r)
00256         {setName(r.name());operator=(r);}
00257 
00261     explicit cLongHistogram(const char *name=NULL, int numcells=10);
00262 
00266     virtual ~cLongHistogram();
00267 
00271     cLongHistogram& operator=(const cLongHistogram&)  {copyNotSupported();return *this;}
00273 
00276 
00280     virtual const char *className() const {return "cLongHistogram";}
00281 
00286     virtual cObject *dup() const    {return new cLongHistogram(*this);}
00287 
00293     virtual int netPack();
00294 
00300     virtual int netUnpack();
00302 
00303   protected:
00308     virtual void setupRange();
00309 
00310   public:
00313 
00317     virtual void collect(double val);
00318 
00325     virtual double random() const;
00327 };
00328 
00329 //==========================================================================
00330 
00337 class SIM_API cDoubleHistogram : public cEqdHistogramBase
00338 {
00339   public:
00342 
00346     cDoubleHistogram(const cDoubleHistogram& r) : cEqdHistogramBase(r)
00347           {setName(r.name());operator=(r);}
00348 
00352     explicit cDoubleHistogram(const char *name=NULL, int numcells=10);
00353 
00357     virtual ~cDoubleHistogram();
00358 
00362     cDoubleHistogram& operator=(const cDoubleHistogram&)  {copyNotSupported();return *this;}
00364 
00367 
00371     virtual const char *className() const  {return "cDoubleHistogram";}
00372 
00377     virtual cObject *dup() const  {return new cDoubleHistogram(*this);}
00378 
00384     virtual int netPack();
00385 
00391     virtual int netUnpack();
00393 
00396 
00403     virtual double random() const;
00405 };
00406 
00407 #endif
00408 

Generated at Sat May 4 15:45:48 2002 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001