42 result_type(
const double __f,
58 operator double()
const
95 inline result_type operator()(
const double x,
99 return result_type(
f (x) *
f (y) *
f (z),
100 fp(x) *
f (y) *
f (z),
101 f (x) * fp(y) *
f (z),
102 f (x) *
f (y) * fp(z));
113 inline double f(
const double x)
const
115 return __f1.getValue(x);
125 inline double fp(
const double x)
const
127 return __f1.getDerivative(x);
142 template<
class JMultiFunction_t>
143 int do_main(
int argc,
char **argv,
const char* title)
154 JParser<> zap(
"Example program to test multi-dimensional interpolation with derivatives.");
163 catch(
const exception &error) {
164 FATAL(error.what() << endl);
168 if (numberOfEvents <= 0) {
FATAL(
"Number of events " << numberOfEvents << endl); }
174 const JFunction3D
f3(
f1);
176 const double xmin = -1.0;
177 const double xmax = +1.0;
183 for (
double x =
xmin; x <
xmax + 0.5*dx; x += dx) {
184 for (
double y =
xmin; y <
xmax + 0.5*dx; y += dx) {
185 for (
double z =
xmin; z <
xmax + 0.5*dx; z += dx) {
186 g3[
x][
y][
z] =
f3(x,y,z);
200 for (
int i = 0;
i != numberOfEvents; ++
i) {
202 const double x = gRandom->Uniform(
xmin,
xmax);
203 const double y = gRandom->Uniform(
xmin,
xmax);
204 const double z = gRandom->Uniform(
xmin,
xmax);
206 const JFunction3D ::result_type
u =
f3(x,y,z);
207 const typename JMultiFunction_t::result_type
v = g3(x,y,z);
209 f .put(u.f - v.f .f .f);
210 fx.put(u.fx - v.fp.f .f);
211 fy.put(u.fy - v.f .fp.f);
212 fz.put(u.fz - v.f .f .fp);
215 cout << endl << title <<
":" << endl;
217 for (
const JQuantile* p : { &
f, &fx, &fy, &fz }) {
218 p->print(cout, p == &
f);
231 int main(
int argc,
char **argv)
239 JPolint3FunctionalGridMapH>::maplist JMaplist_t;
242 if (do_main<JMultiFunction_t>(argc, argv,
"Polint") != 0)
return 1;
248 JSplineFunctionalGridMapH>::maplist JMaplist_t;
251 if (do_main<JMultiFunction_t>(argc, argv,
"Spline") != 0)
return 1;
Utility class to parse command line options.
int main(int argc, char *argv[])
Various implementations of functional maps.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
const parameter_list< JPolynome< ID_t, 0 > > JPolynome< ID_t, 0 >::parameters & JPolynome
Set parameters.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
General purpose messaging.
then usage $script[energy[distance[z of PMT]]] fi case set_variable z
Utility class to parse command line options.
then JHobbit a $DETECTOR f
double f3(const double x, const double y, const double z)
3D function.
Recursive template class for polynomial function.
int numberOfBins
number of bins for average CDF integral of optical module