Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:19

0001 #ifndef NPSTAT_ARRAYSHAPE_HH_
0002 #define NPSTAT_ARRAYSHAPE_HH_
0003 
0004 /*!
0005 // \file ArrayShape.h
0006 //
0007 // \brief Utilities for defining shapes of multidimensional arrays
0008 //
0009 // Author: I. Volobouev
0010 //
0011 // October 2009
0012 */
0013 
0014 #include <vector>
0015 
0016 namespace npstat {
0017   /**
0018     // This type will be used to specify
0019     // array length in each dimension
0020     */
0021   typedef std::vector<unsigned> ArrayShape;
0022 
0023   //@{
0024   /**
0025     // This convenience function will construct
0026     // an array shape using an explicit list of indices
0027     */
0028   ArrayShape makeShape();
0029   ArrayShape makeShape(unsigned i0);
0030   ArrayShape makeShape(unsigned i0, unsigned i1);
0031   ArrayShape makeShape(unsigned i0, unsigned i1, unsigned i2);
0032   ArrayShape makeShape(unsigned i0, unsigned i1, unsigned i2, unsigned i3);
0033   ArrayShape makeShape(unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4);
0034   ArrayShape makeShape(unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5);
0035   ArrayShape makeShape(unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6);
0036   ArrayShape makeShape(
0037       unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7);
0038   ArrayShape makeShape(unsigned i0,
0039                        unsigned i1,
0040                        unsigned i2,
0041                        unsigned i3,
0042                        unsigned i4,
0043                        unsigned i5,
0044                        unsigned i6,
0045                        unsigned i7,
0046                        unsigned i8);
0047   ArrayShape makeShape(unsigned i0,
0048                        unsigned i1,
0049                        unsigned i2,
0050                        unsigned i3,
0051                        unsigned i4,
0052                        unsigned i5,
0053                        unsigned i6,
0054                        unsigned i7,
0055                        unsigned i8,
0056                        unsigned i9);
0057   ArrayShape makeShape(const unsigned* indices, unsigned nIndices);
0058   //@}
0059 
0060   /** Multiply the sise in each dimension by 2 */
0061   ArrayShape doubleShape(const ArrayShape& inputShape);
0062 
0063   /** Divide the size in each dimension by 2 (generate dynamic fault if odd) */
0064   ArrayShape halfShape(const ArrayShape& inputShape);
0065 
0066   /**
0067     // This function returns true if the number of elements is
0068     // the same in both vectors and every element of the first vector
0069     // does not exceed corresponding element of the second
0070     */
0071   bool isSubShape(const ArrayShape& sh1, const ArrayShape& sh2);
0072 }  // namespace npstat
0073 
0074 #endif  // NPSTAT_ARRAYSHAPE_HH_