Sierra Toolkit Version of the Day
FArray.hpp
Go to the documentation of this file.
00001 
00015 #ifndef STK_UTIL_DIAG_FArray_h
00016 #define STK_UTIL_DIAG_FArray_h
00017 
00018 #include <cstddef>
00019 #include <utility>
00020 #include <algorithm>
00021 #include <stdexcept>
00022 #include <typeinfo>
00023 #include <iterator>
00024 
00025 #include <stk_util/util/StaticAssert.hpp>
00026 
00027 #ifndef NDEBUG
00028 #  define SIERRA_ARRAY_BOUNDS_CHECK
00029 #endif
00030 
00031 namespace sierra {
00032 
00037 
00038 
00039 void
00040 array_dimension_error(
00041   const std::type_info &  typeinfo,
00042   unsigned      dimension,
00043   unsigned      value,
00044   unsigned      upper);
00045 
00046 
00077 template<class ElementType, int Dimension>
00078 class FArray;
00079 
00085 template<class ElementType, int Dimension, class A = std::allocator<ElementType> >
00086 class FArrayContainer;
00087 
00088 //----------------------------------------------------------------------
00089 //----------------------------------------------------------------------
00090 // Helpers
00091 
00092 template<unsigned N> struct ArrayHelper;
00093 
00094 //----------------------------------------------------------------------
00095 //----------------------------------------------------------------------
00096 
00097 template<>
00098 struct ArrayHelper<0>
00099 {
00100   template<typename T>
00101   inline static void fill(const T, T *)
00102   {}
00103 
00104   template<typename T>
00105   inline static void copy(const T *, T *)
00106   {}
00107 
00108   template<typename T>
00109   inline static void prefix(const T *, T *)
00110   {}
00111 
00112   inline static void get_index(const unsigned * const, unsigned *index, int offset) {
00113     index[0] = offset;
00114   }
00115 
00116   template<typename T>
00117   inline static T *index(T * ptr, const unsigned * const, const unsigned * const, const unsigned * const index) {
00118     return ptr + index[0];
00119   }
00120 };
00121 
00122 template<>
00123 struct ArrayHelper<1>
00124 {
00125   template<typename T>
00126   inline static bool equal(const T * x, const T * y) {
00127     return *x == *y;
00128   }
00129 
00130   template<typename T>
00131   inline static void fill(const T x, T * y) {
00132     *y = x;
00133   }
00134 
00135   template<typename T>
00136   inline static void copy(const T * x, T * y) {
00137     *y = *x;
00138   }
00139 
00140   template<typename T>
00141   inline static void prefix(const T * x, T * p) {
00142     *(p+1) = *p * *x;
00143   }
00144 
00145   template<typename T>
00146   static void copy(const unsigned * const dim,
00147        T       * a_ptr, const unsigned * const a_inc,
00148        T const * b_ptr, const unsigned * const b_inc)
00149   {
00150     const unsigned ia = *a_inc;
00151     const unsigned ib = *b_inc;
00152     T * const a_end = a_ptr + *dim * ia;
00153     while (a_end != a_ptr) {
00154       *a_ptr = *b_ptr;
00155       a_ptr += ia;
00156       b_ptr += ib;
00157     }
00158   }
00159 
00160   template<typename T>
00161   static void fill(const unsigned * const dim,
00162        T       * a_ptr, const unsigned * const a_inc,
00163        const T & value)
00164   {
00165     const unsigned ia = *a_inc;
00166     T * const a_end = a_ptr + *dim * ia;
00167     while (a_end != a_ptr) {
00168       *a_ptr = value;
00169       a_ptr += ia;
00170     }
00171   }
00172 
00173   template<typename T>
00174   static bool equal(const unsigned * const dim,
00175         const T * a_ptr, const unsigned * const a_inc,
00176         const T * b_ptr, const unsigned * const b_inc)
00177   {
00178     const unsigned ia = *a_inc;
00179     const unsigned ib = *b_inc;
00180     const T * const a_end = a_ptr + *dim * ia;
00181     bool result = true;
00182     while (a_end != a_ptr && (result = *a_ptr == *b_ptr)) {
00183       a_ptr += ia;
00184       b_ptr += ib;
00185     }
00186     return result;
00187   }
00188 
00189   inline static void get_index(const unsigned * const inc, unsigned *index, int offset) {
00190     index[1] = offset/inc[1];
00191     index[0] = offset%inc[1];
00192   }
00193 
00194   template<typename T>
00195   inline static T *index(T * ptr, const unsigned * const inc, const unsigned * const, const unsigned * const index) {
00196     return ptr + index[0] + index[1]*inc[1];
00197   }
00198 };
00199 
00200 
00201 template<unsigned N>
00202 struct ArrayHelper
00203 {
00204 private:
00205   typedef ArrayHelper<N-1> M;
00206 
00207 public:
00208   template<typename T>
00209   inline static bool equal(const T * x, const T * y) {
00210     return *x == *y && M::equal(x + 1, y + 1);
00211   }
00212 
00213   template<typename T>
00214   inline static void fill(const T x, T * y) {
00215     *y = x;
00216     M::fill(x, y+1);
00217   }
00218 
00219   template<typename T>
00220   inline static void copy(const T * x, T * y) {
00221     *y = *x;
00222     M::copy(x+1, y+1);
00223   }
00224 
00225   template<typename T>
00226   inline static void prefix(const T * x, T * p) {
00227     *(p+1) = *p * *x;
00228     M::prefix(x + 1, p + 1);
00229   }
00230 
00231   template<typename T>
00232   static void copy(const unsigned * const dim,
00233        T       * a_ptr, const unsigned * const a_inc,
00234        T const * b_ptr, const unsigned * const b_inc)
00235   {
00236     const unsigned ia = *a_inc;
00237     const unsigned ib = *b_inc;
00238     T * const a_end = a_ptr + *dim * ia;
00239     while (a_end != a_ptr) {
00240       M::copy(dim + 1, a_ptr, a_inc + 1, b_ptr, b_inc + 1);
00241       a_ptr += ia;
00242       b_ptr += ib;
00243     }
00244   }
00245 
00246   template<typename T>
00247   static void fill(const unsigned * const dim,
00248        T       * a_ptr, const unsigned * const a_inc,
00249        const T & value)
00250   {
00251     const unsigned ia = *a_inc;
00252     T * const a_end = a_ptr + *dim * ia;
00253     while (a_end != a_ptr) {
00254       M::fill(dim + 1, a_ptr, a_inc + 1, value);
00255       a_ptr += ia;
00256     }
00257   }
00258 
00259   template<typename T>
00260   static bool equal(const unsigned * const dim,
00261         const T * a_ptr, const unsigned * const a_inc,
00262         const T * b_ptr, const unsigned * const b_inc)
00263   {
00264     const unsigned ia = *a_inc;
00265     const unsigned ib = *b_inc;
00266     const T * const a_end = a_ptr + *dim * ia;
00267     bool result = true;
00268     while (a_end != a_ptr &&
00269      (result = M::equal(dim+1, a_ptr, a_inc+1, b_ptr, b_inc+1))){
00270       a_ptr += ia;
00271       b_ptr += ib;
00272     }
00273     return result;
00274   }
00275 
00276   inline static void get_index(const unsigned * const inc, unsigned *index, int offset) {
00277     index[N] = offset/inc[N];
00278     M::get_index(inc, index, offset%inc[N]);
00279   }
00280 
00281   template<typename T>
00282   inline static T *index(T * ptr, const unsigned * const inc, const unsigned * const dim, const unsigned * const index) {
00283     return M::index(ptr, inc, dim, index) + index[N]*inc[N];
00284   }
00285 };
00286 
00287 //----------------------------------------------------------------------
00288 // A typeless array is invalid...
00289 
00290 template<int Dimension>
00291 class FArray<void, Dimension> {};
00292 
00293 template <class ElementType>
00294 class FArray<ElementType, 0>
00295 {
00296 public:
00297   typedef ElementType value_type;
00298 
00299   typedef FArray<value_type, 0> SelfType;
00300 
00301   typedef FArray<const value_type, 0> Const;
00302 
00303   enum { NumDim = 0};
00304 };
00305 
00306 class FArrayBootstrap
00307 {
00308 public:
00309   ~FArrayBootstrap();
00310 };
00311 
00312 template<class ElementType, int Dimension>
00313 class FArray : public FArrayBootstrap
00314 {
00315 public:
00316   enum { NumDim = Dimension };
00317 
00318   typedef ElementType           value_type;
00319   typedef size_t                size_type;
00320   typedef ptrdiff_t             difference_type;
00321 
00322   typedef value_type *          pointer;
00323   typedef const value_type *    const_pointer;
00324   typedef value_type &          reference;
00325   typedef const value_type &    const_reference;
00326 
00327   typedef pointer               iterator;
00328   typedef const_pointer         const_iterator;
00329   typedef typename std::reverse_iterator<iterator> reverse_iterator;
00330   typedef typename std::reverse_iterator<const_iterator> const_reverse_iterator;
00331 
00332   typedef FArray<ElementType, Dimension> SelfType;
00333   typedef FArrayContainer<ElementType, Dimension> Container;
00334   typedef FArray<ElementType, Dimension - 1> Trunc;
00335 
00336   class Index
00337   {
00338   public:
00339     const unsigned &operator[](unsigned i) const {
00340       return m_index[i];
00341     }
00342 
00343     unsigned &operator[](unsigned i) {
00344       return m_index[i];
00345     }
00346 
00347   private:
00348     unsigned    m_index[NumDim];
00349   };
00350 
00351   const unsigned * dimension() const {
00352     return m_dim;
00353   }
00354 
00355   const unsigned * stride() const {
00356     return m_stride;
00357   }
00358 
00359 #ifdef SIERRA_ARRAY_BOUNDS_CHECK
00360   inline void array_dimension_verify(unsigned l_dimension, unsigned value, unsigned upper) const {
00361     if (value >= upper)
00362     {
00363       array_dimension_error(typeid(*this), l_dimension, value, upper);
00364     }
00365   }
00366 #else
00367   inline void array_dimension_verify(unsigned, unsigned, unsigned) const {}
00368 #endif
00369 
00370   template<unsigned I>
00371   unsigned dimension() const {
00372     enum { ok = stk::StaticAssert<I < NumDim>::OK };
00373     return m_dim[I];
00374   }
00375 
00376   template<unsigned I>
00377   unsigned stride() const {
00378     enum { ok = stk::StaticAssert<I < NumDim>::OK };
00379     return m_stride[I];
00380   }
00381 
00383   unsigned dimension(const unsigned i) const {
00384     array_dimension_verify(0, i, NumDim);
00385     return m_dim[i];
00386   }
00387 
00388   unsigned stride(const unsigned i) const {
00389     array_dimension_verify(0, i, NumDim);
00390     return m_stride[i];
00391   }
00392 
00393   unsigned size() const {
00394     return m_stride[NumDim];
00395   }
00396 
00397   //----------------------------------------
00398 
00399   bool operator==(const SelfType & a) const {
00400     return ArrayHelper<NumDim>::equal(m_dim, a.m_dim) &&
00401       ArrayHelper<NumDim>::equal(m_dim, m_ptr, m_stride, a.m_ptr, a.m_stride);
00402   }
00403 
00404   template<typename T>
00405   bool operator==(const FArray<T, Dimension> & a) const {
00406     return ArrayHelper<NumDim>::equal(m_dim, a.dimension()) &&
00407       ArrayHelper<NumDim>::equal(m_dim, m_ptr, m_stride, a.ptr(), a.stride());
00408   }
00409 
00410   bool operator!=(const SelfType & a) const {
00411     return ! operator==(a); }
00412 
00413   template<typename T>
00414   bool operator!=(const FArray<T, Dimension> & a) const {
00415     return ! operator==(a);
00416   }
00417 
00418   value_type &operator()(const Index &index) {
00419     for (unsigned i = 0; i < NumDim; ++i)
00420       array_dimension_verify(i, index[i], m_dim[i]);
00421 
00422     value_type *l_ptr = ArrayHelper<NumDim - 1>::index(m_ptr, m_stride, m_dim, &index[0]);
00423 
00424     return *l_ptr;
00425   }
00426 
00427   value_type & operator()(const unsigned i0, const unsigned i1,
00428           const unsigned i2, const unsigned i3,
00429           const unsigned i4, const unsigned i5,
00430           const unsigned i6, const unsigned i7)
00431   {
00432     enum { ok = stk::StaticAssert<8 == NumDim>::OK };
00433 
00434     array_dimension_verify(0, i0, m_dim[0]);
00435     array_dimension_verify(1, i1, m_dim[1]);
00436     array_dimension_verify(2, i2, m_dim[2]);
00437     array_dimension_verify(3, i3, m_dim[3]);
00438     array_dimension_verify(4, i4, m_dim[4]);
00439     array_dimension_verify(5, i5, m_dim[5]);
00440     array_dimension_verify(6, i6, m_dim[6]);
00441     array_dimension_verify(7, i7, m_dim[7]);
00442 
00443     return *(m_ptr +    i0 + m_stride[1] * i1 +
00444        m_stride[2] * i2 + m_stride[3] * i3 +
00445        m_stride[4] * i4 + m_stride[5] * i5 +
00446        m_stride[6] * i6 + m_stride[7] * i7);
00447   }
00448 
00449   value_type & operator()(const unsigned i0, const unsigned i1,
00450           const unsigned i2, const unsigned i3,
00451           const unsigned i4, const unsigned i5,
00452           const unsigned i6)
00453   {
00454     enum { ok = stk::StaticAssert<7 == NumDim>::OK };
00455 
00456     array_dimension_verify(0, i0, m_dim[0]);
00457     array_dimension_verify(1, i1, m_dim[1]);
00458     array_dimension_verify(2, i2, m_dim[2]);
00459     array_dimension_verify(3, i3, m_dim[3]);
00460     array_dimension_verify(4, i4, m_dim[4]);
00461     array_dimension_verify(5, i5, m_dim[5]);
00462     array_dimension_verify(6, i6, m_dim[6]);
00463 
00464     return *(m_ptr +    i0 + m_stride[1] * i1 +
00465        m_stride[2] * i2 + m_stride[3] * i3 +
00466        m_stride[4] * i4 + m_stride[5] * i5 +
00467        m_stride[6] * i6);
00468   }
00469 
00470   value_type & operator()(const unsigned i0, const unsigned i1,
00471           const unsigned i2, const unsigned i3,
00472           const unsigned i4, const unsigned i5)
00473   {
00474     enum { ok = stk::StaticAssert<6 == NumDim>::OK };
00475 
00476     array_dimension_verify(0, i0, m_dim[0]);
00477     array_dimension_verify(1, i1, m_dim[1]);
00478     array_dimension_verify(2, i2, m_dim[2]);
00479     array_dimension_verify(3, i3, m_dim[3]);
00480     array_dimension_verify(4, i4, m_dim[4]);
00481     array_dimension_verify(5, i5, m_dim[5]);
00482 
00483     return *(m_ptr +    i0 + m_stride[1] * i1 +
00484        m_stride[2] * i2 + m_stride[3] * i3 +
00485        m_stride[4] * i4 + m_stride[5] * i5);
00486   }
00487 
00488   value_type & operator()(const unsigned i0, const unsigned i1,
00489           const unsigned i2, const unsigned i3,
00490           const unsigned i4)
00491   {
00492     enum { ok = stk::StaticAssert<5 == NumDim>::OK };
00493 
00494     array_dimension_verify(0, i0, m_dim[0]);
00495     array_dimension_verify(1, i1, m_dim[1]);
00496     array_dimension_verify(2, i2, m_dim[2]);
00497     array_dimension_verify(3, i3, m_dim[3]);
00498     array_dimension_verify(4, i4, m_dim[4]);
00499 
00500     return *(m_ptr +    i0 + m_stride[1] * i1 +
00501        m_stride[2] * i2 + m_stride[3] * i3 +
00502        m_stride[4] * i4);
00503   }
00504 
00505   value_type & operator()(const unsigned i0, const unsigned i1,
00506           const unsigned i2, const unsigned i3)
00507   {
00508     enum { ok = stk::StaticAssert<4 == NumDim>::OK };
00509 
00510     array_dimension_verify(0, i0, m_dim[0]);
00511     array_dimension_verify(1, i1, m_dim[1]);
00512     array_dimension_verify(2, i2, m_dim[2]);
00513     array_dimension_verify(3, i3, m_dim[3]);
00514 
00515     return *(m_ptr +    i0 + m_stride[1] * i1 +
00516        m_stride[2] * i2 + m_stride[3] * i3);
00517   }
00518 
00519   value_type & operator()(const unsigned i0, const unsigned i1,
00520           const unsigned i2)
00521   {
00522     enum { ok = stk::StaticAssert<3 == NumDim>::OK };
00523 
00524     array_dimension_verify(0, i0, m_dim[0]);
00525     array_dimension_verify(1, i1, m_dim[1]);
00526     array_dimension_verify(2, i2, m_dim[2]);
00527 
00528     return *(m_ptr +    i0 + m_stride[1] * i1 +
00529        m_stride[2] * i2);
00530   }
00531 
00532   value_type & operator()(const unsigned i0, const unsigned i1) {
00533     enum { ok = stk::StaticAssert<2 == NumDim>::OK };
00534 
00535     array_dimension_verify(0, i0, m_dim[0]);
00536     array_dimension_verify(1, i1, m_dim[1]);
00537 
00538     return *(m_ptr +    i0 + m_stride[1] * i1);
00539   }
00540 
00541   value_type & operator()(const unsigned i0) {
00542     enum { ok = stk::StaticAssert<1 == NumDim>::OK };
00543 
00544     array_dimension_verify(0, i0, m_dim[0]);
00545 
00546     return *(m_ptr +    i0);
00547   }
00548 
00549   value_type * ptr() {
00550     return m_ptr;
00551   }
00552 
00553   value_type & operator[](unsigned i) {
00554     array_dimension_verify(0, i, m_stride[NumDim]);
00555     return m_ptr[i];
00556   }
00557 
00558   const value_type &operator()(const Index &index) const {
00559     for (unsigned i = 0; i < NumDim; ++i)
00560       array_dimension_verify(i, index[i], m_dim[i]);
00561 
00562     const value_type *l_ptr = ArrayHelper<NumDim - 1>::index(m_ptr, m_stride, m_dim, &index[0]);
00563 
00564     return *l_ptr;
00565   }
00566 
00567   const value_type & operator()(const unsigned i0, const unsigned i1,
00568           const unsigned i2, const unsigned i3,
00569           const unsigned i4, const unsigned i5,
00570           const unsigned i6, const unsigned i7) const
00571   {
00572     enum { ok = stk::StaticAssert<8 == NumDim>::OK };
00573 
00574     array_dimension_verify(0, i0, m_dim[0]);
00575     array_dimension_verify(1, i1, m_dim[1]);
00576     array_dimension_verify(2, i2, m_dim[2]);
00577     array_dimension_verify(3, i3, m_dim[3]);
00578     array_dimension_verify(4, i4, m_dim[4]);
00579     array_dimension_verify(5, i5, m_dim[5]);
00580     array_dimension_verify(6, i6, m_dim[6]);
00581     array_dimension_verify(7, i7, m_dim[7]);
00582 
00583     return *(m_ptr +    i0 + m_stride[1] * i1 +
00584        m_stride[2] * i2 + m_stride[3] * i3 +
00585        m_stride[4] * i4 + m_stride[5] * i5 +
00586        m_stride[6] * i6 + m_stride[7] * i7);
00587   }
00588 
00589   const value_type & operator()(const unsigned i0, const unsigned i1,
00590           const unsigned i2, const unsigned i3,
00591           const unsigned i4, const unsigned i5,
00592           const unsigned i6) const
00593   {
00594     enum { ok = stk::StaticAssert<7 == NumDim>::OK };
00595 
00596     array_dimension_verify(0, i0, m_dim[0]);
00597     array_dimension_verify(1, i1, m_dim[1]);
00598     array_dimension_verify(2, i2, m_dim[2]);
00599     array_dimension_verify(3, i3, m_dim[3]);
00600     array_dimension_verify(4, i4, m_dim[4]);
00601     array_dimension_verify(5, i5, m_dim[5]);
00602     array_dimension_verify(6, i6, m_dim[6]);
00603 
00604     return *(m_ptr +    i0 + m_stride[1] * i1 +
00605        m_stride[2] * i2 + m_stride[3] * i3 +
00606        m_stride[4] * i4 + m_stride[5] * i5 +
00607        m_stride[6] * i6);
00608   }
00609 
00610   const value_type & operator()(const unsigned i0, const unsigned i1,
00611           const unsigned i2, const unsigned i3,
00612           const unsigned i4, const unsigned i5) const
00613   {
00614     enum { ok = stk::StaticAssert<6 == NumDim>::OK };
00615 
00616     array_dimension_verify(0, i0, m_dim[0]);
00617     array_dimension_verify(1, i1, m_dim[1]);
00618     array_dimension_verify(2, i2, m_dim[2]);
00619     array_dimension_verify(3, i3, m_dim[3]);
00620     array_dimension_verify(4, i4, m_dim[4]);
00621     array_dimension_verify(5, i5, m_dim[5]);
00622 
00623     return *(m_ptr +    i0 + m_stride[1] * i1 +
00624        m_stride[2] * i2 + m_stride[3] * i3 +
00625        m_stride[4] * i4 + m_stride[5] * i5);
00626   }
00627 
00628   const value_type & operator()(const unsigned i0, const unsigned i1,
00629           const unsigned i2, const unsigned i3,
00630           const unsigned i4) const
00631   {
00632     enum { ok = stk::StaticAssert<5 == NumDim>::OK };
00633 
00634     array_dimension_verify(0, i0, m_dim[0]);
00635     array_dimension_verify(1, i1, m_dim[1]);
00636     array_dimension_verify(2, i2, m_dim[2]);
00637     array_dimension_verify(3, i3, m_dim[3]);
00638     array_dimension_verify(4, i4, m_dim[4]);
00639 
00640     return *(m_ptr +    i0 + m_stride[1] * i1 +
00641        m_stride[2] * i2 + m_stride[3] * i3 +
00642        m_stride[4] * i4);
00643   }
00644 
00645   const value_type & operator()(const unsigned i0, const unsigned i1,
00646           const unsigned i2, const unsigned i3) const
00647   {
00648     enum { ok = stk::StaticAssert<4 == NumDim>::OK };
00649 
00650     array_dimension_verify(0, i0, m_dim[0]);
00651     array_dimension_verify(1, i1, m_dim[1]);
00652     array_dimension_verify(2, i2, m_dim[2]);
00653     array_dimension_verify(3, i3, m_dim[3]);
00654 
00655     return *(m_ptr +    i0 + m_stride[1] * i1 +
00656        m_stride[2] * i2 + m_stride[3] * i3);
00657   }
00658 
00659   const value_type & operator()(const unsigned i0, const unsigned i1,
00660           const unsigned i2) const
00661   {
00662     enum { ok = stk::StaticAssert<3 == NumDim>::OK };
00663 
00664     array_dimension_verify(0, i0, m_dim[0]);
00665     array_dimension_verify(1, i1, m_dim[1]);
00666     array_dimension_verify(2, i2, m_dim[2]);
00667 
00668     return *(m_ptr +    i0 + m_stride[1] * i1 +
00669        m_stride[2] * i2);
00670   }
00671 
00672   const value_type & operator()(const unsigned i0, const unsigned i1) const {
00673     enum { ok = stk::StaticAssert<2 == NumDim>::OK };
00674 
00675     array_dimension_verify(0, i0, m_dim[0]);
00676     array_dimension_verify(1, i1, m_dim[1]);
00677 
00678     return *(m_ptr +    i0 + m_stride[1] * i1);
00679   }
00680 
00681   const value_type & operator()(const unsigned i0) const {
00682     enum { ok = stk::StaticAssert<1 == NumDim>::OK };
00683 
00684     array_dimension_verify(0, i0, m_dim[0]);
00685 
00686     return *(m_ptr +    i0);
00687   }
00688 
00689   value_type * ptr() const {
00690     return m_ptr;
00691   }
00692 
00693   const value_type & operator[](unsigned i) const {
00694     array_dimension_verify(0, i, m_stride[NumDim]);
00695     return m_ptr[i];
00696   }
00697 
00698   //----------------------------------------
00699 
00700   bool verify_dimension(const unsigned n0, const unsigned n1,
00701       const unsigned n2, const unsigned n3,
00702       const unsigned n4, const unsigned n5,
00703       const unsigned n6, const unsigned n7) const
00704   {
00705     enum { ok = stk::StaticAssert<8 == NumDim>::OK };
00706     return m_dim[0] == n0 && m_dim[1] == n1 &&
00707       m_dim[2] == n2 && m_dim[3] == n3 &&
00708       m_dim[4] == n4 && m_dim[5] == n5 &&
00709       m_dim[6] == n6 && m_dim[7] == n7;
00710   }
00711 
00712   bool verify_dimension(const unsigned n0, const unsigned n1,
00713       const unsigned n2, const unsigned n3,
00714       const unsigned n4, const unsigned n5,
00715       const unsigned n6) const
00716   {
00717     enum { ok = stk::StaticAssert<7 == NumDim>::OK };
00718     return m_dim[0] == n0 && m_dim[1] == n1 &&
00719       m_dim[2] == n2 && m_dim[3] == n3 &&
00720       m_dim[4] == n4 && m_dim[5] == n5 &&
00721       m_dim[6] == n6;
00722   }
00723 
00724   bool verify_dimension(const unsigned n0, const unsigned n1,
00725       const unsigned n2, const unsigned n3,
00726       const unsigned n4, const unsigned n5) const
00727   {
00728     enum { ok = stk::StaticAssert<6 == NumDim>::OK };
00729     return m_dim[0] == n0 && m_dim[1] == n1 &&
00730       m_dim[2] == n2 && m_dim[3] == n3 &&
00731       m_dim[4] == n4 && m_dim[5] == n5;
00732   }
00733 
00734   bool verify_dimension(const unsigned n0, const unsigned n1,
00735       const unsigned n2, const unsigned n3,
00736       const unsigned n4) const
00737   {
00738     enum { ok = stk::StaticAssert<5 == NumDim>::OK };
00739     return m_dim[0] == n0 && m_dim[1] == n1 &&
00740       m_dim[2] == n2 && m_dim[3] == n3 &&
00741       m_dim[4] == n4;
00742   }
00743 
00744   bool verify_dimension(const unsigned n0, const unsigned n1,
00745       const unsigned n2, const unsigned n3) const
00746   {
00747     enum { ok = stk::StaticAssert<4 == NumDim>::OK };
00748     return m_dim[0] == n0 && m_dim[1] == n1 &&
00749       m_dim[2] == n2 && m_dim[3] == n3;
00750   }
00751 
00752   bool verify_dimension(const unsigned n0, const unsigned n1,
00753       const unsigned n2) const
00754   {
00755     enum { ok = stk::StaticAssert<3 == NumDim>::OK };
00756     return m_dim[0] == n0 && m_dim[1] == n1 &&
00757       m_dim[2] == n2;
00758   }
00759 
00760   bool verify_dimension(const unsigned n0, const unsigned n1) const {
00761     enum { ok = stk::StaticAssert<2 == NumDim>::OK };
00762     return m_dim[0] == n0 && m_dim[1] == n1;
00763   }
00764 
00765   bool verify_dimension(const unsigned n0) const {
00766     enum { ok = stk::StaticAssert<1 == NumDim>::OK };
00767     return m_dim[0] == n0;
00768   }
00769 
00770   unsigned set_dim(const unsigned d[]) {
00771     m_stride[0] = 1;
00772     ArrayHelper<NumDim>::copy(d, m_dim);
00773     ArrayHelper<NumDim>::prefix(d, m_stride);
00774     return m_stride[NumDim];
00775   }
00776 
00777   unsigned set_dim(const unsigned n0, const unsigned n1,
00778        const unsigned n2, const unsigned n3,
00779        const unsigned n4, const unsigned n5,
00780        const unsigned n6, const unsigned n7)
00781   {
00782     enum { ok = stk::StaticAssert<8 == NumDim>::OK };
00783 
00784     m_stride[0] = 1;
00785     m_stride[1] = m_stride[0] * (m_dim[0] = n0);
00786     m_stride[2] = m_stride[1] * (m_dim[1] = n1);
00787     m_stride[3] = m_stride[2] * (m_dim[2] = n2);
00788     m_stride[4] = m_stride[3] * (m_dim[3] = n3);
00789     m_stride[5] = m_stride[4] * (m_dim[4] = n4);
00790     m_stride[6] = m_stride[5] * (m_dim[5] = n5);
00791     m_stride[7] = m_stride[6] * (m_dim[6] = n6);
00792     m_stride[8] = m_stride[7] * (m_dim[7] = n7);
00793     return m_stride[NumDim];
00794   }
00795 
00796   unsigned set_dim(const unsigned n0, const unsigned n1,
00797        const unsigned n2, const unsigned n3,
00798        const unsigned n4, const unsigned n5,
00799        const unsigned n6)
00800   {
00801     enum { ok = stk::StaticAssert<7 == NumDim>::OK };
00802 
00803     m_stride[0] = 1;
00804     m_stride[1] = m_stride[0] * (m_dim[0] = n0);
00805     m_stride[2] = m_stride[1] * (m_dim[1] = n1);
00806     m_stride[3] = m_stride[2] * (m_dim[2] = n2);
00807     m_stride[4] = m_stride[3] * (m_dim[3] = n3);
00808     m_stride[5] = m_stride[4] * (m_dim[4] = n4);
00809     m_stride[6] = m_stride[5] * (m_dim[5] = n5);
00810     m_stride[7] = m_stride[6] * (m_dim[6] = n6);
00811     return m_stride[NumDim];
00812   }
00813 
00814   unsigned set_dim(const unsigned n0, const unsigned n1,
00815        const unsigned n2, const unsigned n3,
00816        const unsigned n4, const unsigned n5)
00817   {
00818     enum { ok = stk::StaticAssert<6 == NumDim>::OK };
00819 
00820     m_stride[0] = 1;
00821     m_stride[1] = m_stride[0] * (m_dim[0] = n0);
00822     m_stride[2] = m_stride[1] * (m_dim[1] = n1);
00823     m_stride[3] = m_stride[2] * (m_dim[2] = n2);
00824     m_stride[4] = m_stride[3] * (m_dim[3] = n3);
00825     m_stride[5] = m_stride[4] * (m_dim[4] = n4);
00826     m_stride[6] = m_stride[5] * (m_dim[5] = n5);
00827     return m_stride[NumDim];
00828   }
00829 
00830   unsigned set_dim(const unsigned n0, const unsigned n1,
00831        const unsigned n2, const unsigned n3,
00832        const unsigned n4)
00833   {
00834     enum { ok = stk::StaticAssert<5 == NumDim>::OK };
00835 
00836     m_stride[0] = 1;
00837     m_stride[1] = m_stride[0] * (m_dim[0] = n0);
00838     m_stride[2] = m_stride[1] * (m_dim[1] = n1);
00839     m_stride[3] = m_stride[2] * (m_dim[2] = n2);
00840     m_stride[4] = m_stride[3] * (m_dim[3] = n3);
00841     m_stride[5] = m_stride[4] * (m_dim[4] = n4);
00842     return m_stride[NumDim];
00843   }
00844 
00845   unsigned set_dim(const unsigned n0, const unsigned n1,
00846        const unsigned n2, const unsigned n3)
00847   {
00848     enum { ok = stk::StaticAssert<4 == NumDim>::OK };
00849 
00850     m_stride[0] = 1;
00851     m_stride[1] = m_stride[0] * (m_dim[0] = n0);
00852     m_stride[2] = m_stride[1] * (m_dim[1] = n1);
00853     m_stride[3] = m_stride[2] * (m_dim[2] = n2);
00854     m_stride[4] = m_stride[3] * (m_dim[3] = n3);
00855     return m_stride[NumDim];
00856   }
00857 
00858   unsigned set_dim(const unsigned n0, const unsigned n1,
00859        const unsigned n2)
00860   {
00861     enum { ok = stk::StaticAssert<3 == NumDim>::OK };
00862 
00863     m_stride[0] = 1;
00864     m_stride[1] = m_stride[0] * (m_dim[0] = n0);
00865     m_stride[2] = m_stride[1] * (m_dim[1] = n1);
00866     m_stride[3] = m_stride[2] * (m_dim[2] = n2);
00867     return m_stride[NumDim];
00868   }
00869 
00870   unsigned set_dim(const unsigned n0, const unsigned n1)
00871   {
00872     enum { ok = stk::StaticAssert<2 == NumDim>::OK };
00873 
00874     m_stride[0] = 1;
00875     m_stride[1] = m_stride[0] * (m_dim[0] = n0);
00876     m_stride[2] = m_stride[1] * (m_dim[1] = n1);
00877     return m_stride[NumDim];
00878   }
00879 
00880   unsigned set_dim(const unsigned n0)
00881   {
00882     enum { ok = stk::StaticAssert<1 == NumDim>::OK };
00883 
00884     m_stride[0] = 1;
00885     m_stride[1] = m_stride[0] * (m_dim[0] = n0);
00886     return m_stride[NumDim];
00887   }
00888 
00889   unsigned set_dim(const SelfType & a)
00890   {
00891     ArrayHelper<NumDim>::copy(a.m_dim, m_dim);
00892     ArrayHelper<NumDim+1>::copy(a.m_stride, m_stride);
00893     return m_stride[NumDim];
00894   }
00895 
00896 public:
00897   ~FArray()
00898   {
00899     m_ptr = NULL;
00900     ArrayHelper<NumDim>::fill((unsigned) 0, m_dim);
00901     ArrayHelper<NumDim+1>::fill((unsigned) 0, m_stride);
00902   }
00903 
00904   FArray()
00905     : m_ptr(NULL)
00906   {
00907     ArrayHelper<NumDim>::fill((unsigned) 0, m_dim);
00908     ArrayHelper<NumDim+1>::fill((unsigned) 0, m_stride);
00909   }
00910 
00911   FArray(const SelfType & a)
00912     : m_ptr(a.m_ptr)
00913   {
00914     ArrayHelper<NumDim>::copy(a.m_dim, m_dim);
00915     ArrayHelper<NumDim+1>::copy(a.m_stride, m_stride);
00916   }
00917 
00918   SelfType & operator=(SelfType const & a)
00919   {
00920     if (this != &a) {
00921 
00922       m_ptr = a.m_ptr;
00923 
00924       ArrayHelper<NumDim>::copy(a.m_dim, m_dim);
00925       ArrayHelper<NumDim+1>::copy(a.m_stride, m_stride);
00926     }
00927     return *this;
00928   }
00929 
00930   template<typename T>
00931   FArray(const FArray<T, Dimension> & a)
00932     : m_ptr(a.ptr())
00933   {
00934     ArrayHelper<NumDim>::copy(a.dimension(), m_dim);
00935     ArrayHelper<NumDim+1>::copy(a.stride(), m_stride);
00936   }
00937 
00938   FArray(value_type * const l_ptr,
00939    const unsigned n0, const unsigned n1,
00940    const unsigned n2, const unsigned n3,
00941    const unsigned n4, const unsigned n5,
00942    const unsigned n6, const unsigned n7)
00943     : m_ptr(l_ptr)
00944   {
00945     set_dim(n0, n1, n2, n3, n4, n5, n6, n7);
00946   }
00947 
00948   FArray(value_type * const l_ptr,
00949    const unsigned n0, const unsigned n1,
00950    const unsigned n2, const unsigned n3,
00951    const unsigned n4, const unsigned n5,
00952    const unsigned n6)
00953     : m_ptr(l_ptr)
00954   {
00955     set_dim(n0, n1, n2, n3, n4, n5, n6);
00956   }
00957 
00958   FArray(value_type * const l_ptr,
00959    const unsigned n0, const unsigned n1,
00960    const unsigned n2, const unsigned n3,
00961    const unsigned n4, const unsigned n5)
00962     : m_ptr(l_ptr)
00963   {
00964     set_dim(n0, n1, n2, n3, n4, n5);
00965   }
00966 
00967   FArray(value_type * const l_ptr,
00968    const unsigned n0, const unsigned n1,
00969    const unsigned n2, const unsigned n3,
00970    const unsigned n4)
00971     : m_ptr(l_ptr)
00972   {
00973     set_dim(n0, n1, n2, n3, n4);
00974   }
00975 
00976   FArray(value_type * const l_ptr,
00977    const unsigned n0, const unsigned n1,
00978    const unsigned n2, const unsigned n3)
00979     : m_ptr(l_ptr)
00980   {
00981     set_dim(n0, n1, n2, n3);
00982   }
00983 
00984   FArray(value_type * const l_ptr,
00985    const unsigned n0, const unsigned n1,
00986    const unsigned n2)
00987     : m_ptr(l_ptr)
00988   {
00989     set_dim(n0, n1, n2);
00990   }
00991 
00992   FArray(value_type * const l_ptr,
00993    const unsigned n0, const unsigned n1)
00994     : m_ptr(l_ptr)
00995   {
00996     set_dim(n0, n1);
00997   }
00998 
00999   FArray(value_type * const l_ptr,
01000    const unsigned n0)
01001     : m_ptr(l_ptr)
01002   {
01003     set_dim(n0);
01004   }
01005 
01006   FArray(value_type * const l_ptr,
01007    const unsigned n[NumDim])
01008     : m_ptr(l_ptr)
01009   {
01010     set_dim(n);
01011   }
01012 
01013   void set(const SelfType & a) {
01014     m_ptr = a.m_ptr;
01015 
01016     ArrayHelper<NumDim>::copy(a.m_dim, m_dim);
01017     ArrayHelper<NumDim+1>::copy(a.m_stride, m_stride);
01018   }
01019 
01020   void set(value_type * const l_ptr,
01021      const unsigned n0, const unsigned n1,
01022      const unsigned n2, const unsigned n3,
01023      const unsigned n4, const unsigned n5,
01024      const unsigned n6, const unsigned n7)
01025   {
01026     m_ptr = l_ptr;
01027     set_dim(n0, n1, n2, n3, n4, n5, n6, n7);
01028   }
01029 
01030   void set(value_type * const l_ptr,
01031      const unsigned n0, const unsigned n1,
01032      const unsigned n2, const unsigned n3,
01033      const unsigned n4, const unsigned n5,
01034      const unsigned n6)
01035   {
01036     m_ptr = l_ptr;
01037     set_dim(n0, n1, n2, n3, n4, n5, n6);
01038   }
01039 
01040   void set(value_type * const l_ptr,
01041      const unsigned n0, const unsigned n1,
01042      const unsigned n2, const unsigned n3,
01043      const unsigned n4, const unsigned n5)
01044   {
01045     m_ptr = l_ptr;
01046     set_dim(n0, n1, n2, n3, n4, n5);
01047   }
01048 
01049   void set(value_type * const l_ptr,
01050      const unsigned n0, const unsigned n1,
01051      const unsigned n2, const unsigned n3,
01052      const unsigned n4) {
01053     m_ptr = l_ptr;
01054     set_dim(n0, n1, n2, n3, n4);
01055   }
01056 
01057   void set(value_type * const l_ptr,
01058      const unsigned n0, const unsigned n1,
01059      const unsigned n2, const unsigned n3)
01060   {
01061     m_ptr = l_ptr;
01062     set_dim(n0, n1, n2, n3);
01063   }
01064 
01065   void set(value_type * const l_ptr,
01066      const unsigned n0, const unsigned n1,
01067      const unsigned n2)
01068   {
01069     m_ptr = l_ptr;
01070     set_dim(n0, n1, n2);
01071   }
01072 
01073   void set(value_type * const l_ptr,
01074      const unsigned n0, const unsigned n1) {
01075     m_ptr = l_ptr;
01076     set_dim(n0, n1);
01077   }
01078 
01079   void set(value_type * const l_ptr,
01080      const unsigned n0) {
01081     m_ptr = l_ptr;
01082     set_dim(n0);
01083   }
01084 
01085   void set(value_type * const l_ptr,
01086      const unsigned n[NumDim]) {
01087     m_ptr = l_ptr;
01088     set_dim(n);
01089   }
01090 
01091   Trunc dive(int i) {
01092     array_dimension_verify(0, i, m_dim[NumDim - 1]);
01093 
01094     value_type *l_ptr = m_ptr + i*m_stride[NumDim - 1];
01095 
01096     return Trunc(l_ptr, m_dim);
01097   }
01098 
01099   const Trunc dive(int i) const {
01100     array_dimension_verify(0, i, m_dim[NumDim - 1]);
01101 
01102     value_type *l_ptr = m_ptr + i*m_stride[NumDim - 1];
01103 
01104     return Trunc(l_ptr, m_dim);
01105   }
01106 
01107   iterator begin() {
01108     return m_ptr;
01109   }
01110 
01111   iterator end() {
01112     return m_ptr + m_stride[NumDim];
01113   }
01114 
01115   const_iterator begin() const {
01116     return m_ptr;
01117   }
01118 
01119   const_iterator end() const {
01120     return m_ptr + m_stride[NumDim];
01121   }
01122 
01123   void dimensions(const_iterator it, Index &index) const {
01124     ArrayHelper<NumDim - 1>::get_index(m_stride, &index[0], it - m_ptr);
01125   }
01126 
01127   //----------------------------------------
01128   // Copy contents of a compatible array
01129 
01130   template<typename T>
01131   void copy(const FArray<T, Dimension> & a) {
01132     ArrayHelper<NumDim>::copy(m_dim, m_ptr, m_stride, a.ptr(), a.stride());
01133   }
01134 
01135   template<typename T>
01136   void fill(const T & value) {
01137     ArrayHelper<NumDim>::fill(m_dim, m_ptr, m_stride, value);
01138   }
01139 
01140 private:
01141   // Mutation (non-const methods) is not allowed so as to
01142   // provide derived classes with complete control over mutation.
01143 
01144 protected:
01145   value_type *          m_ptr;
01146   unsigned    m_dim[NumDim];
01147   unsigned    m_stride[NumDim + 1];
01148 };
01149 
01150 
01151 template<class ElementType, int Dimension, class A>
01152 class FArrayContainer
01153   : public FArray<ElementType, Dimension>
01154 {
01155 public:
01156 //  typedef typename FArray<ElementType, Dimension>::value_type value_type;
01157 
01158   typedef typename A::value_type value_type;
01159   typedef typename A::size_type size_type;
01160   typedef typename A::difference_type difference_type;
01161 
01162   typedef typename A::pointer pointer;
01163   typedef typename A::const_pointer const_pointer;
01164   typedef typename A::reference reference;
01165   typedef typename A::const_reference const_reference;
01166 
01167   typedef typename A::pointer iterator;
01168   typedef typename A::const_pointer const_iterator;
01169 
01170   typedef typename std::reverse_iterator<iterator> reverse_iterator;
01171   typedef typename std::reverse_iterator<const_iterator> const_reverse_iterator;
01172 
01173   typedef FArrayContainer<ElementType, Dimension> SelfType;
01174 
01175   typedef FArray<ElementType, Dimension> BaseType;
01176 
01177 //  typedef typename BaseType::value_type value_type;
01178 
01179   enum { NumDim = BaseType::NumDim };
01180 
01181 private:
01182   using BaseType::m_ptr;
01183   using BaseType::m_dim;
01184   using BaseType::m_stride;
01185 
01186   void resize_memory(const unsigned new_size) {
01187     if (m_capacity < new_size) {
01188       if ( m_capacity )
01189         m_allocator.deallocate(m_ptr, m_capacity);
01190       m_capacity = new_size;
01191       m_ptr = m_allocator.allocate(m_capacity);
01192     }
01193   }
01194 
01195 public:
01196   ~FArrayContainer() {
01197     if (m_capacity) {
01198       m_allocator.deallocate(m_ptr, m_capacity);
01199       m_capacity = 0;
01200     }
01201   }
01202 
01203   //----------------------------------------
01204   // Constructors for initial view of contiguous memory.
01205 
01206   FArrayContainer()
01207     : BaseType(),
01208       m_capacity(0)
01209   {}
01210 
01211   FArrayContainer(const SelfType & a)
01212     : BaseType(),
01213       m_capacity(0)
01214   {
01215     resize_memory(BaseType::set_dim(a.m_dim));
01216     this->copy(a);
01217   }
01218 
01219   template<typename T>
01220   FArrayContainer(const FArray<T, Dimension> & a)
01221     : BaseType(),
01222       m_capacity(0)
01223   {
01224     resize_memory(BaseType::set_dim(a.dimension()));
01225     this->copy(a);
01226   }
01227 
01228   SelfType & operator=(const SelfType & a)
01229   {
01230     resize_memory(BaseType::set_dim(a.dimension()));
01231     this->copy(a);
01232     return *this;
01233   }
01234 
01235   template<typename T>
01236   SelfType & operator=(const FArray<T, Dimension> & a)
01237   {
01238     resize_memory(BaseType::set_dim(a.dimension()));
01239     this->copy(a);
01240     return *this;
01241   }
01242 
01243   //----------------------------------------
01244 
01245   FArrayContainer(const unsigned n0, const unsigned n1,
01246       const unsigned n2, const unsigned n3,
01247       const unsigned n4, const unsigned n5,
01248       const unsigned n6, const unsigned n7)
01249     : BaseType(NULL, n0, n1, n2, n3, n4, n5, n6, n7),
01250       m_capacity(0)
01251   {
01252     resize_memory(m_stride[NumDim]);
01253     std::fill(m_ptr, m_ptr + m_stride[NumDim], 0);
01254   }
01255 
01256   FArrayContainer(const unsigned n0, const unsigned n1,
01257       const unsigned n2, const unsigned n3,
01258       const unsigned n4, const unsigned n5,
01259       const unsigned n6)
01260     : BaseType(NULL, n0, n1, n2, n3, n4, n5, n6),
01261       m_capacity(0)
01262   {
01263     resize_memory(m_stride[NumDim]);
01264     std::fill(m_ptr, m_ptr + m_stride[NumDim], 0);
01265   }
01266 
01267 
01268   FArrayContainer(const unsigned n0, const unsigned n1,
01269       const unsigned n2, const unsigned n3,
01270       const unsigned n4, const unsigned n5)
01271     : BaseType(NULL, n0, n1, n2, n3, n4, n5),
01272       m_capacity(0)
01273   {
01274     resize_memory(m_stride[NumDim]);
01275     std::fill(m_ptr, m_ptr + m_stride[NumDim], 0);
01276   }
01277 
01278 
01279   FArrayContainer(const unsigned n0, const unsigned n1,
01280       const unsigned n2, const unsigned n3,
01281       const unsigned n4)
01282     : BaseType(NULL, n0, n1, n2, n3, n4),
01283       m_capacity(0)
01284   {
01285     resize_memory(m_stride[NumDim]);
01286     std::fill(m_ptr, m_ptr + m_stride[NumDim], 0);
01287   }
01288 
01289 
01290   FArrayContainer(const unsigned n0, const unsigned n1,
01291       const unsigned n2, const unsigned n3)
01292     : BaseType(NULL, n0, n1, n2, n3),
01293       m_capacity(0)
01294   {
01295     resize_memory(m_stride[NumDim]);
01296     std::fill(m_ptr, m_ptr + m_stride[NumDim], 0);
01297   }
01298 
01299 
01300   FArrayContainer(const unsigned n0, const unsigned n1,
01301       const unsigned n2)
01302     : BaseType(NULL, n0, n1, n2),
01303       m_capacity(0)
01304   {
01305     resize_memory(m_stride[NumDim]);
01306     std::fill(m_ptr, m_ptr + m_stride[NumDim], 0);
01307   }
01308 
01309 
01310   FArrayContainer(const unsigned n0, const unsigned n1)
01311     : BaseType(NULL, n0, n1),
01312       m_capacity(0)
01313   {
01314     resize_memory(m_stride[NumDim]);
01315     std::fill(m_ptr, m_ptr + m_stride[NumDim], 0);
01316   }
01317 
01318 
01319   FArrayContainer(const unsigned n0)
01320     : BaseType(NULL, n0),
01321       m_capacity(0)
01322   {
01323     resize_memory(m_stride[NumDim]);
01324     std::fill(m_ptr, m_ptr + m_stride[NumDim], 0);
01325   }
01326 
01327 
01328   FArrayContainer(const unsigned n[])
01329     : BaseType(NULL, n),
01330       m_capacity(0)
01331   {
01332     resize_memory(m_stride[NumDim]);
01333     std::fill(m_ptr, m_ptr + m_stride[NumDim], 0);
01334   }
01335 
01336 
01337   //----------------------------------------
01338 
01339   template<typename T>
01340   SelfType & resize(const FArray<T, Dimension> & a)
01341   {
01342     resize_memory(BaseType::set_dim(a.dimension()));
01343     return *this;
01344   }
01345 
01346   SelfType & resize(const unsigned n0, const unsigned n1,
01347         const unsigned n2, const unsigned n3,
01348         const unsigned n4, const unsigned n5,
01349         const unsigned n6, const unsigned n7)
01350   {
01351     resize_memory(BaseType::set_dim(n0, n1, n2, n3, n4, n5, n6, n7));
01352     return *this;
01353   }
01354 
01355   SelfType & resize(const unsigned n0, const unsigned n1,
01356         const unsigned n2, const unsigned n3,
01357         const unsigned n4, const unsigned n5,
01358         const unsigned n6)
01359   {
01360     resize_memory(BaseType::set_dim(n0, n1, n2, n3, n4, n5, n6));
01361     return *this;
01362   }
01363 
01364   SelfType & resize(const unsigned n0, const unsigned n1,
01365         const unsigned n2, const unsigned n3,
01366         const unsigned n4, const unsigned n5)
01367   {
01368     resize_memory(BaseType::set_dim(n0, n1, n2, n3, n4, n5));
01369     return *this;
01370   }
01371 
01372   SelfType & resize(const unsigned n0, const unsigned n1,
01373         const unsigned n2, const unsigned n3,
01374         const unsigned n4)
01375   {
01376     resize_memory(BaseType::set_dim(n0, n1, n2, n3, n4));
01377     return *this;
01378   }
01379 
01380   SelfType & resize(const unsigned n0, const unsigned n1,
01381         const unsigned n2, const unsigned n3)
01382   {
01383     resize_memory(BaseType::set_dim(n0, n1, n2, n3));
01384     return *this;
01385   }
01386 
01387 
01388   SelfType & resize(const unsigned n0, const unsigned n1,
01389         const unsigned n2)
01390   {
01391     resize_memory(BaseType::set_dim(n0, n1, n2));
01392     return *this;
01393   }
01394 
01395   SelfType & resize(const unsigned n0, const unsigned n1) {
01396     resize_memory(BaseType::set_dim(n0, n1));
01397     return *this;
01398   }
01399 
01400   SelfType & resize(const unsigned n0) {
01401     resize_memory(BaseType::set_dim(n0));
01402     return *this;
01403   }
01404 
01405   SelfType & resize(const unsigned n[]) {
01406     resize_memory(BaseType::set_dim(n));
01407     return *this;
01408   }
01409 
01410 private:
01411   A             m_allocator;
01412   unsigned      m_capacity;
01413 };
01414 
01418 
01419 } // namespace sierra
01420 
01421 #endif // STK_UTIL_DIAG_FArray_h
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines