test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MultivariateFunctorScanner.h
Go to the documentation of this file.
1 #ifndef NPSTAT_MULTIVARIATEFUNCTORSCANNER_HH_
2 #define NPSTAT_MULTIVARIATEFUNCTORSCANNER_HH_
3 
15 #include <vector>
16 #include <cassert>
18 
20 
21 namespace npstat {
26  template<class IndexMapper>
28  {
29  public:
41  const std::vector<IndexMapper>& maps)
42  : fcn_(fcn), mapping_(maps), buf_(fcn.minDim()), dim_(fcn.minDim())
43  {
44  if (!(dim_ && dim_ == maps.size())) throw npstat::NpstatInvalidArgument(
45  "In npstat::MultivariateFunctorScanner constructor: "
46  "incompatible arguments");
47  if (dim_ != fcn.maxDim()) throw npstat::NpstatInvalidArgument(
48  "In npstat::MultivariateFunctorScanner constructor: "
49  "functors of variable dimensionality are not supported");
50  }
51 
53  inline double operator()(const unsigned* index,
54  const unsigned indexLen) const
55  {
56  if (dim_ != indexLen) throw npstat::NpstatInvalidArgument(
57  "In npstat::MultivariateFunctorScanner::operator(): "
58  "incompatible input point dimensionality");
59  assert(index);
60  double* x = &buf_[0];
61  for (unsigned i=0; i<dim_; ++i)
62  x[i] = mapping_[i](index[i]);
63  return fcn_(x, dim_);
64  }
65 
66  private:
68 
70  const std::vector<IndexMapper>& mapping_;
71  mutable std::vector<double> buf_;
72  unsigned dim_;
73  };
74 }
75 
76 #endif // NPSTAT_MULTIVARIATEFUNCTORSCANNER_HH_
77 
int i
Definition: DBlmapReader.cc:9
double operator()(const unsigned *index, const unsigned indexLen) const
assert(m_qm.get())
T x() const
Cartesian x coordinate.
MultivariateFunctorScanner(const AbsMultivariateFunctor &fcn, const std::vector< IndexMapper > &maps)
Exceptions for the npstat namespace.
virtual unsigned maxDim() const
void fcn(int &, double *, double &, double *, int)
Interface definition for multidimensional functors.
const std::vector< IndexMapper > & mapping_