Example program to test JTOOLS::JRange operations.  
More...
#include <string>
#include <iostream>
#include <iomanip>
#include "JTools/JRange.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
 
Go to the source code of this file.
 | 
| int  | main (int argc, char **argv) | 
|   | 
Example program to test JTOOLS::JRange operations. 
- Author
 - mdejong 
 
Definition in file JRange.cc.
 
      
        
          | int main  | 
          ( | 
          int  | 
          argc,  | 
        
        
           | 
           | 
          char **  | 
          argv  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 45 of file JRange.cc.
   53     JParser<> zap(
"Example program to test range operations.");
 
   59   catch(
const exception &error) {
 
   60     FATAL(error.what() << endl);
 
   66   const double xmin = -1.0;
 
   67   const double xmax = +1.0;
 
   68   const double dx   = (xmax - xmin) / 10;
 
   73     JRange_t A(JRange_t::DEFAULT_RANGE);
 
   74     JRange_t B(xmin, xmax);
 
   76     for (
double x = xmin; x < xmax + 0.5 * dx; x += dx) {
 
   78       DEBUG(setw(
WIDTH) << left << 
"inside"   << 
' ' << B << 
' ' << setw(5) << x << 
' ' << (B(x) ? 
"Y" : 
"N") << endl);
 
   80       ASSERT(B(x) == (x >= xmin && x <= xmax));
 
   85     DEBUG(setw(
WIDTH) << left << 
"range"    << 
' ' << A << endl);
 
   92     const double x1 = -1.0;
 
   93     const double x2 = +0.5;
 
   94     const double x3 = -0.5;
 
   95     const double x4 = +1.0;
 
  100     DEBUG(setw(
WIDTH) << left << 
"join"     << 
' ' << A << 
' ' << B << 
" = " << 
join(A,B)    << endl);
 
  106     const double x1 = -1.0;
 
  107     const double x2 = -0.5;
 
  108     const double x3 = +0.5;
 
  109     const double x4 = +1.0;
 
  114     DEBUG(setw(
WIDTH) << left << 
"combine"  << 
' ' << A << 
' ' << B << 
" = " << 
combine(A,B) << endl);
 
  120     const double x1 = -1.0;
 
  121     const double x2 = -0.5;
 
  122     const double x3 = +0.5;
 
  123     const double x4 = +1.0;
 
  128     DEBUG(setw(
WIDTH) << left << 
"add"      << 
' ' << A << 
' ' << B << 
" = " << A + B        << endl);
 
  130     ASSERT((A + B) == JRange_t(x1+x3,x2+x4));
 
  135       __A__() : value(0.0) {}
 
  136       __A__(
const double value) : value(value) {}
 
  138       double get() 
const { 
return value; }
 
  145     for (
double x = xmin; x < xmax + 0.5 * dx; x += dx) {
 
  152     A.setRange(buffer.begin(), buffer.end(), &__A__::value);
 
  153     B.setRange(buffer.begin(), buffer.end(), &
__A__::get);
 
  155     DEBUG(setw(
WIDTH) << left << 
"setRange"  << 
' ' << A << endl);
 
  156     DEBUG(setw(
WIDTH) << left << 
"setRange"  << 
' ' << B << endl);
 
  158     ASSERT(A == JRange_t(xmin,xmax));
 
  159     ASSERT(B == JRange_t(xmin,xmax));
 
Auxiliary data structure for alignment of data. 
 
Utility class to parse command line options. 
 
#define ASSERT(A)
Assert macro. 
 
T get(const JHead &head)
Get object from header. 
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object 
 
#define DEBUG(A)
Message macros.