46{
   49 
   50  int         numberOfEvents;
   52  double      precision;
   54 
   55  try {
   56 
   57    JParser<> zap(
"Example program to create 1D function interpolator from multi-dimensional interpolator.");
 
   58 
   63 
   64    zap(argc, argv);
   65  }
   66  catch(const exception &error) {
   67    FATAL(error.what() << endl);
 
   68  }
   69 
   70  ASSERT(numberOfEvents > 0);
 
   71 
   72  const double xmin = -1.0;
 
   73  const double xmax = +1.0;
 
   75 
   77  typedef JFunction1D_t::abscissa_type                                     abscissa_type;
   78  typedef JFunction1D_t::value_type                                        value_type;
   79 
   81 
   86 
   89 
   90  for (
double x0 = xmin; x0 < 
xmax + 0.5*dx; x0 += dx) {
 
   91    for (
double x1 = xmin; x1 < 
xmax + 0.5*dx; x1 += dx) {
 
   92      for (
double x2 = xmin; x2 < 
xmax + 0.5*dx; x2 += dx) {
 
   93        for (
double x3 = xmin; x3 < 
xmax + 0.5*dx; x3 += dx) {
 
   94          for (
double x4 = xmin; x4 < 
xmax + 0.5*dx; x4 += dx) {
 
   95            g5[x0][x1][x2][x3][x4] = 
f5(x0,x1,x2,x3,x4);
 
   96            h5[x0][x1][x2][x3][x4] = 
f5(x0,x1,x2,x3,x4);
 
   97          }
   98        }
   99      }
  100    }
  101  }
  102 
  105 
  106 
  107  const double x0 = +0.15;
  108  const double x1 = -0.25;
  109  const double x2 =  0.25;
  110  const double x3 = -0.15;
  111    
  113 
  114  JTimer timer(
"4D interpolator");
 
  115 
  116  timer.start();
  117 
  118  for (int i = 0; i != 100; ++i) {
  119    copy(h5(x0,x1,x2,x3), 
g1);      
 
  120  }
  121 
  122  timer.stop();
  123  timer.print(cout, 1.0/100, 
micro_t);
 
  124 
  126 
  127  JTimer t1(
"1D interpolator");
 
  128  JTimer t5(
"5D interpolator");
 
  129 
  132    
  133  
  134 
  135  const int N = 100;
  136 
  139  double v[N];
  140  double w[N];
  141 
  142  for (int i = 0; i != numberOfEvents; ++i) {
  143 
  144    for (int __i = 0; __i != N; ++__i) {
  145 
  146      const double x4 = gRandom->Uniform(xmin, xmax);
  147 
  149      y[__i] = 
f5(x0,x1,x2,x3,x4);
 
  150    }
  151 
  152    t1.start();
  153 
  154    for (int __i = 0; __i != N; ++__i) {
  156    }
  157 
  158    t1.stop();
  159 
  160    t5.start();
  161 
  162    for (int __i = 0; __i != N; ++__i) {
  163      w[__i] = g5(x0,x1,x2,x3,x[__i]);
  164    }
  165 
  166    t5.stop();
  167 
  168    for (int __i = 0; __i != N; ++__i) {
  169      Q1.put(v[__i] - y[__i]);
  170      Q5.put(w[__i] - y[__i]);
  171    }
  172  }
  173 
  175 
  176    Q1.print(cout);
  177    Q5.print(cout, false);
  178      
  179    t1.print(cout, 1.0 / (N * numberOfEvents), 
nano_t);
 
  180    t5.print(cout, 1.0 / (N * numberOfEvents), 
nano_t);
 
  181  }
  182 
  183  ASSERT(fabs(Q1.getMean()  - Q5.getMean())  <= precision);
 
  184  ASSERT(fabs(Q1.getSTDev() - Q5.getSTDev()) <= precision);
 
  185 
  186  return 0;
  187}
#define ASSERT(A,...)
Assert macro.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
double f5(const double x0, const double x1, const double x2, const double x3, const double x4)
5D function.
 
Double_t g1(const Double_t x)
Function.
 
int numberOfBins
number of bins for average CDF integral of optical module
 
Auxiliary class for CPU timing and usage.
 
Utility class to parse command line options.
 
void copy(const Head &from, JHead &to)
Copy header from from to to.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).