26 JABC(
const char* title) :
46 JPrecision_t(
const double f,
54 friend std::istream&
operator>>(std::istream&
in, JPrecision_t&
object)
56 return in >>
object.f >>
object.fp >>
object.v;
59 friend std::ostream&
operator<<(std::ostream& out,
const JPrecision_t&
object)
61 return out <<
object.f <<
' ' <<
object.fp <<
' ' <<
object.v;
77 int main(
int argc,
char **argv)
84 unsigned int numberOfEvents;
90 precision[
"spline"] = JPrecision_t(1.0e-3, 1.0e-1, 1.0e-4);
91 precision[
"hermite"] = JPrecision_t(1.0e-3, 1.0e-1, 1.0e-4);
92 precision[
"grid"] = JPrecision_t(1.0e-3, 1.0e-1, 1.0e-4);
93 precision[
"polint"] = JPrecision_t(1.0e-14, 1.0e-12, 1.0e-14);
97 JParser<> zap(
"Example program to test 1D interpolation of a polynome.");
107 catch(
const exception &error) {
108 FATAL(error.what() << endl);
114 JSplineFunction1S_t spline;
115 JHermiteSplineFunction1S_t hermite;
116 JGridSplineFunction1S_t grid;
117 JPolintFunction1H_t< N > polint;
118 JPolintFunction1D_t<N+1> Polint;
120 const double xmin = -1.0;
121 const double xmax = +1.0;
137 if (numberOfEvents != 0) {
139 JABC Qspline (
"spline");
140 JABC Qhermite(
"hermite");
142 JABC Qpolint (
"polint");
144 for (
unsigned int i = 0; i != numberOfEvents; ++i) {
146 const double x = gRandom->Uniform(
xmin,
xmax);
152 Qspline .f .put(y1 - spline (x).
f);
153 Qhermite.f .put(y1 - hermite(x).f);
154 Qgrid .f .put(y1 - grid (x).f);
155 Qpolint .f .put(y1 - polint (x).f);
157 Qspline .fp.put(fp - spline (x).fp);
158 Qhermite.fp.put(fp - hermite(x).fp);
159 Qgrid .fp.put(fp - grid (x).fp);
160 Qpolint .fp.put(fp - polint (x).fp);
162 Qspline .v .put(F1 - spline (x).
v);
163 Qhermite.v .put(F1 - hermite(x).v);
164 Qgrid .v .put(F1 - grid (x).v);
165 Qpolint .v .put(F1 - Polint (x));
170 cout <<
"RMS: f f' F " << endl;
171 cout <<
"_________________________________________" << endl;
174 <<
SCIENTIFIC(10,3) << Qspline .f .getSTDev() <<
' '
175 <<
SCIENTIFIC(10,3) << Qspline .fp.getSTDev() <<
' '
176 <<
SCIENTIFIC(10,3) << Qspline .v .getSTDev() << endl;
179 <<
SCIENTIFIC(10,3) << Qhermite.f .getSTDev() <<
' '
180 <<
SCIENTIFIC(10,3) << Qhermite.fp.getSTDev() <<
' '
181 <<
SCIENTIFIC(10,3) << Qhermite.v .getSTDev() << endl;
184 <<
SCIENTIFIC(10,3) << Qgrid .f .getSTDev() <<
' '
185 <<
SCIENTIFIC(10,3) << Qgrid .fp.getSTDev() <<
' '
186 <<
SCIENTIFIC(10,3) << Qgrid .v .getSTDev() << endl;
189 <<
SCIENTIFIC(10,3) << Qpolint .f .getSTDev() <<
' '
190 <<
SCIENTIFIC(10,3) << Qpolint .fp.getSTDev() <<
' '
191 <<
SCIENTIFIC(10,3) << Qpolint .v .getSTDev() << endl;
194 ASSERT(Qspline .
f .getSTDev() <= precision[
"spline"].
f);
195 ASSERT(Qspline .fp.getSTDev() <= precision[
"spline"].fp);
196 ASSERT(Qspline .
v .getSTDev() <= precision[
"spline"].
v);
198 ASSERT(Qhermite.f .getSTDev() <= precision[
"hermite"].f);
199 ASSERT(Qhermite.fp.getSTDev() <= precision[
"hermite"].fp);
200 ASSERT(Qhermite.v .getSTDev() <= precision[
"hermite"].v);
202 ASSERT(Qgrid .f .getSTDev() <= precision[
"grid"].f);
203 ASSERT(Qgrid .fp.getSTDev() <= precision[
"grid"].fp);
204 ASSERT(Qgrid .v .getSTDev() <= precision[
"grid"].v);
206 ASSERT(Qpolint .f .getSTDev() <= precision[
"polint"].f);
207 ASSERT(Qpolint .fp.getSTDev() <= precision[
"polint"].fp);
208 ASSERT(Qpolint .v .getSTDev() <= precision[
"polint"].v);
216 cout <<
"> " << flush;
226 istringstream(buffer) >>
x;
228 cout <<
"f1 " <<
f1 (x) << endl;
229 cout <<
"spline " << spline (x).f << endl;
230 cout <<
"hermite " << hermite(x).f << endl;
231 cout <<
"grid spline " << grid (x).f << endl;
232 cout <<
"polynomial " << polint (x).f << endl;
234 catch(
const JException& exception) {
235 cout << exception.what() << endl;
const JPolynome F1
Integral.
Utility class to parse command line options.
int main(int argc, char *argv[])
o $QUALITY_ROOT d $DEBUG!JPlot1D f
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
const JPolynome f1(1.0, 2.0, 3.0)
Function.
#define ASSERT(A,...)
Assert macro.
I/O formatting auxiliaries.
double getDerivative(const double x) const
Derivative value.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
General purpose messaging.
double getIntegral(const double x) const
Integral value.
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
Utility class to parse command line options.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Auxiliary data structure for floating point format specification.
int numberOfBins
number of bins for average CDF integral of optical module
double getValue(const double x) const
Function value.