Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
genie::BLI2DUnifGrid Class Reference

Bilinear interpolation of 2D functions on a regular grid. More...

#include "/cvmfs/nova.opensciencegrid.org/externals/genie/v3_00_06_p01/Linux64bit+3.10-2.17-e17-debug/GENIE-Generator/src/Framework/Numerical/BLI2D.h"

Inheritance diagram for genie::BLI2DUnifGrid:
genie::BLI2DGrid

Public Member Functions

 BLI2DUnifGrid ()
 
 BLI2DUnifGrid (int nx, double xmin, double xmax, int ny, double ymin, double ymax)
 
 BLI2DUnifGrid (int nx, int ny, double *x, double *y, double *z)
 
bool AddPoint (double x, double y, double z)
 
double Evaluate (double x, double y) const
 
double XMin (void) const
 
double XMax (void) const
 
double YMin (void) const
 
double YMax (void) const
 
double ZMin (void) const
 
double ZMax (void) const
 

Protected Member Functions

int IdxZ (int ix, int iy) const
 

Protected Attributes

int fNX
 
int fNY
 
int fNZ
 
double * fX
 
double * fY
 
double * fZ
 
double fDX
 
double fDY
 
double fXmin
 
double fXmax
 
double fYmin
 
double fYmax
 
double fZmin
 
double fZmax
 

Private Member Functions

void Init (int nx=0, double xmin=0, double xmax=0, int ny=0, double ymin=0, double ymax=0)
 

Detailed Description

Bilinear interpolation of 2D functions on a regular grid.

Author
Costas Andreopoulos <costas.andreopoulos stfc.ac.uk> University of Liverpool & STFC Rutherford Appleton Lab

May 30, 2009

Copyright (c) 2003-2019, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org or see $GENIE/LICENSE

Definition at line 76 of file BLI2D.h.

Constructor & Destructor Documentation

genie::BLI2DUnifGrid::BLI2DUnifGrid ( )
BLI2DUnifGrid::BLI2DUnifGrid ( int  nx,
double  xmin,
double  xmax,
int  ny,
double  ymin,
double  ymax 
)

Definition at line 63 of file BLI2D.cxx.

References genie::BLI2DGrid::Init().

65 {
66  this->Init(nx, xmin, xmax, ny, ymin, ymax);
67 }
std::map< std::string, double > xmax
void Init(int nx=0, double xmin=0, double xmax=0, int ny=0, double ymin=0, double ymax=0)
Definition: BLI2D.cxx:143
Double_t ymax
Definition: plot.C:25
Double_t ymin
Definition: plot.C:24
BLI2DUnifGrid::BLI2DUnifGrid ( int  nx,
int  ny,
double *  x,
double *  y,
double *  z 
)

Definition at line 69 of file BLI2D.cxx.

References genie::BLI2DGrid::AddPoint(), genie::BLI2DGrid::IdxZ(), genie::BLI2DGrid::Init(), xmax, make_mec_shifts_plots::xmin, ymax, and ymin.

71 {
72  double xmin = x[0];
73  double xmax = x[nx-1];
74  double ymin = y[0];
75  double ymax = y[nx-1];
76 
77  this->Init(nx, xmin, xmax, ny, ymin, ymax);
78 
79  for(int ix=0; ix<nx; ix++) {
80  for(int iy=0; iy<ny; iy++) {
81  this->AddPoint(x[ix], y[iy], z[this->IdxZ(ix,iy)]);
82  }
83  }
84 }
std::map< std::string, double > xmax
void Init(int nx=0, double xmin=0, double xmax=0, int ny=0, double ymin=0, double ymax=0)
Definition: BLI2D.cxx:143
Double_t ymax
Definition: plot.C:25
bool AddPoint(double x, double y, double z)
Definition: BLI2D.cxx:86
z
Definition: test.py:28
int IdxZ(int ix, int iy) const
Definition: BLI2D.cxx:49
Double_t ymin
Definition: plot.C:24

Member Function Documentation

bool BLI2DUnifGrid::AddPoint ( double  x,
double  y,
double  z 
)
virtual

Implements genie::BLI2DGrid.

Definition at line 86 of file BLI2D.cxx.

References genie::BLI2DGrid::fDX, genie::BLI2DGrid::fDY, genie::BLI2DGrid::fXmin, genie::BLI2DGrid::fYmin, genie::BLI2DGrid::fZ, genie::BLI2DGrid::fZmax, genie::BLI2DGrid::fZmin, genie::BLI2DGrid::IdxZ(), LOG, pDEBUG, and test::z.

Referenced by main().

