GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 <c.andreopoulos \at cern.ch>
9  University of Liverpool
10 
11 \created May 30, 2009
12 
13 \cpright Copyright (c) 2003-2024, The GENIE Collaboration
14  For the full text of the license visit http://copyright.genie-mc.org
15 */
16 //____________________________________________________________________________
17 
18 #ifndef _BILLINEAR_INTERPOLATION_2D_GRID_H_
19 #define _BILLINEAR_INTERPOLATION_2D_GRID_H_
20 
21 #include <TObject.h>
22 
23 namespace genie {
24 
25 class BLI2DGrid : public TObject {
26 
27 public:
28  //-- ctors & dtor
29  BLI2DGrid();
30  //BLI2DGrid(int nx, double xmin, double xmax, int ny, double ymin, double ymax);
31  //BLI2DGrid(int nx, int ny, double *x, double *y, double **z);
32  virtual ~BLI2DGrid();
33 
34  //-- add another point in the grid
35  virtual bool AddPoint(double x, double y, double z) =0;
36 
37  //-- evaluate the function at the input position
38  virtual double Evaluate (double x, double y) const =0;
39 
40  // report min/max values
41  double XMin (void) const { return fXmin; }
42  double XMax (void) const { return fXmax; }
43  double YMin (void) const { return fYmin; }
44  double YMax (void) const { return fYmax; }
45  double ZMin (void) const { return fZmin; }
46  double ZMax (void) const { return fZmax; }
47 
48 protected:
49 
50  virtual void Init (int nx, double xmin, double xmax, int ny, double ymin, double ymax) =0;
51  int IdxZ (int ix, int iy) const;
52 
53  //-- private data members
54  int fNX;
55  int fNY;
56  int fNZ;
57  double * fX; //[fNX]
58  double * fY; //[fNY]
59  double * fZ; //[fNZ]
60  double fDX;
61  double fDY;
62  double fXmin;
63  double fXmax;
64  double fYmin;
65  double fYmax;
66  double fZmin;
67  double fZmax;
68 
69  ClassDef(BLI2DGrid, 1)
70  };
71 
72 //____________________________________________________________________________
73 //____________________________________________________________________________
74 
75 class BLI2DUnifGrid : public BLI2DGrid {
76 
77 public:
78  //-- ctors & dtor
79  BLI2DUnifGrid();
80  BLI2DUnifGrid(int nx, double xmin, double xmax, int ny, double ymin, double ymax);
81  BLI2DUnifGrid(int nx, int ny, double *x, double *y, double *z);
82 
83  //-- add another point in the grid
84  bool AddPoint(double x, double y, double z);
85 
86  //-- evaluate the function at the input position
87  double Evaluate (double x, double y) const;
88 
89 private:
90 
91  void Init (int nx=0, double xmin=0, double xmax=0, int ny=0, double ymin=0, double ymax=0);
92 
93  ClassDef(BLI2DUnifGrid, 1)
94  };
95 
96 //____________________________________________________________________________
97 //____________________________________________________________________________
98 
99 class BLI2DNonUnifGrid : public BLI2DGrid {
100 
101 public:
102  //-- ctors & dtor
104  BLI2DNonUnifGrid(int nx, double xmin, double xmax, int ny, double ymin, double ymax);
105  BLI2DNonUnifGrid(int nx, int ny, double *x, double *y, double *z);
106 
107  //-- add another point in the grid
108  bool AddPoint(double x, double y, double z);
109 
110  //-- evaluate the function at the input position
111  double Evaluate (double x, double y) const;
112 
113 private:
114 
115  void Init (int nx=0, double xmin=0, double xmax=0, int ny=0, double ymin=0, double ymax=0);
116  int fNFillX;
117  int fNFillY;
118 
119  ClassDef(BLI2DNonUnifGrid, 1)
120  };
121 
122 }
123 #endif
double fXmin
Definition: BLI2D.h:62
double fYmax
Definition: BLI2D.h:65
double * fY
Definition: BLI2D.h:58
Bilinear interpolation of 2D functions on a regular grid.
Definition: BLI2D.h:75
bool AddPoint(double x, double y, double z)
Definition: BLI2D.cxx:205
double fZmax
Definition: BLI2D.h:67
double * fX
Definition: BLI2D.h:57
double Evaluate(double x, double y) const
Definition: BLI2D.cxx:325
double fDX
Definition: BLI2D.h:60
void Init(int nx=0, double xmin=0, double xmax=0, int ny=0, double ymin=0, double ymax=0)
Definition: BLI2D.cxx:130
double ZMin(void) const
Definition: BLI2D.h:45
bool AddPoint(double x, double y, double z)
Definition: BLI2D.cxx:73
double fDY
Definition: BLI2D.h:61
double YMin(void) const
Definition: BLI2D.h:43
double XMax(void) const
Definition: BLI2D.h:42
virtual void Init(int nx, double xmin, double xmax, int ny, double ymin, double ymax)=0
void Init(int nx=0, double xmin=0, double xmax=0, int ny=0, double ymin=0, double ymax=0)
Definition: BLI2D.cxx:387
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:46
double Evaluate(double x, double y) const
Definition: BLI2D.cxx:92
int IdxZ(int ix, int iy) const
Definition: BLI2D.cxx:36
double YMax(void) const
Definition: BLI2D.h:44
double fYmin
Definition: BLI2D.h:64
virtual ~BLI2DGrid()
Definition: BLI2D.cxx:29
double fXmax
Definition: BLI2D.h:63
double XMin(void) const
Definition: BLI2D.h:41
double fZmin
Definition: BLI2D.h:66
double * fZ
Definition: BLI2D.h:59