1 | #include "pexceptions.h"
|
---|
2 |
|
---|
3 | #ifndef SLINPARBUF_H_SEEN
|
---|
4 | #define SLINPARBUF_H_SEEN
|
---|
5 |
|
---|
6 | namespace SOPHYA {
|
---|
7 |
|
---|
8 | //////////////////////////////////////////////////////////////////////////////////
|
---|
9 | class SLinParBuff {
|
---|
10 | public:
|
---|
11 | friend class SLinParBuffMerger;
|
---|
12 |
|
---|
13 | SLinParBuff(uint_4 lenbuf,uint_4 nresynch=0,r_8 x0=0.,r_8 y0=0.,bool autoxy0=false);
|
---|
14 | SLinParBuff(SLinParBuff& slp);
|
---|
15 | SLinParBuff(void);
|
---|
16 | virtual ~SLinParBuff();
|
---|
17 |
|
---|
18 | void GetX0Y0(r_8& x0,r_8& y0);
|
---|
19 | bool GetAutoX0Y0();
|
---|
20 | void SetX0Y0(r_8 x0=0.,r_8 y0=0.);
|
---|
21 | void SetAutoX0Y0(bool autoxy0=false);
|
---|
22 |
|
---|
23 | void Reset(void);
|
---|
24 | uint_4 Pop(void);
|
---|
25 | uint_4 Push(r_8 x,r_8 y);
|
---|
26 | inline uint_4 NPoints(void) {return mNCur;}
|
---|
27 |
|
---|
28 | r_8 SumX(void) {return mSx+mNCur*mX0;}
|
---|
29 | r_8 SumY(void) {return mSy+mNCur*mY0;}
|
---|
30 |
|
---|
31 | uint_4 ReComputeSum(void);
|
---|
32 | r_8 Compute(r_8& mean,bool recomputeXi2=false);
|
---|
33 | r_8 Compute(r_8& a0,r_8 &a1,bool recomputeXi2=false);
|
---|
34 | r_8 Compute(r_8& a0,r_8 &a1,r_8 &a2,bool recomputeXi2=false);
|
---|
35 |
|
---|
36 | void Print(int lp=0);
|
---|
37 | void PrintCompute(int lp=0);
|
---|
38 |
|
---|
39 | protected:
|
---|
40 | uint_4 mLenBuf,mNResynch;
|
---|
41 | r_8 *mX,*mY, mX0, mY0;
|
---|
42 | bool mAutoXY0;
|
---|
43 | uint_4 mNCur,mIDeb,mIResynch;
|
---|
44 | r_8 mSx,mSy,mSx2,mSy2,mSxy, mSx3,mSx2y, mSx4;
|
---|
45 | uint_4 mNResynchEff, mNPush, mNPop;
|
---|
46 | };
|
---|
47 |
|
---|
48 |
|
---|
49 | ///////////////////////////////////////////////////////////////////
|
---|
50 | // That Class allows merging of SLinParBuff Class for computing //
|
---|
51 | // parameters.
|
---|
52 | // ex:
|
---|
53 | // SLinParBuff s1; -> Fill s1
|
---|
54 | // SLinParBuff s2; -> Fill s2
|
---|
55 | // SLinParBuff s3; -> Fill s3
|
---|
56 | // SLinParBuffMerger smerge(s1);
|
---|
57 | // sig = smerge.Compute(mean); -> same as sig = s1.Compute(mean);
|
---|
58 | // smerge.Add(s2);
|
---|
59 | // sig = smerge.Compute(mean); -> sig and mean are those for
|
---|
60 | class SLinParBuffMerger {
|
---|
61 | public:
|
---|
62 | SLinParBuffMerger(void);
|
---|
63 | SLinParBuffMerger(SLinParBuff& s,bool recompute=false);
|
---|
64 | virtual ~SLinParBuffMerger(void);
|
---|
65 |
|
---|
66 | inline uint_4 NPoints(void) {return mSlp.NPoints();}
|
---|
67 | inline void Reset(void) {mSlp.Reset(); mFirst=true;}
|
---|
68 | void Add(SLinParBuff& s,bool recompute=false);
|
---|
69 | inline r_8 Compute(r_8& mean) {return mSlp.Compute(mean);}
|
---|
70 | inline r_8 Compute(r_8& a0,r_8 &a1) {return mSlp.Compute(a0,a1);}
|
---|
71 | inline r_8 Compute(r_8& a0,r_8 &a1,r_8 &a2) {return mSlp.Compute(a0,a1,a2);}
|
---|
72 | inline void Print(int lp=0) {mSlp.Print(lp);}
|
---|
73 | inline void PrintCompute(int lp=0) {mSlp.PrintCompute(lp);}
|
---|
74 |
|
---|
75 | protected:
|
---|
76 | bool mFirst;
|
---|
77 | SLinParBuff mSlp;
|
---|
78 | };
|
---|
79 |
|
---|
80 | } // Fin du namespace
|
---|
81 |
|
---|
82 | #endif
|
---|