87 {
88  int ix = TMath::FloorNint( (x - fXmin + fDX/2) / fDX );
89  int iy = TMath::FloorNint( (y - fYmin + fDY/2) / fDY );
90  int iz = this->IdxZ(ix,iy);
91 
92  fZ[iz] = z;
93 
94  fZmin = TMath::Min(z, fZmin);
95  fZmax = TMath::Max(z, fZmax);
96 
97  LOG("BLI2DUnifGrid", pDEBUG)
98  << "Added x = " << x << " (ix = " << ix << ")"
99  << " y = " << y << " (iy = " << iy << ") -> "
100  << " z = " << z << " (iz = " << iz << ")";
101 
102  return true;
103 }
double fXmin
Definition: BLI2D.h:63
double fZmax
Definition: BLI2D.h:68
double fDX
Definition: BLI2D.h:61
double fDY
Definition: BLI2D.h:62
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
z
Definition: test.py:28
int IdxZ(int ix, int iy) const
Definition: BLI2D.cxx:49
double fYmin
Definition: BLI2D.h:65
double fZmin
Definition: BLI2D.h:67
double * fZ
Definition: BLI2D.h:60
#define pDEBUG
Definition: Messenger.h:64
double BLI2DUnifGrid::Evaluate ( double  x,
double  y 
) const
virtual

Implements genie::BLI2DGrid.

Definition at line 105 of file BLI2D.cxx.

References genie::BLI2DGrid::fDX, genie::BLI2DGrid::fDY, genie::BLI2DGrid::fX, genie::BLI2DGrid::fXmax, genie::BLI2DGrid::fXmin, genie::BLI2DGrid::fY, genie::BLI2DGrid::fYmax, genie::BLI2DGrid::fYmin, genie::BLI2DGrid::fZ, genie::BLI2DGrid::IdxZ(), submit_syst::x, x1, submit_syst::x2, submit_syst::y, y1, submit_syst::y2, and test::z.

Referenced by main().

106 {
107  if(x < fXmin || x > fXmax) return 0.;
108  if(y < fYmin || y > fYmax) return 0.;
109 
110  int ix_lo = TMath::FloorNint( (x - fXmin) / fDX );
111  int iy_lo = TMath::FloorNint( (y - fYmin) / fDY );
112  int ix_hi = ix_lo + 1;
113  int iy_hi = iy_lo + 1;
114 
115  double x1 = fX[ix_lo];
116  double x2 = fX[ix_hi];
117  double y1 = fY[iy_lo];
118  double y2 = fY[iy_hi];
119 
120  double z11 = fZ[ this->IdxZ(ix_lo,iy_lo) ];
121  double z21 = fZ[ this->IdxZ(ix_hi,iy_lo) ];
122  double z12 = fZ[ this->IdxZ(ix_lo,iy_hi) ];
123  double z22 = fZ[ this->IdxZ(ix_hi,iy_hi) ];
124 
125  double z1 = z11 * (x2-x)/(x2-x1) + z21 * (x-x1)/(x2-x1);
126  double z2 = z12 * (x2-x)/(x2-x1) + z22 * (x-x1)/(x2-x1);
127  double z = z1 * (y2-y)/(y2-y1) + z2 * (y-y1)/(y2-y1);
128 
129 /*
130  LOG("BLI2DUnifGrid", pDEBUG) << "x = " << x << " -> nearby nodes: " << x1 << ", " << x2;
131  LOG("BLI2DUnifGrid", pDEBUG) << "y = " << x << " -> nearby nodes: " << y1 << ", " << y2;
132  LOG("BLI2DUnifGrid", pDEBUG) << "z11 := z(" << this->IdxZ(ix_lo,iy_lo) << ") = " << z11;
133  LOG("BLI2DUnifGrid", pDEBUG) << "z21 := z(" << this->IdxZ(ix_hi,iy_lo) << ") = " << z21;
134  LOG("BLI2DUnifGrid", pDEBUG) << "z12 := z(" << this->IdxZ(ix_lo,iy_hi) << ") = " << z12;
135  LOG("BLI2DUnifGrid", pDEBUG) << "z22 := z(" << this->IdxZ(ix_hi,iy_hi) << ") = " << z22;
136  LOG("BLI2DUnifGrid", pDEBUG) << "z1 = " << z1 << ", z2 = " << z2;
137  LOG("BLI2DUnifGrid", pDEBUG) << "interpolated z(x,y) = " << z;
138 */
139 
140  return z;
141 }
double fXmin
Definition: BLI2D.h:63
double fYmax
Definition: BLI2D.h:66
double * fY
Definition: BLI2D.h:59
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
double * fX
Definition: BLI2D.h:58
double fDX
Definition: BLI2D.h:61
double fDY
Definition: BLI2D.h:62
z
Definition: test.py:28
int IdxZ(int ix, int iy) const
Definition: BLI2D.cxx:49
double fYmin
Definition: BLI2D.h:65
double fXmax
Definition: BLI2D.h:64
double * fZ
Definition: BLI2D.h:60
int BLI2DGrid::IdxZ ( int  ix,
int  iy 
) const
protectedinherited
void BLI2DUnifGrid::Init ( int  nx = 0,
double  xmin = 0,
double  xmax = 0,
int  ny = 0,
double  ymin = 0,
double  ymax = 0 
)
privatevirtual

Implements genie::BLI2DGrid.

Definition at line 143 of file BLI2D.cxx.

