npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
ArrayShape.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_ARRAYSHAPE_HH_
2 #define NPSTAT_ARRAYSHAPE_HH_
3 
4 /*!
5 // \file ArrayShape.hh
6 //
7 // \brief Utilities for defining shapes of multidimensional arrays
8 //
9 // Author: I. Volobouev
10 //
11 // October 2009
12 */
13 
14 #include <vector>
15 
16 namespace npstat {
17  /**
18  // This type will be used to specify
19  // array length in each dimension
20  */
21  typedef std::vector<unsigned> ArrayShape;
22 
23  //@{
24  /**
25  // This convenience function will construct
26  // an array shape using an explicit list of indices
27  */
29  ArrayShape makeShape(unsigned i0);
30  ArrayShape makeShape(unsigned i0, unsigned i1);
31  ArrayShape makeShape(unsigned i0, unsigned i1, unsigned i2);
32  ArrayShape makeShape(unsigned i0, unsigned i1, unsigned i2, unsigned i3);
33  ArrayShape makeShape(unsigned i0, unsigned i1, unsigned i2, unsigned i3,
34  unsigned i4);
35  ArrayShape makeShape(unsigned i0, unsigned i1, unsigned i2, unsigned i3,
36  unsigned i4, unsigned i5);
37  ArrayShape makeShape(unsigned i0, unsigned i1, unsigned i2, unsigned i3,
38  unsigned i4, unsigned i5, unsigned i6);
39  ArrayShape makeShape(unsigned i0, unsigned i1, unsigned i2, unsigned i3,
40  unsigned i4, unsigned i5, unsigned i6, unsigned i7);
41  ArrayShape makeShape(unsigned i0, unsigned i1, unsigned i2, unsigned i3,
42  unsigned i4, unsigned i5, unsigned i6, unsigned i7,
43  unsigned i8);
44  ArrayShape makeShape(unsigned i0, unsigned i1, unsigned i2, unsigned i3,
45  unsigned i4, unsigned i5, unsigned i6, unsigned i7,
46  unsigned i8, unsigned i9);
47  ArrayShape makeShape(const unsigned* indices, unsigned nIndices);
48  //@}
49 
50  /** Multiply the size in each dimension by 2 */
51  ArrayShape doubleShape(const ArrayShape& inputShape);
52 
53  /** Divide the size in each dimension by 2 (generate dynamic fault if odd) */
54  ArrayShape halfShape(const ArrayShape& inputShape);
55 
56  /**
57  // This function returns true if the number of elements is
58  // the same in both vectors and every element of the first vector
59  // does not exceed corresponding element of the second
60  */
61  bool isSubShape(const ArrayShape& sh1, const ArrayShape& sh2);
62 
63  /** The number of elements in the array with the given shape */
64  unsigned long arrayLengthFromShape(const ArrayShape& sh);
65 }
66 
67 #endif // NPSTAT_ARRAYSHAPE_HH_
Definition: AbsArrayProjector.hh:14
ArrayShape halfShape(const ArrayShape &inputShape)
ArrayShape makeShape()
std::vector< unsigned > ArrayShape
Definition: ArrayShape.hh:21
bool isSubShape(const ArrayShape &sh1, const ArrayShape &sh2)
ArrayShape doubleShape(const ArrayShape &inputShape)
unsigned long arrayLengthFromShape(const ArrayShape &sh)