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