OpendTect-6_4  6.4
sampledprobdenfunc.h
Go to the documentation of this file.
1 #ifndef sampledprobdenfunc_h
2 #define sampledprobdenfunc_h
3 
4 /*
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Bert
9  Date: Jan 2010
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 
14 */
15 
16 #include "algomod.h"
17 #include "probdenfunc.h"
18 #include "samplingdata.h"
19 #include "arrayndimpl.h"
20 #include "bufstringset.h"
21 
22 
30 {
31 public:
32 
34  : cumbins_(0) {}
35  ArrayNDProbDenFunc( const ArrayNDProbDenFunc& oth)
36  : cumbins_(0) { *this = oth; }
37  virtual ~ArrayNDProbDenFunc() {}
38  ArrayNDProbDenFunc& operator =(const ArrayNDProbDenFunc&);
39 
40  int size( int dim ) const
41  { return getArrND().info().getSize(dim); }
43  { return getArrND().info().getTotalSz(); }
44 
45  virtual const ArrayND<float>& getData() const
46  { return getArrND(); }
48  { return const_cast<ArrayND<float>&>(getArrND()); }
49  virtual ArrayND<float>* getArrClone() const = 0;
50 
51  virtual SamplingData<float> sampling( int dim ) const
52  { return getSampling(dim); }
53  virtual SamplingData<float>& sampling( int dim )
54  { return const_cast<SamplingData<float>&>(
55  getSampling(dim)); }
56 
57  void fillPar(IOPar&) const;
58  bool usePar(const IOPar&);
59  void writeBulkData(od_ostream&,bool) const;
60  bool readBulkData(od_istream&,bool);
61 
62  float getAveragePos(int dim) const;
63  static float findAveragePos(const float*,int,float grandtotal);
64 
65 protected:
66 
67  virtual const ArrayND<float>& getArrND() const = 0;
68  virtual const SamplingData<float>& getSampling(int) const = 0;
69  virtual float getNormFac() const;
70  virtual void doScale(float);
71  virtual bool gtIsEq(const ProbDenFunc&) const;
72 
73  mutable float* cumbins_;
74 
75  void prepRndDrw() const;
76  void fillCumBins() const;
77  od_uint64 getRandBin() const;
78  od_uint64 getBinPos(float) const;
79 
80 };
81 
82 
83 #define mDefArrayNDProbDenFuncFns(nm) \
84  virtual nm##ProbDenFunc* clone() const \
85  { return new nm##ProbDenFunc(*this); } \
86  static const char* typeStr() { return #nm; } \
87  virtual const char* getTypeStr() const { return typeStr(); } \
88  virtual float normFac() const { return getNormFac();}\
89  virtual bool canScale() const { return true; } \
90  virtual void scale( float f ) { doScale(f); } \
91  virtual void prepareRandDrawing() const { prepRndDrw(); } \
92  virtual bool isEq( const ProbDenFunc& oth ) const \
93  { return gtIsEq(oth); }
94 
95 
101  , public ArrayNDProbDenFunc
102 {
103 public:
104 
108  Sampled1DProbDenFunc(const float*,int);
110  Sampled1DProbDenFunc& operator =(const Sampled1DProbDenFunc&);
111  virtual void copyFrom(const ProbDenFunc&);
113 
114  virtual void fillPar(IOPar&) const;
115  virtual bool usePar(const IOPar&);
116  virtual void writeBulk(od_ostream&,bool binary) const;
117  virtual bool readBulk(od_istream&,bool binary);
118  virtual ArrayND<float>* getArrClone() const
119  { return new Array1DImpl<float>(bins_); }
120 
123 
124 protected:
125 
126  virtual const ArrayND<float>& getArrND() const { return bins_;}
127  virtual const SamplingData<float>& getSampling(int) const { return sd_; }
128 
129  virtual float gtAvgPos() const;
130  virtual float gtVal(float) const;
131  virtual void drwRandPos(float&) const;
132 
133 };
134 
135 
141  , public ArrayNDProbDenFunc
142 {
143 public:
144 
148  Sampled2DProbDenFunc& operator =(const Sampled2DProbDenFunc&);
149  virtual void copyFrom(const ProbDenFunc&);
151 
152  virtual void fillPar(IOPar&) const;
153  virtual bool usePar(const IOPar&);
154  virtual void writeBulk(od_ostream&,bool binary) const;
155  virtual bool readBulk(od_istream&,bool binary);
156  virtual ArrayND<float>* getArrClone() const
157  { return new Array2DImpl<float>(bins_); }
158  virtual float averagePos( int dim ) const
159  { return getAveragePos( dim ); }
160 
164 
165 protected:
166 
167  virtual const ArrayND<float>& getArrND() const { return bins_;}
168  virtual const SamplingData<float>& getSampling( int d ) const
169  { return d ? sd1_ : sd0_; }
170 
171  virtual float gtVal(float,float) const;
172  virtual void drwRandPos(float&,float&) const;
173 
174 };
175 
176 
184  , public ArrayNDProbDenFunc
185 {
186 public:
187 
188  SampledNDProbDenFunc(int nrdims);
191  SampledNDProbDenFunc& operator =(const SampledNDProbDenFunc&);
192  virtual void copyFrom(const ProbDenFunc&);
194 
195  virtual int nrDims() const { return bins_.info().getNDim(); }
196  virtual const char* dimName(int) const;
197  virtual void setDimName( int dim, const char* nm )
198  { *dimnms_[dim] = nm; }
199  virtual float averagePos( int dim ) const
200  { return getAveragePos( dim ); }
201  virtual float value(const TypeSet<float>&) const;
202  virtual void drawRandomPos(TypeSet<float>&) const;
203  virtual ArrayND<float>* getArrClone() const
204  { return new ArrayNDImpl<float>(bins_); }
205 
206  virtual void fillPar(IOPar&) const;
207  virtual bool usePar(const IOPar&);
208  virtual void writeBulk(od_ostream&,bool binary) const;
209  virtual bool readBulk(od_istream&,bool binary);
210 
214 
215 protected:
216 
217  virtual const ArrayND<float>& getArrND() const
218  { return bins_;}
219  virtual const SamplingData<float>& getSampling( int d ) const
220  { return sds_[d]; }
221 
222 public:
223 
225 
226 };
227 
228 
229 #endif
virtual const ArrayND< float > & getData() const
Definition: sampledprobdenfunc.h:45
virtual ArrayND< float > * getArrClone() const
Definition: sampledprobdenfunc.h:203
#define mExpClass(module)
Definition: commondefs.h:160
OD class for stream write common access to the user log file, or std::cout in batch progs...
Definition: od_ostream.h:26
Probability Density Function for one dimensional datasets.
Definition: probdenfunc.h:81
virtual ~ArrayNDProbDenFunc()
Definition: sampledprobdenfunc.h:37
virtual void setDimName(int dim, const char *nm)
Definition: sampledprobdenfunc.h:197
virtual const SamplingData< float > & getSampling(int d) const
Definition: sampledprobdenfunc.h:219
float * cumbins_
Definition: sampledprobdenfunc.h:73
#define mDefArrayNDProbDenFuncFns(nm)
Definition: sampledprobdenfunc.h:83
Base class for Probability Density Functions.
Definition: probdenfunc.h:31
void usePar(const IOPar &iop, ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:188
SamplingData< float > sd1_
Definition: sampledprobdenfunc.h:162
virtual SamplingData< float > & sampling(int dim)
Definition: sampledprobdenfunc.h:53
virtual const SamplingData< float > & getSampling(int) const
Definition: sampledprobdenfunc.h:127
Set of BufferString objects.
Definition: bufstringset.h:28
Array1DImpl< float > bins_
Definition: sampledprobdenfunc.h:122
virtual const ArrayND< float > & getArrND() const
Definition: sampledprobdenfunc.h:217
OD class for stream read.
Definition: od_istream.h:24
Two dimensional PDF based on binned data.
Definition: sampledprobdenfunc.h:140
SamplingData< float > sd_
Definition: sampledprobdenfunc.h:121
virtual const ArrayND< float > & getArrND() const
Definition: sampledprobdenfunc.h:167
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
ArrayNDImpl< float > bins_
Definition: sampledprobdenfunc.h:212
Multi-dimensional PDF based on binned data.
Definition: sampledprobdenfunc.h:183
SamplingData< float > sd0_
Definition: sampledprobdenfunc.h:161
od_uint64 totalSize() const
Definition: sampledprobdenfunc.h:42
virtual float averagePos(int dim) const
Definition: sampledprobdenfunc.h:158
One dimensional PDF based on binned data.
Definition: sampledprobdenfunc.h:100
void fillPar(IOPar &iop, const ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:175
Probability Density Function for two dimensional datasets.
Definition: probdenfunc.h:126
int size(int dim) const
Definition: sampledprobdenfunc.h:40
#define od_uint64
Definition: plftypes.h:37
virtual SamplingData< float > sampling(int dim) const
Definition: sampledprobdenfunc.h:51
BufferStringSet dimnms_
Definition: sampledprobdenfunc.h:213
ArrayNDProbDenFunc(const ArrayNDProbDenFunc &oth)
Definition: sampledprobdenfunc.h:35
TypeSet< SamplingData< float > > sds_
Definition: sampledprobdenfunc.h:211
virtual const SamplingData< float > & getSampling(int d) const
Definition: sampledprobdenfunc.h:168
virtual float averagePos(int dim) const
Definition: sampledprobdenfunc.h:199
Array2DImpl< float > bins_
Definition: sampledprobdenfunc.h:163
ArrayNDProbDenFunc()
Definition: sampledprobdenfunc.h:33
virtual const ArrayND< float > & getArrND() const
Definition: sampledprobdenfunc.h:126
virtual ArrayND< float > & getData()
Definition: sampledprobdenfunc.h:47
PDF based on ArrayND implementation.
Definition: sampledprobdenfunc.h:29

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019