CMS 3D CMS Logo

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 
npstat::MultivariateFunctorScanner::buf_
std::vector< double > buf_
Definition: MultivariateFunctorScanner.h:71
mps_fire.i
i
Definition: mps_fire.py:428
npstat::MultivariateFunctorScanner::mapping_
const std::vector< IndexMapper > & mapping_
Definition: MultivariateFunctorScanner.h:70
npstat::MultivariateFunctorScanner
Definition: MultivariateFunctorScanner.h:27
npstat::MultivariateFunctorScanner::MultivariateFunctorScanner
MultivariateFunctorScanner(const AbsMultivariateFunctor &fcn, const std::vector< IndexMapper > &maps)
Definition: MultivariateFunctorScanner.h:40
cms::cuda::assert
assert(be >=bs)
fcn
void fcn(int &, double *, double &, double *, int)
Definition: LASBarrelAlgorithm.cc:388
npstat::AbsMultivariateFunctor
Definition: AbsMultivariateFunctor.h:18
npstat
Definition: AbsArrayProjector.h:14
npstat::MultivariateFunctorScanner::fcn_
const AbsMultivariateFunctor & fcn_
Definition: MultivariateFunctorScanner.h:69
npstat::NpstatInvalidArgument
Definition: NpstatException.h:38
AbsMultivariateFunctor.h
Interface definition for multidimensional functors.
npstat::MultivariateFunctorScanner::MultivariateFunctorScanner
MultivariateFunctorScanner()
npstat::MultivariateFunctorScanner::dim_
unsigned dim_
Definition: MultivariateFunctorScanner.h:72
npstat::MultivariateFunctorScanner::operator()
double operator()(const unsigned *index, const unsigned indexLen) const
Definition: MultivariateFunctorScanner.h:53
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
NpstatException.h
Exceptions for the npstat namespace.