npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
CoordinateSelector.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_COORDINATESELECTOR_HH_
2 #define NPSTAT_COORDINATESELECTOR_HH_
3 
4 /*!
5 // \file CoordinateSelector.hh
6 //
7 // \brief Multidimensional functor which picks one of the elements
8 // from an array of doubles
9 //
10 // Author: I. Volobouev
11 //
12 // August 2012
13 */
14 
15 #include <climits>
16 #include <stdexcept>
17 
19 
20 namespace npstat {
21  /**
22  // A trivial implementation of AbsMultivariateFunctor which selects
23  // an element with a certain index from the input array
24  */
26  {
27  public:
28  inline explicit CoordinateSelector(const unsigned i) : index_(i) {}
29 
30  inline virtual ~CoordinateSelector() {}
31 
32  inline double operator()(const double* point, const unsigned dim) const
33  {
34  if (dim <= index_)
35  throw std::invalid_argument(
36  "In npstat::CoordinateSelector::operator(): "
37  "input array dimensionality is too small");
38  return point[index_];
39  }
40  inline unsigned minDim() const {return index_ + 1U;}
41  inline unsigned maxDim() const {return UINT_MAX;}
42 
43  private:
45  unsigned index_;
46  };
47 }
48 
49 #endif // NPSTAT_COORDINATESELECTOR_HH_
Interface definition for multidimensional functors.
Definition: CoordinateSelector.hh:26
unsigned maxDim() const
Definition: CoordinateSelector.hh:41
unsigned minDim() const
Definition: CoordinateSelector.hh:40
double operator()(const double *point, const unsigned dim) const
Definition: CoordinateSelector.hh:32
Definition: AbsArrayProjector.hh:14
Definition: AbsMultivariateFunctor.hh:19