npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
scanSymmetricDensityAsWeight.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_SCANSYMMETRICDENSITYASWEIGHT_HH_
2 #define NPSTAT_SCANSYMMETRICDENSITYASWEIGHT_HH_
3 
4 /*!
5 // \file scanSymmetricDensityAsWeight.hh
6 //
7 // \brief Scan a symmetric multivariate density for subsequent use as
8 // a tabulated weight
9 //
10 // Author: I. Volobouev
11 //
12 // December 2011
13 */
14 
15 #include <stdexcept>
16 
17 #include "geners/CPP11_auto_ptr.hh"
18 #include "npstat/nm/ArrayND.hh"
20 
21 namespace npstat {
22  /**
23  // Utility function for scanning multivariate kernels and returning
24  // ArrayND of minimal size which encloses the complete density support
25  // region. It is assumed that the density is symmetric under all possible
26  // mirror reflections (i.e., whenever the sign of any "x" component
27  // changes, the density does not change).
28  //
29  // Arguments are as follows:
30  //
31  // kernel -- the density to scan. Assumed to be even in
32  // any coordinate.
33  //
34  // maxOctantDim -- maximum number of steps to make in each dimension
35  // while scanning the hyperoctant
36  //
37  // bandwidthSet -- density function bandwidth values in each dimension
38  //
39  // stepSize -- scan step size in each dimension
40  //
41  // arrayLength -- number of elements in each of the arrays
42  // maxOctantDim, bandwidthSet, and stepSize
43  //
44  // fillOneOctantOnly -- set "true" to scan one octant only (including
45  // central grid points), "false" to scan the complete
46  // support region of the density. In the latter case,
47  // array size in the n-th dimension can become
48  // as large as 2*maxOctantDim[n] - 1.
49  */
50  CPP11_auto_ptr<ArrayND<double> > scanSymmetricDensityAsWeight(
51  const AbsDistributionND& kernel, const unsigned* maxOctantDim,
52  const double* bandwidthSet, const double* stepSize,
53  unsigned arrayLength, bool fillOneOctantOnly = true);
54 
55 #ifdef SWIG
56  inline ArrayND<double>* scanSymmetricDensityAsWeight2(
57  const AbsDistributionND& kernel,
58  const unsigned* maxOctantDim, unsigned len1,
59  const double* bandwidthSet, unsigned len2,
60  const double* stepSize, unsigned len3,
61  const bool fillOneOctantOnly = true)
62  {
63  const unsigned dim = kernel.dim();
64  if (!dim || len1 != dim || len2 != dim || len3 != dim)
65  throw std::invalid_argument(
66  "In npstat::scanSymmetricDensityAsWeight2: "
67  "incompatible argument dimensions");
68  CPP11_auto_ptr<ArrayND<double> > p = scanSymmetricDensityAsWeight(
69  kernel, maxOctantDim, bandwidthSet, stepSize, dim, fillOneOctantOnly);
70  return p.release();
71  }
72 #endif // SWIG
73 }
74 
75 #endif // NPSTAT_SCANSYMMETRICDENSITYASWEIGHT_HH_
Interface definition for multivariate continuous statistical distributions.
Arbitrary-dimensional array template.
Definition: AbsDistributionND.hh:26
unsigned dim() const
Definition: AbsDistributionND.hh:51
Definition: AbsArrayProjector.hh:14
CPP11_auto_ptr< ArrayND< double > > scanSymmetricDensityAsWeight(const AbsDistributionND &kernel, const unsigned *maxOctantDim, const double *bandwidthSet, const double *stepSize, unsigned arrayLength, bool fillOneOctantOnly=true)