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-2008 Andras Varga
00015   Copyright (C) 2006-2008 OpenSim Ltd.
00016 
00017   This file is distributed WITHOUT ANY WARRANTY. See the file
00018   `license' for details on this and other legal matters.
00019 *--------------------------------------------------------------*/
00020 
00021 #ifndef __CVARHIST_H
00022 #define __CVARHIST_H
00023 
00024 #include "chistogram.h"
00025 
00026 NAMESPACE_BEGIN
00027 
00028 
00032 enum {
00033    HIST_TR_NO_TRANSFORM=1, 
00034    HIST_TR_AUTO_EPC_DBL=0, 
00035    HIST_TR_AUTO_EPC_INT=2  
00036 };
00037 
00075 class SIM_API cVarHistogram : public cHistogramBase
00076 {
00077   protected:
00078     int transform_type;     // one of the HIST_TR_xxx constants
00079     int max_num_cells;      // the length of the allocated cellv
00080     double *bin_bounds;     // bin/cell boundaries
00081 
00082     // the boundaries of the ordinary cells/bins are:
00083     // rangemin=bin_bounds[0], bin_bounds[1], ... bin_bounds[num_cells]=rangemax
00084     // consequence: sizeof(binbounds)=sizeof(cellv)+1
00085 
00086   private:
00087     void copy(const cVarHistogram& other);
00088 
00089   protected:
00095     void createEquiprobableCells();
00096 
00097   public:
00100 
00104     cVarHistogram(const cVarHistogram& r) : cHistogramBase(r) {bin_bounds=NULL;copy(r);}
00105 
00112     explicit cVarHistogram(const char *name=NULL,
00113                            int numcells=11,
00114                            int transformtype=HIST_TR_AUTO_EPC_DBL);
00115 
00119     virtual ~cVarHistogram();
00120 
00124     cVarHistogram& operator=(const cVarHistogram& res);
00126 
00129 
00134     virtual cVarHistogram *dup() const  {return new cVarHistogram(*this);}
00135 
00141     virtual void parsimPack(cCommBuffer *buffer);
00142 
00148     virtual void parsimUnpack(cCommBuffer *buffer);
00150 
00153 
00157     virtual void clearResult();
00158 
00163     virtual void transform();
00164 
00169     virtual void collectTransformed(double val);
00170 
00174     virtual double random() const;
00175 
00179     virtual double getPDF(double x) const;
00180 
00184     virtual double getCDF(double x) const;
00185 
00189     virtual double getBasepoint(int k) const;
00190 
00194     virtual double getCellValue(int k) const;
00195 
00199     virtual void saveToFile(FILE *) const;
00200 
00204     virtual void loadFromFile(FILE *);
00206 
00209 
00216     virtual void addBinBound(double x);
00218 };
00219 
00220 NAMESPACE_END
00221 
00222 
00223 #endif
00224 
00225 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3