21 inline std::ostream& operator<<(std::ostream& out, const JTOOLS::JRange<double>& range)
25 out << fixed << right << showpos << setprecision(1)
45 int main(
int argc,
char **argv)
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;
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);
90 for (
double x = xmin - (xmax - xmin); x < xmax + (xmax - xmin) + 0.5 * dx; x += dx) {
94 while (x1 <= xmin) { x1 += (xmax - xmin); }
95 while (x1 > xmax) { x1 -= (xmax - xmin); }
103 const double x1 = -1.0;
104 const double x2 = +0.5;
105 const double x3 = -0.5;
106 const double x4 = +1.0;
111 DEBUG(setw(
WIDTH) << left <<
"join" <<
' ' << A <<
' ' << B <<
" = " <<
join(A,B) << endl);
118 const double x1 = -1.0;
119 const double x2 = -0.5;
120 const double x3 = +0.5;
121 const double x4 = +1.0;
126 DEBUG(setw(
WIDTH) << left <<
"combine" <<
' ' << A <<
' ' << B <<
" = " <<
combine(A,B) << endl);
132 const double x1 = -1.0;
133 const double x2 = -0.5;
134 const double x3 = +0.5;
135 const double x4 = +1.0;
140 DEBUG(setw(
WIDTH) << left <<
"add" <<
' ' << A <<
' ' << B <<
" = " << A + B << endl);
147 __A__() : value(0.0) {}
148 __A__(
const double value) : value(value) {}
150 double get()
const {
return value; }
157 for (
double x = xmin; x < xmax + 0.5 * dx; x += dx) {
164 A.
setRange(buffer.begin(), buffer.end(), &__A__::value);
165 B.setRange(buffer.begin(), buffer.end(), &
__A__::get);
167 DEBUG(setw(
WIDTH) << left <<
"setRange" <<
' ' << A << endl);
168 DEBUG(setw(
WIDTH) << left <<
"setRange" <<
' ' << B << endl);
Auxiliary data structure for alignment of data.
Utility class to parse command line options.
T get(const JHead &header)
Get object from header.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
General purpose messaging.
JRange< Double_t > JRange_t
Auxiliary class to define a range between two values.
Utility class to parse command line options.
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A
#define DEBUG(A)
Message macros.
int main(int argc, char *argv[])