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 cout <<
' ' << fp[i](x0);
93 JResult_t result = polint(x0);
95 for (
int i = 0; i != N+1; ++i) {
96 cout <<
' ' << result.y[i];
102 if (numberOfEvents != 0) {
106 for (
int j = 0; j !=
sizeof(Q)/
sizeof(Q[0]); ++j) {
112 Q[j].setTitle(os.str());
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 !=
sizeof(Q)/
sizeof(Q[0]); ++j) {
122 Q[j].put(fp[j](x) - result.y[j]);
126 for (
int j = 0; j !=
sizeof(Q)/
sizeof(Q[0]); ++j) {
127 Q[j].print(cout, j == 0);
Utility class to parse command line options.
static const JZero zero
Function object to assign zero value.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
General purpose messaging.
Utility class to parse command line options.
int main(int argc, char *argv[])