[658] | 1 | #ifndef CSPLINE_H_SEEN
|
---|
| 2 | #define CSPLINE_H_SEEN
|
---|
| 3 |
|
---|
| 4 | #include "machdefs.h"
|
---|
| 5 | #include "pexceptions.h"
|
---|
| 6 |
|
---|
| 7 | ///////////////////////////////////////////////////////////////////
|
---|
| 8 | // Class CSpline et CSpline2 selon Numerical Receipes (cmv 17/02/97)
|
---|
| 9 | ///////////////////////////////////////////////////////////////////
|
---|
| 10 | class CSpline EXC_AWARE {
|
---|
| 11 |
|
---|
| 12 | public:
|
---|
| 13 |
|
---|
| 14 | friend class CSpline2;
|
---|
| 15 |
|
---|
| 16 | enum { NaturalAll = 3, NoNatural = 0, Natural1 = 1, NaturalN = 2 };
|
---|
| 17 |
|
---|
| 18 | CSpline(int n,double* x,double* y,double yp1=0.,double ypn=0.
|
---|
| 19 | ,int natural=NaturalAll,bool order=true);
|
---|
| 20 |
|
---|
| 21 | CSpline(double yp1=0.,double ypn=0.,int natural=NaturalAll);
|
---|
| 22 |
|
---|
| 23 | virtual ~CSpline();
|
---|
| 24 |
|
---|
| 25 | void SetNewTab(int n,double* x,double* y
|
---|
| 26 | ,bool order=true,bool force=false);
|
---|
| 27 |
|
---|
| 28 | void SetBound1er(double yp1 = 0.,double yp2 = 0.);
|
---|
| 29 |
|
---|
| 30 | inline void SetNaturalCSpline(int type = NaturalAll)
|
---|
| 31 | { Natural = type;}
|
---|
| 32 |
|
---|
| 33 | inline void Free_Tmp()
|
---|
| 34 | { if(tmp != NULL) delete [] tmp; tmp=NULL;}
|
---|
| 35 |
|
---|
| 36 | void ComputeCSpline();
|
---|
| 37 |
|
---|
| 38 | double CSplineInt(double x);
|
---|
| 39 |
|
---|
| 40 | protected:
|
---|
| 41 |
|
---|
| 42 | void DelTab();
|
---|
| 43 |
|
---|
| 44 | // nombre d elements dans les tableaux X et Y
|
---|
| 45 | int Nel;
|
---|
| 46 | // true si les tableaux ont ete changes
|
---|
| 47 | // et qu il faut recalculer ComputeCSpline()
|
---|
| 48 | bool corrupt_Y2;
|
---|
| 49 | // true si les tableaux X,Y ont ete alloues
|
---|
| 50 | bool XY_Created;
|
---|
| 51 | // type de contraintes sur la derivee 2sd
|
---|
| 52 | int Natural;
|
---|
| 53 | // valeurs imposees de la derivee 1ere aux limites
|
---|
| 54 | double YP1, YPn;
|
---|
| 55 |
|
---|
| 56 | // tableaux rellement alloues si "order=true" ou seulement
|
---|
| 57 | // connectes aux tableaux externes si "order=false"
|
---|
| 58 | double* X;
|
---|
| 59 | double* Y;
|
---|
| 60 |
|
---|
| 61 | // tableau des coeff permettant l interpolation,
|
---|
| 62 | // remplis par ComputeCSpline()
|
---|
| 63 | double* Y2;
|
---|
| 64 |
|
---|
| 65 | // tableau tampon utilise dans ComputeCSpline()
|
---|
| 66 | double* tmp;
|
---|
| 67 | int_4* ind;
|
---|
| 68 |
|
---|
| 69 | };
|
---|
| 70 |
|
---|
| 71 |
|
---|
| 72 | ///////////////////////////////////////////////////////////////////
|
---|
| 73 | class CSpline2 EXC_AWARE {
|
---|
| 74 |
|
---|
| 75 | public:
|
---|
| 76 | CSpline2(int n1,double* x1,int n2,double* x2,double* y
|
---|
| 77 | ,int natural=CSpline::NaturalAll,bool order=true);
|
---|
| 78 |
|
---|
| 79 | CSpline2(int natural=CSpline::NaturalAll);
|
---|
| 80 |
|
---|
| 81 | virtual ~CSpline2();
|
---|
| 82 |
|
---|
| 83 | void SetNewTab(int n1,double* x1,int n2,double* x2,double* y
|
---|
| 84 | ,bool order=true,bool force=false);
|
---|
| 85 |
|
---|
| 86 | inline void SetNaturalCSpline(int type = CSpline::NaturalAll)
|
---|
| 87 | { Natural = type;}
|
---|
| 88 |
|
---|
| 89 | void ComputeCSpline();
|
---|
| 90 |
|
---|
| 91 | double CSplineInt(double x1,double x2);
|
---|
| 92 |
|
---|
| 93 | protected:
|
---|
| 94 | void DelTab();
|
---|
| 95 |
|
---|
| 96 | int Nel1, Nel2;
|
---|
| 97 | bool corrupt_Y2;
|
---|
| 98 | bool XY_Created;
|
---|
| 99 | int Natural;
|
---|
| 100 |
|
---|
| 101 | double* X1;
|
---|
| 102 | double* X2;
|
---|
| 103 | double* Y;
|
---|
| 104 | double* Y2;
|
---|
| 105 |
|
---|
| 106 | // nombre d elements alloues dans S
|
---|
| 107 | int Nel_S;
|
---|
| 108 | // tableau de CSpline pour interpolation selon X1
|
---|
| 109 | CSpline** S; // S[0->n2]
|
---|
| 110 | CSpline* Sint;
|
---|
| 111 |
|
---|
| 112 | // tableau tampon utilise dans CSplineInt()
|
---|
| 113 | double* tmp; // tmp[max(n1,n2)]
|
---|
| 114 | int_4* ind;
|
---|
| 115 |
|
---|
| 116 | };
|
---|
| 117 |
|
---|
| 118 | #endif /* CSPLINE_H_SEEN */
|
---|