Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMath.cc File Reference

Example program to test user class with arithmetic capabilities (based on class JMATH::JMath). More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TRandom3.h"
#include "JLang/JException.hh"
#include "JMath/JMath.hh"
#include "JMath/JMathToolkit.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test user class with arithmetic capabilities (based on class JMATH::JMath).

Author
mdejong

Definition in file JMath.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 117 of file JMath.cc.

118 {
119  using namespace std;
120 
121  double alpha;
122  int debug;
123 
124  try {
125 
126  JParser<> zap("Example program to test user class with arithmetic capabilities.");
127 
128  zap['a'] = make_field(alpha);
129  zap['d'] = make_field(debug) = 0;
130 
131  zap(argc, argv);
132  }
133  catch(const exception &error) {
134  FATAL(error.what() << endl);
135  }
136 
137  using namespace JPP;
138 
139 
140  gRandom->SetSeed(0);
141 
142  const Double_t xmin = -1.0;
143  const Double_t xmax = +1.0;
144 
145 
146  const JObject A(gRandom->Uniform(xmin, xmax),
147  gRandom->Uniform(xmin, xmax),
148  gRandom->Uniform(xmin, xmax));
149 
150  const JObject B(gRandom->Uniform(xmin, xmax),
151  gRandom->Uniform(xmin, xmax),
152  gRandom->Uniform(xmin, xmax));
153 
154  cout << "A " << A << endl;
155  cout << "B " << B << endl;
156  cout << "interpolate " << interpolate(A, B, alpha) << endl;
157 
158  cout << "A + B = " << A + B << endl;
159 
160  cout << "A * " << noshowpos << FIXED(5,2) << alpha << " = " << A * alpha << endl;
161 }
Utility class to parse command line options.
Definition: JParser.hh:1493
T interpolate(const T &first, const T &second, const double alpha)
Interpolation between objects.
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:481
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
Auxiliary base class for inline creation of a static value or clone from a temporary object...
Definition: JObject.hh:18
int debug
debug level
Definition: JSirene.cc:61
#define FATAL(A)
Definition: JMessage.hh:67
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A