53{
56
57 double precision;
59
60 try {
61
62 JParser<> zap(
"Example program to test multi-dimensional map.");
63
66
67 zap(argc, argv);
68 }
69 catch(const exception &error) {
70 FATAL(error.what() << endl);
71 }
72
73
74 const double xmin = -1.0;
75 const double xmax = +1.0;
76 const double nx = 3;
77
80 JMap>::maplist JMaplist_t;
81
83
84 JMultimap_t buffer;
85
86 for (
double x = xmin;
x <= xmax;
x += (xmax - xmin)/(nx - 1)) {
87 for (
double y = xmin;
y <= xmax;
y += (xmax - xmin)/(nx - 1)) {
88 for (double z = xmin; z <= xmax; z += (xmax - xmin)/(nx - 1)) {
89 buffer[
x][
y][z] = f1(x, y, z);
90 }
91 }
92 }
93
94 const JFormat_t format(6, 1, std::ios::fixed);
95
99
100 DEBUG(
"i->[second]*->(first|second)" << endl);
101
102 for (JMultimap_t::super_const_iterator i = buffer.super_begin(); i != buffer.super_end(); ++i) {
104 << format << i->first << ' '
105 << format << i->second->first << ' '
106 << format << i->second->second->first << ' '
107 << format << i->second->second->second << endl);
108
110 i->second->first,
111 i->second->second->first) - i->second->second->second) <= precision, "Test iterator equality");
112 }
113
114 DEBUG(
"i->[second]*->(first|second)" << endl);
115
116 for (JMultimap_t::super_const_reverse_iterator i = buffer.super_rbegin(); i != buffer.super_rend(); ++i) {
118 << format << i->first << ' '
119 << format << i->second->first << ' '
120 << format << i->second->second->first << ' '
121 << format << i->second->second->second << endl);
122
124 i->second->first,
125 i->second->second->first) - i->second->second->second) <= precision, "Test iterator equality");
126 }
127
128 DEBUG(
"*i.[second]*.(first|second)" << endl);
129
130 for (JMultimap_t::super_const_reverse_iterator i = buffer.super_rbegin(); i != buffer.super_rend(); ++i) {
132 << format << (*i).first << ' '
133 << format << (*i).second.first << ' '
134 << format << (*i).second.second.first << ' '
135 << format << (*i).second.second.second << endl);
136
138 i->second->first,
139 i->second->second->first) - i->second->second->second) <= precision, "Test iterator equality");
140 }
141
142 DEBUG(
"i.getKey() i.getValue()" << endl);
143
144 for (JMultimap_t::super_const_iterator i = buffer.super_begin(); i != buffer.super_end(); ++i) {
145
146 DEBUG(i.getKey() <<
' ' << format << i.getValue() << endl);
147
148 ASSERT(fabs(f1(i.getKey()) - i.getValue()) <= precision,
"Test iterator equality");
149 }
150
151 return 0;
152}
void setFormat(const JFormat_t &format)
Set format for given type.
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).