References genie::BLI2DGrid::fDX, genie::BLI2DGrid::fDY, genie::BLI2DGrid::fNX, genie::BLI2DGrid::fNY, genie::BLI2DGrid::fNZ, genie::BLI2DGrid::fX, genie::BLI2DGrid::fXmax, genie::BLI2DGrid::fXmin, genie::BLI2DGrid::fY, genie::BLI2DGrid::fYmax, genie::BLI2DGrid::fYmin, genie::BLI2DGrid::fZ, genie::BLI2DGrid::fZmax, genie::BLI2DGrid::fZmin, MECModelEnuComparisons::i, cet::sqlite::max(), min(), xmax, make_mec_shifts_plots::xmin, ymax, and ymin.

145 {
146  fNX = 0;
147  fNY = 0;
148  fNZ = 0;
149  fXmin = 0.;
150  fXmax = 0.;
151  fYmin = 0.;
152  fYmax = 0.;
155  fDX = 0.;
156  fDY = 0.;
157  fX = 0;
158  fY = 0;
159  fZ = 0;
160 
161  if(nx>1 && ny>1) {
162  fNX = nx;
163  fNY = ny;
164  fNZ = nx * ny;
165 
166  fXmin = xmin;
167  fXmax = xmax;
168  fYmin = ymin;
169  fYmax = ymax;
172 
173  fDX = (xmax-xmin)/(nx-1);
174  fDY = (ymax-ymin)/(ny-1);
175 
176  fX = new double[fNX];
177  fY = new double[fNY];
178  fZ = new double[fNZ];
179 
180  for(int i=0; i<fNX; i++) { fX[i] = xmin + i*fDX; }
181  for(int i=0; i<fNY; i++) { fY[i] = ymin + i*fDY; }
182  for(int i=0; i<fNZ; i++) { fZ[i] = 0.; }
183  }
184 }
double fXmin
Definition: BLI2D.h:63
double fYmax
Definition: BLI2D.h:66
double * fY
Definition: BLI2D.h:59
double fZmax
Definition: BLI2D.h:68
std::map< std::string, double > xmax
double * fX
Definition: BLI2D.h:58
double fDX
Definition: BLI2D.h:61
Double_t ymax
Definition: plot.C:25
double fDY
Definition: BLI2D.h:62
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
double fYmin
Definition: BLI2D.h:65
Double_t ymin
Definition: plot.C:24
double fXmax
Definition: BLI2D.h:64
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
double fZmin
Definition: BLI2D.h:67
double * fZ
Definition: BLI2D.h:60
double genie::BLI2DGrid::XMax ( void  ) const
inlineinherited

Definition at line 43 of file BLI2D.h.

References genie::BLI2DGrid::fXmax.

43 { return fXmax; }
double fXmax
Definition: BLI2D.h:64
double genie::BLI2DGrid::XMin ( void  ) const
inlineinherited

Definition at line 42 of file BLI2D.h.

References genie::BLI2DGrid::fXmin.

42 { return fXmin; }
double fXmin
Definition: BLI2D.h:63
double genie::BLI2DGrid::YMax ( void  ) const
inlineinherited

Definition at line 45 of file BLI2D.h.

References genie::BLI2DGrid::fYmax.

45 { return fYmax; }
double fYmax
Definition: BLI2D.h:66
double genie::BLI2DGrid::YMin ( void  ) const
inlineinherited

Definition at line 44 of file BLI2D.h.

References genie::BLI2DGrid::fYmin.

44 { return fYmin; }
double fYmin
Definition: BLI2D.h:65
double genie::BLI2DGrid::ZMax ( void  ) const
inlineinherited
double genie::BLI2DGrid::ZMin ( void  ) const
inlineinherited

Definition at line 46 of file BLI2D.h.

References genie::BLI2DGrid::fZmin.

46 { return fZmin; }
double fZmin
Definition: BLI2D.h:67

Member Data Documentation

double genie::BLI2DGrid::fDX
protectedinherited

Definition at line 61 of file BLI2D.h.

Referenced by AddPoint(), Evaluate(), and Init().

double genie::BLI2DGrid::fDY
protectedinherited

Definition at line 62 of file BLI2D.h.

Referenced by AddPoint(), Evaluate(), and Init().

int genie::BLI2DGrid::fNX
protectedinherited

Definition at line 55 of file BLI2D.h.

Referenced by genie::BLI2DNonUnifGrid::AddPoint(), Init(), and genie::BLI2DNonUnifGrid::Init().

int genie::BLI2DGrid::fNY
protectedinherited
int genie::BLI2DGrid::fNZ
protectedinherited

Definition at line 57 of file BLI2D.h.

Referenced by Init(), and genie::BLI2DNonUnifGrid::Init().

double* genie::BLI2DGrid::fX
protectedinherited
double genie::BLI2DGrid::fXmax
protectedinherited
double genie::BLI2DGrid::fXmin
protectedinherited
double* genie::BLI2DGrid::fY
protectedinherited
double genie::BLI2DGrid::fYmax
protectedinherited
double genie::BLI2DGrid::fYmin
protectedinherited
double* genie::BLI2DGrid::fZ
protectedinherited
double genie::BLI2DGrid::fZmax
protectedinherited
double genie::BLI2DGrid::fZmin
protectedinherited

The documentation for this class was generated from the following files: