Changeset 3157 in Sophya for trunk/Cosmo/SimLSS/geneutils.h
- Timestamp:
- Jan 25, 2007, 6:04:48 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/geneutils.h
r3120 r3157 7 7 #include "histos.h" 8 8 #include "tvector.h" 9 #include "cspline.h" 9 10 10 11 #include <vector> … … 12 13 namespace SOPHYA { 13 14 15 //---------------------------------------------------- 14 16 class InterpFunc { 15 17 public: … … 19 21 double XMin(void) {return _xmin;} 20 22 double XMax(void) {return _xmax;} 23 inline double X(long i) {return _xmin + i*_dx;} 21 24 22 25 //! Retourne l'element le plus proche de f donnant y=f(x) … … 24 27 { 25 28 x -= _xmin; 26 long i = long(x/_ xlarg*_nm1+0.5); // On prend le "i" le plus proche29 long i = long(x/_dx+0.5); // On prend le "i" le plus proche 27 30 if(i<0) i=0; else if(i>=_nm1) i=_nm1-1; 28 31 return _y[i]; … … 43 46 44 47 protected: 45 double _xmin,_xmax,_xlarg,_dx; 48 double _xmin,_xmax,_dx; 49 long _nm1; // n-1 46 50 vector<double>& _y; 47 long _nm1; // n-1 51 }; 52 53 //---------------------------------------------------- 54 class InverseFunc { 55 public: 56 InverseFunc(vector<double>& x,vector<double>& y); 57 virtual ~InverseFunc(void); 58 int ComputeLinear(long n,vector<double>& xfcty); 59 int ComputeParab(long n,vector<double>& xfcty); 60 double YMin(void) {return _ymin;} 61 double YMax(void) {return _ymax;} 62 protected: 63 inline void find_in_y(double x,long& klo,long& khi) 64 { 65 long k; 66 klo=0, khi=_y.size()-1; 67 while (khi-klo > 1) { 68 k = (khi+klo) >> 1; 69 if (_y[k] > x) khi=k; else klo=k; 70 } 71 } 72 73 vector<double>& _x; 74 vector<double>& _y; 75 double _ymin,_ymax,_dy; 48 76 }; 49 77 50 78 } 51 79 80 //---------------------------------------------------- 52 81 int FuncToHisto(GenericFunc& func,Histo& h,bool logaxex=false); 53 82 int FuncToVec(GenericFunc& func,TVector<r_8>& h,double xmin,double xmax,bool logaxex=false); 54 83 84 //---------------------------------------------------- 55 85 double AngSol(double dtheta,double dphi,double theta0=M_PI/2.); 56 86 double AngSol(double dtheta); 57 87 88 //---------------------------------------------------- 58 89 unsigned long PoissRandLimit(double mu,double mumax=10.); 59 90
Note:
See TracChangeset
for help on using the changeset viewer.