OMNeT++ Simulation Library  5.4.1
cpsquare.h
1 //==========================================================================
2 // CPSQUARE.H - part of
3 // OMNeT++/OMNEST
4 // Discrete System Simulation in C++
5 //
6 //==========================================================================
7 
8 /*--------------------------------------------------------------*
9  Copyright (C) 1992-2017 Andras Varga
10  Copyright (C) 2006-2017 OpenSim Ltd.
11 
12  This file is distributed WITHOUT ANY WARRANTY. See the file
13  `license' for details on this and other legal matters.
14 *--------------------------------------------------------------*/
15 
16 // Author: Babak Fakhamzadeh, TU Delft, Dec 1996
17 
18 #ifndef __OMNETPP_CPSQUARE_H
19 #define __OMNETPP_CPSQUARE_H
20 
21 #include "cabstracthistogram.h"
22 
23 namespace omnetpp {
24 
25 
35 class SIM_API cPSquare : public cAbstractHistogram
36 {
37  protected:
38  int numBins; // number of bins
39  long numObs; // number of observations
40  int *n; // array of positions
41  double *q; // array of heights
42 
43  protected:
44  void copy(const cPSquare& other);
45  void ensureStrictlyIncreasingEdges();
46 
47  public:
50 
54  cPSquare(const cPSquare& r);
55 
59  explicit cPSquare(const char *name=nullptr, int bins=10);
60 
64  virtual ~cPSquare();
65 
69  cPSquare& operator=(const cPSquare& res);
71 
74 
79  virtual cPSquare *dup() const override {return new cPSquare(*this);}
80 
86  virtual void parsimPack(cCommBuffer *buffer) const override;
87 
93  virtual void parsimUnpack(cCommBuffer *buffer) override;
95 
96  public:
103  virtual bool binsAlreadySetUp() const override {return true;}
104 
109  virtual void setUpBins() override {}
110 
114  virtual void collect(double value) override;
115  using cStatistic::collect;
116 
121  virtual void collectWeighted(double value, double weight) override;
123 
127  virtual int getNumBins() const override;
128 
134  virtual double getBinEdge(int k) const override;
135 
139  virtual double getBinValue(int k) const override;
140 
145  virtual int64_t getNumUnderflows() const override {return 0;}
146 
151  virtual int64_t getNumOverflows() const override {return 0;}
152 
157  virtual double getUnderflowSumWeights() const override {return 0;}
158 
163  virtual double getOverflowSumWeights() const override {return 0;}
164 
168  virtual double draw() const override;
169 
173  virtual void merge(const cStatistic *other) override;
174 
178  virtual void saveToFile(FILE *) const override;
179 
183  virtual void loadFromFile(FILE *) override;
185 };
186 
187 } // namespace omnetpp
188 
189 
190 #endif
191 
virtual int64_t getNumOverflows() const override
Definition: cpsquare.h:151
virtual double getOverflowSumWeights() const override
Definition: cpsquare.h:163
virtual void collect(double value)=0
Interface and base class for histogram-like density estimation classes.
Definition: cabstracthistogram.h:26
virtual double getUnderflowSumWeights() const override
Definition: cpsquare.h:157
virtual void collectWeighted(double value, double weight)
Buffer for the communications layer of parallel simulation.
Definition: ccommbuffer.h:41
Implements the P2 algorithm, which calculates quantile values without storing the observations...
Definition: cpsquare.h:35
virtual void setUpBins() override
Definition: cpsquare.h:109
Definition: cabstracthistogram.h:21
virtual int64_t getNumUnderflows() const override
Definition: cpsquare.h:145
virtual bool binsAlreadySetUp() const override
Definition: cpsquare.h:103
virtual cPSquare * dup() const override
Definition: cpsquare.h:79
cStatistic is an abstract class for computing statistical properties of a random variable.
Definition: cstatistic.h:34