CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
npstat::ArrayRange Struct Reference

#include <ArrayRange.h>

Inheritance diagram for npstat::ArrayRange:
npstat::BoxND< unsigned >

Public Member Functions

 ArrayRange ()
 
 ArrayRange (unsigned dim)
 
 ArrayRange (unsigned dim, const Interval< unsigned > &r1)
 
void lowerLimits (unsigned *limits, unsigned limitsLen) const
 
bool operator< (const ArrayRange &) const
 
void rangeLength (unsigned *range, unsigned rangeLen) const
 
unsigned long rangeSize () const
 
ArrayShape shape () const
 
ArrayRangestripOuterLayer ()
 
void upperLimits (unsigned *limits, unsigned limitsLen) const
 
 ArrayRange (const ArrayShape &shape)
 
 ArrayRange (const unsigned *shape, unsigned shapeLen)
 
bool isCompatible (const ArrayShape &shape) const
 
bool isCompatible (const unsigned *shape, unsigned shapeLen) const
 
- Public Member Functions inherited from npstat::BoxND< unsigned >
 BoxND ()
 
 BoxND (const unsigned long dim)
 
 BoxND (const unsigned long dim, const Interval< unsigned > &v)
 
 BoxND (const std::vector< Num2 > &limits)
 
 BoxND (const BoxND< Num2 > &r)
 
BoxNDcopyFrom (const BoxND< Num2 > &r)
 
unsigned long dim () const
 
BoxNDexpand (double r)
 
void getMidpoint (unsigned *coord, unsigned long coordLen) const
 
BoxNDmoveToOrigin ()
 
double overlapFraction (const BoxND &r) const
 
unsigned overlapVolume (const BoxND &r) const
 
unsigned volume () const
 
bool isInsideLower (const Num2 *coord, unsigned long coordLen) const
 
bool isInsideUpper (const Num2 *coord, unsigned long coordLen) const
 
bool isInsideWithBounds (const Num2 *coord, unsigned long coordLen) const
 
bool isInside (const Num2 *coord, unsigned long coordLen) const
 
BoxNDoperator*= (double r)
 
BoxNDoperator/= (double r)
 
BoxNDoperator*= (const std::vector< double > &scales)
 
BoxNDoperator/= (const std::vector< double > &scales)
 
BoxNDexpand (const std::vector< double > &scales)
 
BoxNDexpand (const double *scales, unsigned long lenScales)
 
BoxNDoperator+= (const std::vector< Num2 > &shifts)
 
BoxNDoperator-= (const std::vector< Num2 > &shifts)
 
BoxNDshift (const Num2 *shifts, unsigned long lenShifts)
 
gs::ClassId classId () const
 
bool write (std::ostream &of) const
 

Additional Inherited Members

- Static Public Member Functions inherited from npstat::BoxND< unsigned >
static BoxND allSpace (unsigned long ndim)
 
static const char * classname ()
 
static void restore (const gs::ClassId &id, std::istream &in, BoxND *box)
 
static BoxND sizeTwoBox (unsigned long ndim)
 
static BoxND unitBox (unsigned long ndim)
 
static unsigned version ()
 

Detailed Description

Utility class for use in certain array iterations

Definition at line 21 of file ArrayRange.h.

Constructor & Destructor Documentation

npstat::ArrayRange::ArrayRange ( )
inline

Definition at line 23 of file ArrayRange.h.

23 {}
npstat::ArrayRange::ArrayRange ( unsigned  dim)
inlineexplicit

Constructor from a given number of dimensions

Definition at line 26 of file ArrayRange.h.

26 : BoxND<unsigned>(dim) {}
unsigned long dim() const
Definition: BoxND.h:57
npstat::ArrayRange::ArrayRange ( unsigned  dim,
const Interval< unsigned > &  r1 
)
inline

The given interval is repeated for every dimension

Definition at line 29 of file ArrayRange.h.

30  : BoxND<unsigned>(dim, r1) {}
unsigned long dim() const
Definition: BoxND.h:57
npstat::ArrayRange::ArrayRange ( const ArrayShape shape)
inlineexplicit

Constructor which creates a range out of a shape which is used to represent the upper limit. The lower limit in each dimension is set to 0.

Definition at line 38 of file ArrayRange.h.

39  : BoxND<unsigned>(shape) {}
ArrayShape shape() const
Definition: ArrayRange.cc:90
npstat::ArrayRange::ArrayRange ( const unsigned *  shape,
unsigned  shapeLen 
)

Definition at line 5 of file ArrayRange.cc.

References assert(), and i.

6  {
7  if (imax)
8  {
9  assert(ishape);
10  this->reserve(imax);
11  for (unsigned i=0; i<imax; ++i)
12  this->push_back(Interval<unsigned>(ishape[i]));
13  }
14  }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())

Member Function Documentation

bool npstat::ArrayRange::isCompatible ( const ArrayShape shape) const

Check for compatibility with a shape

Definition at line 16 of file ArrayRange.cc.

Referenced by npstat::ArrayND< Numeric, StackLen, StackDim >::ArrayND().

17  {
18  const unsigned imax = ishape.size();
19  return isCompatible(imax ? &ishape[0] : (unsigned*)0, imax);
20  }
bool isCompatible(const ArrayShape &shape) const
Definition: ArrayRange.cc:16
bool npstat::ArrayRange::isCompatible ( const unsigned *  shape,
unsigned  shapeLen 
) const

Definition at line 22 of file ArrayRange.cc.

References assert(), i, bookConverter::max, and findQualityFiles::size.

