- Main Page
- Modules
- Classes
- Files
- Directories
- Related Pages

# cvarhist.h

    00001 //==========================================================================
    00002 //  CVARHIST.H - part of
    00003 //
    00004 //                     OMNeT++/OMNEST
    00005 //            Discrete System Simulation in C++
    00006 //
    00007 //
    00008 //  Declaration of the following classes:
    00009 //    cVarHistogram : Variable bin size histogram
    00010 //
    00011 //==========================================================================
    00012
    00013 /*--------------------------------------------------------------*
    00014   Copyright (C) 1992-2005 Andras Varga
    00015
    00016   This file is distributed WITHOUT ANY WARRANTY. See the file
    00017   `license' for details on this and other legal matters.
    00018 *--------------------------------------------------------------*/
    00019
    00020 #ifndef __CVARHIST_H
    00021 #define __CVARHIST_H
    00022
    00023 #include "chist.h"
    00024
    00025 //==========================================================================
    00026 //  transform types for cVarHistogram
    00027 //
    00028 // HIST_TR_NO_TRANSFORM: no transformation; uses bin boundaries
    00029 //                       previously defined by addBinBound()/appendBinBound()
    00030 // HIST_TR_AUTO_EPC_DBL: automatically creates equiprobable cells
    00031 // HIST_TR_AUTO_EPC_INT: like the above, but uses a different hack :-)
    00032
    00033 enum {
    00034    HIST_TR_NO_TRANSFORM=1,
    00035    HIST_TR_AUTO_EPC_DBL=0,
    00036    HIST_TR_AUTO_EPC_INT=2
    00037 };
    00038
    00039 //==========================================================================
    00040
    00078 class SIM_API cVarHistogram : public cHistogramBase //--LG
    00079 {
    00080   protected:
    00081     int transform_type;     // one of the HIST_TR_xxx constants
    00082     int max_num_cells;      // the length of the allocated cellv
    00083     double *bin_bounds;     // bin/cell boundaries
    00084
    00085     // the boundaries of the ordinary cells/bins are:
    00086     // rangemin=bin_bounds[0], bin_bounds[1], ... bin_bounds[num_cells]=rangemax
    00087     // consequence: sizeof(binbounds)=sizeof(cellv)+1
    00088
    00089   protected:
    00095     void createEquiProbableCells();
    00096
    00097   public:
    00100
    00104     cVarHistogram(const cVarHistogram& r) : cHistogramBase(r)
    00105        {setName(r.name());bin_bounds=NULL;operator=(r);}
    00106
    00113     explicit cVarHistogram(const char *name=NULL,
    00114                            int numcells=11,
    00115                            int transformtype=HIST_TR_AUTO_EPC_DBL);
    00116
    00120     virtual ~cVarHistogram();
    00121
    00125     cVarHistogram& operator=(const cVarHistogram& res);
    00127
    00130
    00135     virtual cPolymorphic *dup() const    {return new cVarHistogram(*this);}
    00136
    00142     virtual void netPack(cCommBuffer *buffer);
    00143
    00149     virtual void netUnpack(cCommBuffer *buffer);
    00151
    00154
    00158     virtual void clearResult();
    00159
    00164     virtual void transform();
    00165
    00170     virtual void collectTransformed(double val);
    00171
    00175     virtual double random() const;
    00176
    00180     virtual double pdf(double x) const; // --LG
    00181
    00185     virtual double cdf(double x) const; // --LG
    00186
    00190     virtual double basepoint(int k) const; // --LG
    00191
    00195     virtual double cell(int k) const;
    00196
    00200     virtual void saveToFile(FILE *) const; //--LG
    00201
    00205     virtual void loadFromFile(FILE *);  //--LG
    00207
    00210
    00217     virtual void addBinBound(double x);
    00219 };
    00220
    00221 #endif
    00222
    00223