CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
npstat::MultivariateFunctorScanner< IndexMapper > Class Template Reference

#include <MultivariateFunctorScanner.h>

Public Member Functions

 MultivariateFunctorScanner (const AbsMultivariateFunctor &fcn, const std::vector< IndexMapper > &maps)
 
double operator() (const unsigned *index, const unsigned indexLen) const
 

Private Member Functions

 MultivariateFunctorScanner ()
 

Private Attributes

std::vector< double > buf_
 
unsigned dim_
 
const AbsMultivariateFunctorfcn_
 
const std::vector< IndexMapper > & mapping_
 

Detailed Description

template<class IndexMapper>
class npstat::MultivariateFunctorScanner< IndexMapper >

This class adapts an object derived from AbsMultivariateFunctor so that it can be used with ArrayND method "functorFill" and such

Definition at line 27 of file MultivariateFunctorScanner.h.

Constructor & Destructor Documentation

template<class IndexMapper >
npstat::MultivariateFunctorScanner< IndexMapper >::MultivariateFunctorScanner ( const AbsMultivariateFunctor fcn,
const std::vector< IndexMapper > &  maps 
)
inline

A mapper for each coordinate in the "maps" argument will convert the array index into a proper argument for the scanned density.

This functor will NOT make copies of either "fcn" or "maps" parameters. These parameters will be used by reference only (aliased). It is up to the user of this class to ensure proper lifetime of these objects.

Definition at line 40 of file MultivariateFunctorScanner.h.

References npstat::MultivariateFunctorScanner< IndexMapper >::dim_, and npstat::AbsMultivariateFunctor::maxDim().

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  }
void fcn(int &, double *, double &, double *, int)
const std::vector< IndexMapper > & mapping_
template<class IndexMapper >
npstat::MultivariateFunctorScanner< IndexMapper >::MultivariateFunctorScanner ( )
private

Member Function Documentation

template<class IndexMapper >
double npstat::MultivariateFunctorScanner< IndexMapper >::operator() ( const unsigned *  index,
const unsigned  indexLen 
) const
inline

Calculate the functor value for the given array indices

Definition at line 53 of file MultivariateFunctorScanner.h.

References npstat::MultivariateFunctorScanner< IndexMapper >::buf_, npstat::MultivariateFunctorScanner< IndexMapper >::dim_, npstat::MultivariateFunctorScanner< IndexMapper >::fcn_, mps_fire::i, npstat::MultivariateFunctorScanner< IndexMapper >::mapping_, npstat::MultivariateFunctorScanner< IndexMapper >::MultivariateFunctorScanner(), and x().

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  }
const std::vector< IndexMapper > & mapping_

Member Data Documentation

template<class IndexMapper >
std::vector<double> npstat::MultivariateFunctorScanner< IndexMapper >::buf_
mutableprivate
template<class IndexMapper >
unsigned npstat::MultivariateFunctorScanner< IndexMapper >::dim_
private
template<class IndexMapper >
const AbsMultivariateFunctor& npstat::MultivariateFunctorScanner< IndexMapper >::fcn_
private
template<class IndexMapper >
const std::vector<IndexMapper>& npstat::MultivariateFunctorScanner< IndexMapper >::mapping_
private