# cpsquare.h

    00001 //==========================================================================
    00002 //  CPSQUARE.H - part of
    00003 //                     OMNeT++/OMNEST
    00004 //            Discrete System Simulation in C++
    00005 //
    00006 //
    00007 //  Declaration of the following classes:
    00008 //    cPSquare : calculates quantile values without storing the observations
    00009 //
    00010 //   Written by Babak Fakhamzadeh, TU Delft, Dec 1996
    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 __CPSQUARE_H
    00021 #define __CPSQUARE_H
    00022
    00023 #include "cdensity.h"
    00024
    00025 //==========================================================================
    00026
    00033 class SIM_API cPSquare : public cDensityEstBase
    00034 {
    00035   protected:
    00036     int numcells;      // number of observations
    00037     long numobs;       // number of cells,
    00038     int *n;            // array of positions
    00039     double *q;         // array of heights
    00040
    00041   public:
    00044
    00048     cPSquare(const cPSquare& r);
    00049
    00053     explicit cPSquare(const char *name=NULL, int cells=10);
    00054
    00058     virtual ~cPSquare();
    00059
    00063     cPSquare& operator=(const cPSquare& res);
    00065
    00068
    00073     virtual cPolymorphic *dup() const   {return new cPSquare(*this);}
    00074
    00080     virtual void netPack(cCommBuffer *buffer);
    00081
    00087     virtual void netUnpack(cCommBuffer *buffer);
    00088
    00093     virtual void writeContents(std::ostream& os);
    00095
    00096   private:
    00097     // internal: issues error message
    00098     void giveError();
    00099
    00100   protected:
    00105     virtual void collectTransformed(double val);
    00106
    00107   public:
    00110
    00114     virtual void transform() {}
    00115
    00120     virtual void setRange(double,double) {giveError();}
    00121
    00126     virtual void setRangeAuto(int,double) {giveError();}
    00127
    00132     virtual void setRangeAutoLower(double,int,double) {giveError();}
    00133
    00138     virtual void setRangeAutoUpper(double,int,double) {giveError();}
    00139
    00144     virtual void setNumFirstVals(int) {giveError();}
    00145
    00149     virtual int cells() const;
    00150
    00156     virtual double basepoint(int k) const;
    00157
    00161     virtual double cell(int k) const;
    00162
    00166     virtual double cdf(double x) const;
    00167
    00171     virtual double pdf(double x) const;
    00172
    00176     virtual double random() const;
    00177
    00181     virtual void saveToFile(FILE *) const;
    00182
    00186     virtual void loadFromFile(FILE *);
    00188 };
    00189
    00190 #endif
    00191