25 int main(
int argc,
char **argv)
30 unsigned int numberOfEvents;
31 unsigned int numberOfBins;
38 JParser<> zap(
"Example program to test 1D interpolation of a polynome.");
48 catch(
const exception &error) {
49 FATAL(error.what() << endl);
53 FATAL(
"Invalid polynomial.");
60 typedef JResultPolynome<N, double> JResult_t;
61 typedef JPolintFunction1D<N, JElement2D<double, double>, JCollection, JResult_t> JFunction1D_t;
67 const double xmin = -1.0;
68 const double xmax = +1.0;
70 polint.configure(JGrid<double>(numberOfBins, xmin, xmax), f1);
74 polint.setExceptionHandler(
new JFunction1D_t::JDefaultResult(
JMATH::zero));
79 for (
int i = 1; i != (int) f1.size(); ++i) {
80 fp.push_back(fp.rbegin()->getDerivative());
85 for (
int i = 0; i != (int) f1.size(); ++i) {
86 DEBUG(
' ' << fp[i](x0));
92 JResult_t
result = polint(x0);
94 for (
int i = 0; i != N+1; ++i) {
100 if (numberOfEvents != 0) {
104 for (
int j = 0;
j !=
sizeof(Q)/
sizeof(Q[0]); ++
j) {
110 Q[
j].setTitle(os.str());
113 const int M = min(fp.size(),
sizeof(Q)/
sizeof(Q[0]));
115 for (
unsigned int i = 0; i != numberOfEvents; ++i) {
117 const double x = gRandom->Uniform(xmin, xmax);
119 JResult_t
result = polint(x);
121 for (
int j = 0;
j != M; ++
j) {
126 for (
int j = 0;
j != M; ++
j) {
127 Q[
j].print(cout,
j == 0);