Functions
gtestBLI2DUnifGrid.cxx File Reference
#include <TMath.h>
#include <TFile.h>
#include <TNtuple.h>
#include "Framework/Messenger/Messenger.h"
#include "Framework/Numerical/BLI2D.h"
#include "Framework/Numerical/RandomGen.h"

Go to the source code of this file.

Functions

double func (double x, double y)
 
int main (int, char **)
 

Function Documentation

double func ( double  x,
double  y 
)

Definition at line 81 of file gtestBLI2DUnifGrid.cxx.

82 {
83  //return x*y+10*x-7*y+1;
84  return TMath::Sin(x)/x * TMath::Sin(y)/y;
85 }
list x
Definition: train.py:276
int main ( int  ,
char **   
)

Definition at line 31 of file gtestBLI2DUnifGrid.cxx.

32 {
33  int npoints=10000;
34 
35  int nx = 100;
36  int ny = 100;
37 
38  double xmin = -5;
39  double xmax = 5;
40  double ymin = -5;
41  double ymax = 5;
42 
43  double dx = (xmax-xmin)/(nx-1);
44  double dy = (ymax-ymin)/(ny-1);
45 
46  BLI2DUnifGrid biln(nx,xmin,xmax,ny,ymin,ymax);
47 
48  for(int ix=0; ix<nx; ix++) {
49  double x = xmin + ix * dx;
50  for(int iy=0; iy<ny; iy++) {
51  double y = ymin + iy * dy;
52  double z = func(x,y);
53  biln.AddPoint(x,y,z);
54  }
55  }
56 
57  RandomGen * rnd = RandomGen::Instance();
58 
59  TNtuple * nt = new TNtuple("nt","billinear interpolation validation","x:y:ztrue:zeval");
60 
61  for(int ip=0; ip<npoints; ip++) {
62  double rx = rnd->RndGen().Uniform();
63  double ry = rnd->RndGen().Uniform();
64  double x = xmin + (xmax-xmin)*rx;
65  double y = ymin + (ymax-ymin)*ry;
66  double zt = func(x,y);
67  double ze = biln.Evaluate(x,y);
68 
69  nt->Fill(x,y,zt,ze);
70  }
71 
72  TFile f("./bli2dug.root","recreate");
73  nt->Write();
74  f.Close();
75 
76  LOG("test", pINFO) << "Done!";
77  return 0;
78 }
Bilinear interpolation of 2D functions on a regular grid.
Definition: BLI2D.h:75
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
double func(double x, double y)
#define pINFO
Definition: Messenger.h:62
TRandom3 & RndGen(void) const
rnd number generator for generic usage
Definition: RandomGen.h:80
list x
Definition: train.py:276