BLI2D.h
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \class genie::BLI2DUnifGrid
5 
6 \brief Bilinear interpolation of 2D functions on a regular grid.
7 
8 \author Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
9  University of Liverpool & STFC Rutherford Appleton Lab
10 
11 \created May 30, 2009
12 
13 \cpright Copyright (c) 2003-2019, The GENIE Collaboration
14  For the full text of the license visit http://copyright.genie-mc.org
15  or see $GENIE/LICENSE
16 */
17 //____________________________________________________________________________
18 
19 #ifndef _BILLINEAR_INTERPOLATION_2D_GRID_H_
20 #define _BILLINEAR_INTERPOLATION_2D_GRID_H_
21 
22 #include <TObject.h>
23 
24 namespace genie {
25 
26 class BLI2DGrid : public TObject {
27 
28 public:
29  //-- ctors & dtor
30  BLI2DGrid();
31  //BLI2DGrid(int nx, double xmin, double xmax, int ny, double ymin, double ymax);
32  //BLI2DGrid(int nx, int ny, double *x, double *y, double **z);
33  virtual ~BLI2DGrid();
34 
35  //-- add another point in the grid
36  virtual bool AddPoint(double x, double y, double z) =0;
37 
38  //-- evaluate the function at the input position
39  virtual double Evaluate (double x, double y) const =0;
40 
41  // report min/max values
42  double XMin (void) const { return fXmin; }
43  double XMax (void) const { return fXmax; }
44  double YMin (void) const { return fYmin; }
45  double YMax (void) const { return fYmax; }
46  double ZMin (void) const { return fZmin; }
47  double ZMax (void) const { return fZmax; }
48 
49 protected:
50 
51  virtual void Init (int nx, double xmin, double xmax, int ny, double ymin, double ymax) =0;
52  int IdxZ (int ix, int iy) const;
53 
54  //-- private data members
55  int fNX;
56  int fNY;
57  int fNZ;
58  double * fX; //[fNX]
59  double * fY; //[fNY]
60  double * fZ; //[fNZ]
61  double fDX;
62  double fDY;
63  double fXmin;
64  double fXmax;
65  double fYmin;
66  double fYmax;
67  double fZmin;
68  double fZmax;
69 
70  ClassDef(BLI2DGrid, 1)
71  };
72 
73 //____________________________________________________________________________
74 //____________________________________________________________________________
75 
76 class BLI2DUnifGrid : public BLI2DGrid {
77 
78 public:
79  //-- ctors & dtor
80  BLI2DUnifGrid();
81  BLI2DUnifGrid(int nx, double xmin, double xmax, int ny, double ymin, double ymax);
82  BLI2DUnifGrid(int nx, int ny, double *x, double *y, double *z);
83 
84  //-- add another point in the grid
85  bool AddPoint(double x, double y, double z);
86 
87  //-- evaluate the function at the input position
88  double Evaluate (double x, double y) const;
89 
90 private:
91 
92  void Init (int nx=0, double xmin=0, double xmax=0, int ny=0, double ymin=0, double ymax=0);
93 
94  ClassDef(BLI2DUnifGrid, 1)
95  };
96 
97 //____________________________________________________________________________
98 //____________________________________________________________________________
99 
100 class BLI2DNonUnifGrid : public BLI2DGrid {
101 
102 public:
103  //-- ctors & dtor
105  BLI2DNonUnifGrid(int nx, double xmin, double xmax, int ny, double ymin, double ymax);
106  BLI2DNonUnifGrid(int nx, int ny, double *x, double *y, double *z);
107 
108  //-- add another point in the grid
109  bool AddPoint(double x, double y, double z);
110 
111  //-- evaluate the function at the input position
112  double Evaluate (double x, double y) const;
113 
114 private:
115 
116  void Init (int nx=0, double xmin=0, double xmax=0, int ny=0, double ymin=0, double ymax=0);
117  int fNFillX;
118  int fNFillY;
119 
120  ClassDef(BLI2DNonUnifGrid, 1)
121  };
122 
123 }
124 #endif
double fXmin
Definition: BLI2D.h:63
double fYmax
Definition: BLI2D.h:66
double * fY
Definition: BLI2D.h:59
Bilinear interpolation of 2D functions on a regular grid.
Definition: BLI2D.h:76
double fZmax
Definition: BLI2D.h:68
std::map< std::string, double > xmax
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
double * fX
Definition: BLI2D.h:58
double fDX
Definition: BLI2D.h:61
double ZMin(void) const
Definition: BLI2D.h:46
Double_t ymax
Definition: plot.C:25
double fDY
Definition: BLI2D.h:62
double YMin(void) const
Definition: BLI2D.h:44
double XMax(void) const
Definition: BLI2D.h:43
virtual void Init(int nx, double xmin, double xmax, int ny, double ymin, double ymax)=0
virtual bool AddPoint(double x, double y, double z)=0
virtual double Evaluate(double x, double y) const =0
double ZMax(void) const
Definition: BLI2D.h:47
z
Definition: test.py:28
int IdxZ(int ix, int iy) const
Definition: BLI2D.cxx:49
double YMax(void) const
Definition: BLI2D.h:45
double fYmin
Definition: BLI2D.h:65
virtual ~BLI2DGrid()
Definition: BLI2D.cxx:42
Double_t ymin
Definition: plot.C:24
double fXmax
Definition: BLI2D.h:64
double XMin(void) const
Definition: BLI2D.h:42
double fZmin
Definition: BLI2D.h:67
double * fZ
Definition: BLI2D.h:60