27 int do_main(
int argc,
char **argv)
32 unsigned int numberOfEvents;
33 unsigned int numberOfBins;
38 JParser<> zap(
"Example program to test 1D interpolation of a polynome.");
46 catch(
const exception &error) {
47 FATAL(error.what() << endl);
51 FATAL(
"Number of degrees " << N <<
" < 1." << endl);
61 for (
int i = 1; i != N + 1; ++i) {
62 f1.push_back(f1.rbegin()->getDerivative());
66 typedef JResultPolynome<N, double> JResult_t;
67 typedef JPolintFunction1D<N, JElement2D<double, double>, JCollection, JResult_t> JFunction1D_t;
71 const double xmin = 0.0;
72 const double xmax =
PI;
75 const double dx = 0.0 *
PI;
77 const JGrid<double> grid(numberOfBins + 1, xmin - dx, xmax + dx);
79 polint.configure(grid, f1[0]);
83 polint.setExceptionHandler(
new typename JFunction1D_t::JDefaultResult(
JMATH::zero));
86 if (numberOfEvents != 0) {
90 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
96 Q[i].setTitle(os.str());
99 for (
unsigned int i = 0; i != numberOfEvents; ++i) {
101 const double x = gRandom->Uniform(xmin, xmax);
102 const JResult_t
result = polint(x);
104 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
105 Q[i].put(f1[i](x) -
result.y[i]);
109 cout <<
"\nInterpolation with " << N <<
" degrees polynomial:" << endl;
111 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
112 Q[i].print(cout, i == 0);
126 int main(
int argc,
char **argv)
128 if (do_main<2>(argc, argv) != 0) {
return 1; }
129 if (do_main<3>(argc, argv) != 0) {
return 1; }
130 if (do_main<4>(argc, argv) != 0) {
return 1; }
131 if (do_main<5>(argc, argv) != 0) {
return 1; }