24  {
25  if (this->size() != imax)
26  return false;
27  if (imax)
28  {
29  assert(ishape);
30  for (unsigned i=0; i<imax; ++i)
31  if ((*this)[i].length() == 0U)
32  return true;
33  for (unsigned i=0; i<imax; ++i)
34  if ((*this)[i].max() > ishape[i])
35  return false;
36  }
37  return true;
38  }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
tuple size
Write out results.
void npstat::ArrayRange::lowerLimits ( unsigned *  limits,
unsigned  limitsLen 
) const

Get the lower range limits into an array. The length of the limit array should be at least equal to the dimensionality.

Definition at line 99 of file ArrayRange.cc.

References assert(), data, i, min(), and findQualityFiles::size.

Referenced by npstat::ArrayND< Numeric, StackLen, StackDim >::ArrayND().

101  {
102  const unsigned imax = this->size();
103  if (limitsLen < imax) throw npstat::NpstatInvalidArgument(
104  "In npstat::ArrayRange::lowerLimits: "
105  "insufficient size of the output buffer");
106  if (imax)
107  {
108  assert(limits);
109  const Interval<unsigned>* data = &(*this)[0];
110  for (unsigned i=0; i<imax; ++i)
111  limits[i] = data[i].min();
112  }
113  }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
T min(T a, T b)
Definition: MathUtil.h:58
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
tuple size
Write out results.
bool npstat::ArrayRange::operator< ( const ArrayRange r) const

Operator for use with maps

Definition at line 40 of file ArrayRange.cc.

References i, npstat::Interval< Numeric >::max(), npstat::Interval< Numeric >::min(), and findQualityFiles::size.

41  {
42  const unsigned mysize = this->size();
43  const unsigned othersize = r.size();
44  if (mysize < othersize)
45  return true;
46  if (mysize > othersize)
47  return false;
48  for (unsigned i=0; i<mysize; ++i)
49  {
50  const Interval<unsigned>& left((*this)[i]);
51  const Interval<unsigned>& right(r[i]);
52  if (left.min() < right.min())
53  return true;
54  if (left.min() > right.min())
55  return false;
56  if (left.max() < right.max())
57  return true;
58  if (left.max() > right.max())
59  return false;
60  }
61  return false;
62  }
int i
Definition: DBlmapReader.cc:9
tuple size
Write out results.
void npstat::ArrayRange::rangeLength ( unsigned *  range,
unsigned  rangeLen 
) const

Get the range into an array

Definition at line 131 of file ArrayRange.cc.

References assert(), data, i, and findQualityFiles::size.

Referenced by npstat::ArrayND< Numeric, StackLen, StackDim >::ArrayND().

133  {
134  const unsigned imax = this->size();
135  if (limitsLen < imax) throw npstat::NpstatInvalidArgument(
136  "In npstat::ArrayRange::rangeLength: "
137  "insufficient size of the output buffer");
138  if (imax)
139  {
140  assert(limits);
141  const Interval<unsigned>* data = &(*this)[0];
142  for (unsigned i=0; i<imax; ++i)
143  limits[i] = data[i].length();
144  }
145  }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
tuple size
Write out results.
unsigned long npstat::ArrayRange::rangeSize ( ) const

How many elements will be iterated over?

Definition at line 77 of file ArrayRange.cc.

References i, mps_fire::result, and findQualityFiles::size.

Referenced by npstat::ArrayND< Numeric, StackLen, StackDim >::ArrayND().

78  {
79  unsigned long result = 0UL;
80  const unsigned imax = this->size();
81  if (imax)
82  {
83  result = 1UL;
84  for (unsigned i=0; i<imax; ++i)
85  result *= (*this)[i].length();
86  }
87  return result;
88  }
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: mps_fire.py:83
tuple size
Write out results.
ArrayShape npstat::ArrayRange::shape ( void  ) const

The shape which corresponds to this range (i.e., max - min in all dimensions)

Definition at line 90 of file ArrayRange.cc.

References i, and findQualityFiles::size.

91  {
92  const unsigned imax = this->size();
93  ArrayShape oshape(imax);
94  for (unsigned i=0; i<imax; ++i)
95  oshape[i] = (*this)[i].length();
96  return oshape;
97  }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple size
Write out results.
ArrayRange & npstat::ArrayRange::stripOuterLayer ( )

This method changes the range of this object so that for each dimension the minimum becomes larger by 1 and the maximum smaller by 1.

Definition at line 64 of file ArrayRange.cc.

References i, min(), and findQualityFiles::size.

65  {
66  const unsigned mysize = this->size();
67  for (unsigned i=0; i<mysize; ++i)
68  {
69  (*this)[i].setMin((*this)[i].min() + 1U);
70  const unsigned uplim = (*this)[i].max();
71  if (uplim)
72  (*this)[i].setMax(uplim - 1U);
73  }
74  return *this;
75  }
int i
Definition: DBlmapReader.cc:9
T min(T a, T b)
Definition: MathUtil.h:58
tuple size
Write out results.
void npstat::ArrayRange::upperLimits ( unsigned *  limits,
unsigned  limitsLen 
) const

Get the upper range limits into an array

Definition at line 115 of file ArrayRange.cc.

References assert(), data, i, bookConverter::max, and findQualityFiles::size.

117  {
118  const unsigned imax = this->size();
119  if (limitsLen < imax) throw npstat::NpstatInvalidArgument(
120  "In npstat::ArrayRange::upperLimits: "
121  "insufficient size of the output buffer");
122  if (imax)
123  {
124  assert(limits);
125  const Interval<unsigned>* data = &(*this)[0];
126  for (unsigned i=0; i<imax; ++i)
127  limits[i] = data[i].max();
128  }
129  }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
tuple size
Write out results.