include/deal.II/base/table.h

00001 //---------------------------------------------------------------------------
00002 //    @f$Id: table.h 25345 2012-03-31 08:37:04Z bangerth @f$
00003 //
00004 //    Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
00005 //
00006 //    This file is subject to QPL and may not be  distributed
00007 //    without copyright and license information. Please refer
00008 //    to the file deal.II/doc/license.html for the  text  and
00009 //    further information on this license.
00010 //
00011 //---------------------------------------------------------------------------
00012 #ifndef __deal2__table_h
00013 #define __deal2__table_h
00014 
00015 #include <deal.II/base/config.h>
00016 #include <deal.II/base/exceptions.h>
00017 #include <deal.II/base/subscriptor.h>
00018 #include <deal.II/base/table_indices.h>
00019 #include <deal.II/base/memory_consumption.h>
00020 
00021 #include <cstddef>
00022 #include <algorithm>
00023 
00024 DEAL_II_NAMESPACE_OPEN
00025 
00026 // forward declaration
00027 template <int N, typename T> class TableBase;
00028 template <int N, typename T> class Table;
00029 template <typename T> class Table<1,T>;
00030 template <typename T> class Table<2,T>;
00031 template <typename T> class Table<3,T>;
00032 template <typename T> class Table<4,T>;
00033 template <typename T> class Table<5,T>;
00034 template <typename T> class Table<6,T>;
00035 
00036 
00037 
00038 namespace internal
00039 {
00040 
00059   namespace TableBaseAccessors
00060   {
00069     template <int N, typename T, bool Constness>
00070     struct Types
00071     {};
00072 
00079     template <int N, typename T> struct Types<N,T,true>
00080     {
00081         typedef const T value_type;
00082         typedef const TableBase<N,T> TableType;
00083 
00084         typedef typename std::vector<T>::const_iterator iterator;
00085         typedef typename std::vector<T>::const_iterator const_iterator;
00086 
00087         typedef typename std::vector<T>::const_reference reference;
00088         typedef typename std::vector<T>::const_reference const_reference;
00089     };
00090 
00097     template <int N, typename T> struct Types<N,T,false>
00098     {
00099         typedef T value_type;
00100         typedef TableBase<N,T> TableType;
00101 
00102         typedef typename std::vector<T>::iterator iterator;
00103         typedef typename std::vector<T>::const_iterator const_iterator;
00104 
00105         typedef typename std::vector<T>::reference reference;
00106         typedef typename std::vector<T>::const_reference const_reference;
00107     };
00108 
00109 
00149     template <int N, typename T, bool C, unsigned int P>
00150     class Accessor
00151     {
00152       public:
00153         typedef typename Types<N,T,C>::TableType TableType;
00154 
00155         typedef typename Types<N,T,C>::iterator iterator;
00156         typedef typename Types<N,T,C>::const_iterator const_iterator;
00157 
00158       private:
00167         Accessor (const TableType &table,
00168                   const iterator    data);
00169 
00175         Accessor ();
00176 
00177       public:
00178 
00191         Accessor (const Accessor &a);
00192 
00197         Accessor<N,T,C,P-1> operator [] (const unsigned int i) const;
00198 
00206         DeclException3 (ExcIndexRange, int, int, int,
00207                         << "Index " << N-P+1 << "has a value of "
00208                         << arg1 << " but needs to be in the range ["
00209                         << arg2 << "," << arg3 << "[");
00210       private:
00219         const TableType &table;
00220         const iterator   data;
00221 
00222                                          // declare some other classes
00223                                          // as friends. make sure to
00224                                          // work around bugs in some
00225                                          // compilers
00226 #ifndef DEAL_II_NAMESP_TEMPL_FRIEND_BUG
00227         template <int N1, typename T1> friend class ::Table;
00228         template <int N1, typename T1, bool C1, unsigned int P1>
00229         friend class Accessor;
00230 #  ifndef DEAL_II_TEMPL_SPEC_FRIEND_BUG
00231         friend class ::Table<N,T>;
00232         friend class Accessor<N,T,C,P+1>;
00233 #  endif
00234 #else
00235         friend class Table<N,T>;
00236         friend class Accessor<N,T,C,P+1>;
00237 #endif
00238     };
00239 
00240 
00241 
00252     template <int N, typename T, bool C>
00253     class Accessor<N,T,C,1>
00254     {
00255       public:
00265         typedef typename Types<N,T,C>::value_type value_type;
00266 
00267         typedef typename Types<N,T,C>::iterator iterator;
00268         typedef typename Types<N,T,C>::const_iterator const_iterator;
00269 
00270         typedef typename Types<N,T,C>::reference reference;
00271         typedef typename Types<N,T,C>::const_reference const_reference;
00272 
00273         typedef size_t size_type;
00274         typedef ptrdiff_t difference_type;
00275 
00280         typedef typename Types<N,T,C>::TableType    TableType;
00281 
00282       private:
00283 
00308         Accessor (const TableType &table,
00309                   const iterator    data);
00310 
00315         Accessor ();
00316 
00317       public:
00330         Accessor (const Accessor &a);
00331 
00332 
00337         reference operator [] (const unsigned int) const;
00338 
00345         unsigned int size () const;
00346 
00352         iterator begin () const;
00353 
00359         iterator end () const;
00360 
00361       private:
00370         const TableType &table;
00371         const iterator   data;
00372 
00373                                          // declare some other classes
00374                                          // as friends. make sure to
00375                                          // work around bugs in some
00376                                          // compilers
00377 #ifndef DEAL_II_NAMESP_TEMPL_FRIEND_BUG
00378         template <int N1, typename T1> friend class ::Table;
00379         template <int N1, typename T1, bool C1, unsigned int P1>
00380         friend class Accessor;
00381 #  ifndef DEAL_II_TEMPL_SPEC_FRIEND_BUG
00382         friend class ::Table<2,T>;
00383         friend class Accessor<N,T,C,2>;
00384 #  endif
00385 #else
00386         friend class Table<2,T>;
00387         friend class Accessor<N,T,C,2>;
00388 #endif
00389     };
00390   }
00391 
00392 } // namespace internal
00393 
00394 
00395 
00396 
00471 template <int N, typename T>
00472 class TableBase : public Subscriptor
00473 {
00474   public:
00479     TableBase ();
00480 
00487     TableBase (const TableIndices<N> &sizes);
00488 
00493     TableBase (const TableBase<N,T> &src);
00494 
00500     template <typename T2>
00501     TableBase (const TableBase<N,T2> &src);
00502 
00506     ~TableBase ();
00507 
00520     TableBase<N,T>& operator = (const TableBase<N,T>& src);
00521 
00532     template<typename T2>
00533     TableBase<N,T>& operator = (const TableBase<N,T2> &src);
00534 
00538     bool operator == (const TableBase<N,T> & T2)  const;
00539 
00547     void reset_values ();
00548 
00558     void reinit (const TableIndices<N> &new_size,
00559                  const bool             fast = false);
00560 
00565     unsigned int size (const unsigned int i) const;
00566 
00571     const TableIndices<N> & size () const;
00572 
00579     unsigned int n_elements () const;
00580 
00588     bool empty () const;
00589 
00614     template<typename T2>
00615     void fill (const T2 *entries);
00616 
00621     void fill (const T& value);
00622 
00627     typename std::vector<T>::reference
00628     operator () (const TableIndices<N> &indices);
00629 
00643     typename std::vector<T>::const_reference
00644     operator () (const TableIndices<N> &indices) const;
00645 
00651     std::size_t memory_consumption () const;
00652 
00657     template <class Archive>
00658     void serialize (Archive & ar, const unsigned int version);
00659 
00660   protected:
00668     unsigned int position (const TableIndices<N> &indices) const;
00669 
00679     typename std::vector<T>::reference el (const TableIndices<N> &indices);
00680 
00699     typename std::vector<T>::const_reference el (const TableIndices<N> &indices) const;
00700 
00713     typename std::vector<T>::const_pointer data () const;
00714 
00715   protected:
00719     std::vector<T> values;
00720 
00725     TableIndices<N> table_size;
00726 
00731     template <int, typename> friend class TableBase;
00732 };
00733 
00734 
00749 template <int N,typename T>
00750 class Table : public TableBase<N,T>
00751 {
00752 };
00753 
00754 
00768 template <typename T>
00769 class Table<1,T> : public TableBase<1,T>
00770 {
00771   public:
00776     Table ();
00777 
00783     Table (const unsigned int size);
00784 
00792     typename std::vector<T>::const_reference
00793     operator [] (const unsigned int i) const;
00794 
00802     typename std::vector<T>::reference
00803     operator [] (const unsigned int i);
00804 
00812     typename std::vector<T>::const_reference
00813     operator () (const unsigned int i) const;
00814 
00822     typename std::vector<T>::reference
00823     operator () (const unsigned int i);
00824 
00831     typename std::vector<T>::reference
00832     operator () (const TableIndices<1> &indices);
00833 
00840     typename std::vector<T>::const_reference
00841     operator () (const TableIndices<1> &indices) const;
00842 };
00843 
00844 
00845 
00859 template <typename T>
00860 class Table<2,T> : public TableBase<2,T>
00861 {
00862   public:
00867     Table ();
00868 
00874     Table (const unsigned int size1,
00875            const unsigned int size2);
00876 
00887     void reinit (const unsigned int size1,
00888                  const unsigned int size2,
00889                  const bool         fast = false);
00890 
00901     internal::TableBaseAccessors::Accessor<2,T,true,1>
00902     operator [] (const unsigned int i) const;
00903 
00914     internal::TableBaseAccessors::Accessor<2,T,false,1>
00915     operator [] (const unsigned int i);
00916 
00926     typename std::vector<T>::const_reference
00927     operator () (const unsigned int i,
00928                  const unsigned int j) const;
00929 
00930 
00940     typename std::vector<T>::reference
00941     operator () (const unsigned int i,
00942                  const unsigned int j);
00943 
00950     typename std::vector<T>::reference
00951     operator () (const TableIndices<2> &indices);
00952 
00959     typename std::vector<T>::const_reference
00960     operator () (const TableIndices<2> &indices) const;
00961 
00962 
00969     unsigned int n_rows () const;
00970 
00977     unsigned int n_cols () const;
00978 
00979   protected:
00995     typename std::vector<T>::reference el (const unsigned int i,
00996                                            const unsigned int j);
00997 
01022     typename std::vector<T>::const_reference el (const unsigned int i,
01023                                                  const unsigned int j) const;
01024 };
01025 
01026 
01027 
01038 template <typename T>
01039 class Table<3,T> : public TableBase<3,T>
01040 {
01041   public:
01046     Table ();
01047 
01053     Table (const unsigned int size1,
01054            const unsigned int size2,
01055            const unsigned int size3);
01056 
01068     internal::TableBaseAccessors::Accessor<3,T,true,2>
01069     operator [] (const unsigned int i) const;
01070 
01082     internal::TableBaseAccessors::Accessor<3,T,false,2>
01083     operator [] (const unsigned int i);
01084 
01094     typename std::vector<T>::const_reference operator () (const unsigned int i,
01095                            const unsigned int j,
01096                            const unsigned int k) const;
01097 
01098 
01108     typename std::vector<T>::reference operator () (const unsigned int i,
01109                      const unsigned int j,
01110                      const unsigned int k);
01111 
01118     typename std::vector<T>::reference operator () (const TableIndices<3> &indices);
01119 
01126     typename std::vector<T>::const_reference operator () (const TableIndices<3> &indices) const;
01127 };
01128 
01129 
01130 
01141 template <typename T>
01142 class Table<4,T> : public TableBase<4,T>
01143 {
01144   public:
01149     Table ();
01150 
01156     Table (const unsigned int size1,
01157            const unsigned int size2,
01158            const unsigned int size3,
01159            const unsigned int size4);
01160 
01172     internal::TableBaseAccessors::Accessor<4,T,true,3>
01173     operator [] (const unsigned int i) const;
01174 
01186     internal::TableBaseAccessors::Accessor<4,T,false,3>
01187     operator [] (const unsigned int i);
01188 
01198     typename std::vector<T>::const_reference operator () (const unsigned int i,
01199                            const unsigned int j,
01200                            const unsigned int k,
01201                            const unsigned int l) const;
01202 
01203 
01213     typename std::vector<T>::reference operator () (const unsigned int i,
01214                      const unsigned int j,
01215                      const unsigned int k,
01216                      const unsigned int l);
01217 
01224     typename std::vector<T>::reference
01225     operator () (const TableIndices<4> &indices);
01226 
01233     typename std::vector<T>::const_reference
01234     operator () (const TableIndices<4> &indices) const;
01235 };
01236 
01237 
01238 
01249 template <typename T>
01250 class Table<5,T> : public TableBase<5,T>
01251 {
01252   public:
01257     Table ();
01258 
01264     Table (const unsigned int size1,
01265            const unsigned int size2,
01266            const unsigned int size3,
01267            const unsigned int size4,
01268            const unsigned int size5);
01269 
01281     internal::TableBaseAccessors::Accessor<5,T,true,4>
01282     operator [] (const unsigned int i) const;
01283 
01295     internal::TableBaseAccessors::Accessor<5,T,false,4>
01296     operator [] (const unsigned int i);
01297 
01307     typename std::vector<T>::const_reference operator () (const unsigned int i,
01308                            const unsigned int j,
01309                            const unsigned int k,
01310                            const unsigned int l,
01311                            const unsigned int m) const;
01312 
01322     typename std::vector<T>::reference operator () (const unsigned int i,
01323                      const unsigned int j,
01324                      const unsigned int k,
01325                      const unsigned int l,
01326                      const unsigned int m);
01327 
01334     typename std::vector<T>::reference
01335     operator () (const TableIndices<5> &indices);
01336 
01343     typename std::vector<T>::const_reference
01344     operator () (const TableIndices<5> &indices) const;
01345 };
01346 
01347 
01348 
01359 template <typename T>
01360 class Table<6,T> : public TableBase<6,T>
01361 {
01362   public:
01367     Table ();
01368 
01374     Table (const unsigned int size1,
01375            const unsigned int size2,
01376            const unsigned int size3,
01377            const unsigned int size4,
01378            const unsigned int size5,
01379            const unsigned int size6);
01380 
01392     internal::TableBaseAccessors::Accessor<6,T,true,5>
01393     operator [] (const unsigned int i) const;
01394 
01406     internal::TableBaseAccessors::Accessor<6,T,false,5>
01407     operator [] (const unsigned int i);
01408 
01418     typename std::vector<T>::const_reference operator () (const unsigned int i,
01419                            const unsigned int j,
01420                            const unsigned int k,
01421                            const unsigned int l,
01422                            const unsigned int m,
01423                            const unsigned int n) const;
01424 
01434     typename std::vector<T>::reference operator () (const unsigned int i,
01435                      const unsigned int j,
01436                      const unsigned int k,
01437                      const unsigned int l,
01438                      const unsigned int m,
01439                      const unsigned int n);
01440 
01447     typename std::vector<T>::reference
01448     operator () (const TableIndices<6> &indices);
01449 
01456     typename std::vector<T>::const_reference
01457     operator () (const TableIndices<6> &indices) const;
01458 };
01459 
01460 
01471 template <typename T>
01472 class Table<7,T> : public TableBase<7,T>
01473 {
01474   public:
01479     Table ();
01480 
01486     Table (const unsigned int size1,
01487            const unsigned int size2,
01488            const unsigned int size3,
01489            const unsigned int size4,
01490            const unsigned int size5,
01491            const unsigned int size6,
01492            const unsigned int size7);
01493 
01505     internal::TableBaseAccessors::Accessor<7,T,true,6>
01506     operator [] (const unsigned int i) const;
01507 
01519     internal::TableBaseAccessors::Accessor<7,T,false,6>
01520     operator [] (const unsigned int i);
01521 
01531     typename std::vector<T>::const_reference operator () (const unsigned int i,
01532                            const unsigned int j,
01533                            const unsigned int k,
01534                            const unsigned int l,
01535                            const unsigned int m,
01536                            const unsigned int n,
01537                            const unsigned int o) const;
01538 
01548     typename std::vector<T>::reference operator () (const unsigned int i,
01549                      const unsigned int j,
01550                      const unsigned int k,
01551                      const unsigned int l,
01552                      const unsigned int m,
01553                      const unsigned int n,
01554                      const unsigned int o);
01555 
01562     typename std::vector<T>::reference
01563     operator () (const TableIndices<7> &indices);
01564 
01571     typename std::vector<T>::const_reference
01572     operator () (const TableIndices<7> &indices) const;
01573 };
01574 
01575 
01576 
01590 template <typename T>
01591 class TransposeTable : public TableBase<2,T>
01592 {
01593   public:
01598     TransposeTable ();
01599 
01605     TransposeTable (const unsigned int size1,
01606                     const unsigned int size2);
01607 
01618     void reinit (const unsigned int size1,
01619                  const unsigned int size2,
01620                  const bool         fast = false);
01621 
01631     typename std::vector<T>::const_reference operator () (const unsigned int i,
01632                            const unsigned int j) const;
01633 
01643     typename std::vector<T>::reference operator () (const unsigned int i,
01644                      const unsigned int j);
01645 
01652     unsigned int n_rows () const;
01653 
01660     unsigned int n_cols () const;
01661 
01662   protected:
01678     typename std::vector<T>::reference el (const unsigned int i,
01679             const unsigned int j);
01680 
01705     typename std::vector<T>::const_reference el (const unsigned int i,
01706                   const unsigned int j) const;
01707 };
01708 
01709 
01710 
01711 
01712 /* --------------------- Template and inline functions ---------------- */
01713 
01714 #ifndef DOXYGEN
01715 
01716 template <int N, typename T>
01717 TableBase<N,T>::TableBase ()
01718 {}
01719 
01720 
01721 
01722 template <int N, typename T>
01723 TableBase<N,T>::TableBase (const TableIndices<N> &sizes)
01724 {
01725   reinit (sizes);
01726 }
01727 
01728 
01729 
01730 template <int N, typename T>
01731 TableBase<N,T>::TableBase (const TableBase<N,T> &src)
01732                 :
01733                 Subscriptor ()
01734 {
01735   reinit (src.table_size);
01736   if (src.n_elements() != 0)
01737     std::copy (src.values.begin(), src.values.end(), values.begin());
01738 }
01739 
01740 
01741 
01742 template <int N, typename T>
01743 template <typename T2>
01744 TableBase<N,T>::TableBase (const TableBase<N,T2> &src)
01745 {
01746   reinit (src.table_size);
01747   if (src.n_elements() != 0)
01748     std::copy (src.values.begin(), src.values.end(), values.begin());
01749 }
01750 
01751 
01752 
01753 template <int N, typename T>
01754 template <class Archive>
01755 inline
01756 void
01757 TableBase<N,T>::serialize (Archive & ar, const unsigned int)
01758 {
01759   ar & static_cast<Subscriptor &>(*this);
01760 
01761   ar & values & table_size;
01762 }
01763 
01764 
01765 
01766 namespace internal
01767 {
01768   namespace TableBaseAccessors
01769   {
01770     template <int N, typename T, bool C, unsigned int P>
01771     inline
01772     Accessor<N,T,C,P>::Accessor (const TableType &table,
01773                                  const iterator    data)
01774                     :
01775                     table (table),
01776                     data (data)
01777     {}
01778 
01779 
01780 
01781     template <int N, typename T, bool C, unsigned int P>
01782     inline
01783     Accessor<N,T,C,P>::Accessor (const Accessor &a)
01784                     :
01785                     table (a.table),
01786                     data (a.data)
01787     {}
01788 
01789 
01790 
01791     template <int N, typename T, bool C, unsigned int P>
01792     inline
01793     Accessor<N,T,C,P>::Accessor ()
01794                     :
01795                     table (*static_cast<const TableType*>(0)),
01796                     data (0)
01797     {
01798                                        // accessor objects are only
01799                                        // temporary objects, so should
01800                                        // not need to be copied around
01801       Assert (false, ExcInternalError());
01802     }
01803 
01804 
01805 
01806     template <int N, typename T, bool C, unsigned int P>
01807     inline
01808     Accessor<N,T,C,P-1>
01809     Accessor<N,T,C,P>::operator [] (const unsigned int i) const
01810     {
01811       Assert (i < table.size()[N-P],
01812               ExcIndexRange (i, 0, table.size()[N-P]));
01813 
01814                                        // access i-th
01815                                        // subobject. optimize on the
01816                                        // case i==0
01817       if (i==0)
01818         return Accessor<N,T,C,P-1> (table, data);
01819       else
01820         {
01821                                            // note: P>1, otherwise the
01822                                            // specialization would have
01823                                            // been taken!
01824           unsigned int subobject_size = table.size()[N-1];
01825           for (int p=P-1; p>1; --p)
01826             subobject_size *= table.size()[N-p];
01827           const iterator new_data = data + i*subobject_size;
01828           return Accessor<N,T,C,P-1> (table, new_data);
01829         }
01830     }
01831 
01832 
01833 
01834     template <int N, typename T, bool C>
01835     inline
01836     Accessor<N,T,C,1>::Accessor (const TableType &table,
01837                                  const iterator    data)
01838                     :
01839                     table (table),
01840                     data (data)
01841     {}
01842 
01843 
01844 
01845     template <int N, typename T, bool C>
01846     inline
01847     Accessor<N,T,C,1>::Accessor ()
01848                     :
01849                     table (*static_cast<const TableType*>(0)),
01850                     data (0)
01851     {
01852                                        // accessor objects are only
01853                                        // temporary objects, so should
01854                                        // not need to be copied around
01855       Assert (false, ExcInternalError());
01856     }
01857 
01858 
01859 
01860     template <int N, typename T, bool C>
01861     inline
01862     Accessor<N,T,C,1>::Accessor (const Accessor &a)
01863                     :
01864                     table (a.table),
01865                     data (a.data)
01866     {}
01867 
01868 
01869 
01870     template <int N, typename T, bool C>
01871     inline
01872     typename Accessor<N,T,C,1>::reference
01873     Accessor<N,T,C,1>::operator [] (const unsigned int i) const
01874     {
01875       Assert (i < table.size()[N-1],
01876               ExcIndexRange (i, 0, table.size()[N-1]));
01877       return *(data+i);
01878     }
01879 
01880 
01881 
01882     template <int N, typename T, bool C>
01883     inline
01884     unsigned int
01885     Accessor<N,T,C,1>::size () const
01886     {
01887       return table.size()[N-1];
01888     }
01889 
01890 
01891 
01892     template <int N, typename T, bool C>
01893     inline
01894     typename Accessor<N,T,C,1>::iterator
01895     Accessor<N,T,C,1>::begin () const
01896     {
01897       return data;
01898     }
01899 
01900 
01901 
01902     template <int N, typename T, bool C>
01903     inline
01904     typename Accessor<N,T,C,1>::iterator
01905     Accessor<N,T,C,1>::end () const
01906     {
01907       return data+table.size()[N-1];
01908     }
01909   }
01910 }
01911 
01912 
01913 
01914 template <int N, typename T>
01915 inline
01916 TableBase<N,T>::~TableBase ()
01917 {}
01918 
01919 
01920 
01921 template <int N, typename T>
01922 inline
01923 TableBase<N,T>&
01924 TableBase<N,T>::operator = (const TableBase<N,T>& m)
01925 {
01926   reinit (m.size());
01927   if (!empty())
01928     std::copy (m.values.begin(), m.values.end(), values.begin());
01929 
01930   return *this;
01931 }
01932 
01933 
01934 
01935 template <int N, typename T>
01936 template <typename T2>
01937 inline
01938 TableBase<N,T>&
01939 TableBase<N,T>::operator = (const TableBase<N,T2>& m)
01940 {
01941   reinit (m.size());
01942   if (!empty())
01943     std::copy (m.values.begin(), m.values.begin() + n_elements(),
01944                values.begin());
01945 
01946   return *this;
01947 }
01948 
01949 
01950 template <int N, typename T>
01951 inline
01952 bool
01953 TableBase<N,T>::operator == (const TableBase<N,T> & T2)  const
01954 {
01955   return (values == T2.values);
01956 }
01957 
01958 
01959 
01960 template <int N, typename T>
01961 inline
01962 void
01963 TableBase<N,T>::reset_values ()
01964 {
01965   if (n_elements() != 0)
01966     std::fill (values.begin(), values.end(), T());
01967 }
01968 
01969 
01970 
01971 template <int N, typename T>
01972 inline
01973 void
01974 TableBase<N,T>::fill (const T& value)
01975 {
01976   if (n_elements() != 0)
01977     std::fill (values.begin(), values.end(), value);
01978 }
01979 
01980 
01981 
01982 
01983 template <int N, typename T>
01984 inline
01985 void
01986 TableBase<N,T>::reinit (const TableIndices<N> &new_sizes,
01987                         const bool             fast)
01988 {
01989   table_size = new_sizes;
01990 
01991   const unsigned int new_size = n_elements();
01992 
01993                                    // if zero size was given: free all
01994                                    // memory
01995   if (new_size == 0)
01996     {
01997       values.resize (0);
01998                                        // set all sizes to zero, even
01999                                        // if one was previously
02000                                        // nonzero. This simplifies
02001                                        // some assertions.
02002       table_size = TableIndices<N>();
02003 
02004       return;
02005     }
02006 
02007                                    // if new size is nonzero:
02008                                    // if necessary allocate
02009                                    // additional memory
02010   values.resize (new_size);
02011 
02012                                    // reinitialize contents of old or
02013                                    // new memory. note that we
02014                                    // actually need to do this here,
02015                                    // even in the case that we
02016                                    // reallocated memory, since per
02017                                    // C++ standard, clause 5.3.4/15
02018                                    // the newly allocated objects are
02019                                    // only default initialized by
02020                                    // operator new[] if they are
02021                                    // non-POD type. In other words, if
02022                                    // we have a table of doubles, then
02023                                    // their values after calling 'new
02024                                    // double[val_size]' is
02025                                    // indetermined.
02026   if (fast == false)
02027     reset_values ();
02028 }
02029 
02030 
02031 
02032 template <int N, typename T>
02033 inline
02034 const TableIndices<N> &
02035 TableBase<N,T>::size () const
02036 {
02037   return table_size;
02038 }
02039 
02040 
02041 
02042 template <int N, typename T>
02043 inline
02044 unsigned int
02045 TableBase<N,T>::size (const unsigned int i) const
02046 {
02047   Assert (i<N, ExcIndexRange(i,0,N));
02048   return table_size[i];
02049 }
02050 
02051 
02052 
02053 template <int N, typename T>
02054 inline
02055 unsigned int
02056 TableBase<N,T>::n_elements () const
02057 {
02058   unsigned s = 1;
02059   for (unsigned int n=0; n<N; ++n)
02060     s *= table_size[n];
02061   return s;
02062 }
02063 
02064 
02065 
02066 template <int N, typename T>
02067 inline
02068 bool
02069 TableBase<N,T>::empty () const
02070 {
02071   return (n_elements() == 0);
02072 }
02073 
02074 
02075 
02076 template <int N, typename T>
02077 template <typename T2>
02078 inline
02079 void
02080 TableBase<N,T>::fill (const T2* entries)
02081 {
02082   Assert (n_elements() != 0,
02083           ExcMessage("Trying to fill an empty matrix."));
02084 
02085   std::copy (entries, entries+n_elements(), values.begin());
02086 }
02087 
02088 
02089 
02090 template <int N, typename T>
02091 inline
02092 std::size_t
02093 TableBase<N,T>::memory_consumption () const
02094 {
02095   return sizeof(*this) + MemoryConsumption::memory_consumption(values);
02096 }
02097 
02098 
02099 
02100 template <int N, typename T>
02101 inline
02102 unsigned int
02103 TableBase<N,T>::position (const TableIndices<N> &indices) const
02104 {
02105                                    // specialize this for the
02106                                    // different numbers of dimensions,
02107                                    // to make the job somewhat easier
02108                                    // for the compiler. have the
02109                                    // general formula nevertheless:
02110   switch (N)
02111     {
02112       case 1:
02113             return indices[0];
02114       case 2:
02115             return indices[0]*table_size[1] + indices[1];
02116       case 3:
02117             return ((indices[0]*table_size[1] + indices[1])*table_size[2]
02118                     + indices[2]);
02119       default:
02120       {
02121         unsigned int s = indices[0];
02122         for (unsigned int n=1; n<N; ++n)
02123           s = s*table_size[n] + indices[n];
02124         return s;
02125       }
02126     }
02127 }
02128 
02129 
02130 
02131 template <int N, typename T>
02132 inline
02133 typename std::vector<T>::const_reference
02134 TableBase<N,T>::operator () (const TableIndices<N> &indices) const
02135 {
02136   for (unsigned int n=0; n<N; ++n)
02137     Assert (indices[n] < table_size[n],
02138             ExcIndexRange (indices[n], 0, table_size[n]));
02139   return el(indices);
02140 }
02141 
02142 
02143 
02144 template <int N, typename T>
02145 inline
02146 typename std::vector<T>::reference
02147 TableBase<N,T>::operator () (const TableIndices<N> &indices)
02148 {
02149   for (unsigned int n=0; n<N; ++n)
02150     Assert (indices[n] < table_size[n],
02151             ExcIndexRange (indices[n], 0, table_size[n]));
02152   return el(indices);
02153 }
02154 
02155 
02156 
02157 template <int N, typename T>
02158 inline
02159 typename std::vector<T>::const_reference
02160 TableBase<N,T>::el (const TableIndices<N> &indices) const
02161 {
02162   return values[position(indices)];
02163 }
02164 
02165 
02166 
02167 template <int N, typename T>
02168 inline
02169 typename std::vector<T>::reference
02170 TableBase<N,T>::el (const TableIndices<N> &indices)
02171 {
02172   Assert (position(indices) < values.size(),
02173           ExcIndexRange (position(indices), 0, values.size()));
02174   return values[position(indices)];
02175 }
02176 
02177 
02178 
02179 template <int N, typename T>
02180 inline
02181 typename std::vector<T>::const_pointer
02182 TableBase<N,T>::data () const
02183 {
02184   if (values.size() == 0)
02185     return typename std::vector<T>::const_pointer();
02186   else
02187     return &values[0];
02188 }
02189 
02190 
02191 
02192 
02193 template <typename T>
02194 inline
02195 Table<1,T>::Table ()
02196 {}
02197 
02198 
02199 
02200 template <typename T>
02201 inline
02202 Table<1,T>::Table (const unsigned int size)
02203                 :
02204                 TableBase<1,T> (TableIndices<1> (size))
02205 {}
02206 
02207 
02208 
02209 template <typename T>
02210 inline
02211 typename std::vector<T>::const_reference
02212 Table<1,T>::operator [] (const unsigned int i) const
02213 {
02214   Assert (i < this->table_size[0],
02215           ExcIndexRange (i, 0, this->table_size[0]));
02216   return this->values[i];
02217 }
02218 
02219 
02220 
02221 template <typename T>
02222 inline
02223 typename std::vector<T>::reference
02224 Table<1,T>::operator [] (const unsigned int i)
02225 {
02226   Assert (i < this->table_size[0],
02227           ExcIndexRange (i, 0, this->table_size[0]));
02228   return this->values[i];
02229 }
02230 
02231 
02232 
02233 template <typename T>
02234 inline
02235 typename std::vector<T>::const_reference
02236 Table<1,T>::operator () (const unsigned int i) const
02237 {
02238   Assert (i < this->table_size[0],
02239           ExcIndexRange (i, 0, this->table_size[0]));
02240   return this->values[i];
02241 }
02242 
02243 
02244 
02245 template <typename T>
02246 inline
02247 typename std::vector<T>::reference
02248 Table<1,T>::operator () (const unsigned int i)
02249 {
02250   Assert (i < this->table_size[0],
02251           ExcIndexRange (i, 0, this->table_size[0]));
02252   return this->values[i];
02253 }
02254 
02255 
02256 
02257 template <typename T>
02258 inline
02259 typename std::vector<T>::const_reference
02260 Table<1,T>::operator () (const TableIndices<1> &indices) const
02261 {
02262   return TableBase<1,T>::operator () (indices);
02263 }
02264 
02265 
02266 
02267 template <typename T>
02268 inline
02269 typename std::vector<T>::reference
02270 Table<1,T>::operator () (const TableIndices<1> &indices)
02271 {
02272   return TableBase<1,T>::operator () (indices);
02273 }
02274 
02275 
02276 //---------------------------------------------------------------------------
02277 
02278 template <typename T>
02279 inline
02280 Table<2,T>::Table ()
02281 {}
02282 
02283 
02284 
02285 template <typename T>
02286 inline
02287 Table<2,T>::Table (const unsigned int size1,
02288                    const unsigned int size2)
02289                 :
02290                 TableBase<2,T> (TableIndices<2> (size1, size2))
02291 {}
02292 
02293 
02294 
02295 template <typename T>
02296 inline
02297 void
02298 Table<2,T>::reinit (const unsigned int size1,
02299                     const unsigned int size2,
02300                     const bool         fast)
02301 {
02302   this->TableBase<2,T>::reinit (TableIndices<2> (size1, size2),fast);
02303 }
02304 
02305 
02306 
02307 template <typename T>
02308 inline
02309 internal::TableBaseAccessors::Accessor<2,T,true,1>
02310 Table<2,T>::operator [] (const unsigned int i) const
02311 {
02312   Assert (i < this->table_size[0],
02313           ExcIndexRange (i, 0, this->table_size[0]));
02314   return internal::TableBaseAccessors::Accessor<2,T,true,1>(*this,
02315                                                             this->values.begin()+i*n_cols());
02316 }
02317 
02318 
02319 
02320 template <typename T>
02321 inline
02322 internal::TableBaseAccessors::Accessor<2,T,false,1>
02323 Table<2,T>::operator [] (const unsigned int i)
02324 {
02325   Assert (i < this->table_size[0],
02326           ExcIndexRange (i, 0, this->table_size[0]));
02327   return internal::TableBaseAccessors::Accessor<2,T,false,1>(*this,
02328                                                              this->values.begin()+i*n_cols());
02329 }
02330 
02331 
02332 
02333 template <typename T>
02334 inline
02335 typename std::vector<T>::const_reference
02336 Table<2,T>::operator () (const unsigned int i,
02337                          const unsigned int j) const
02338 {
02339   Assert (i < this->table_size[0],
02340           ExcIndexRange (i, 0, this->table_size[0]));
02341   Assert (j < this->table_size[1],
02342           ExcIndexRange (j, 0, this->table_size[1]));
02343   return this->values[i*this->table_size[1]+j];
02344 }
02345 
02346 
02347 
02348 template <typename T>
02349 inline
02350 typename std::vector<T>::reference
02351 Table<2,T>::operator () (const unsigned int i,
02352                          const unsigned int j)
02353 {
02354   Assert (i < this->table_size[0],
02355           ExcIndexRange (i, 0, this->table_size[0]));
02356   Assert (j < this->table_size[1],
02357           ExcIndexRange (j, 0, this->table_size[1]));
02358   return this->values[i*this->table_size[1]+j];
02359 }
02360 
02361 
02362 
02363 template <typename T>
02364 inline
02365 typename std::vector<T>::const_reference
02366 Table<2,T>::operator () (const TableIndices<2> &indices) const
02367 {
02368   return TableBase<2,T>::operator () (indices);
02369 }
02370 
02371 
02372 
02373 template <typename T>
02374 inline
02375 typename std::vector<T>::reference
02376 Table<2,T>::operator () (const TableIndices<2> &indices)
02377 {
02378   return TableBase<2,T>::operator () (indices);
02379 }
02380 
02381 
02382 
02383 template <typename T>
02384 inline
02385 typename std::vector<T>::const_reference
02386 Table<2,T>::el (const unsigned int i,
02387                 const unsigned int j) const
02388 {
02389   return this->values[i*this->table_size[1]+j];
02390 }
02391 
02392 
02393 
02394 template <typename T>
02395 inline
02396 typename std::vector<T>::reference
02397 Table<2,T>::el (const unsigned int i,
02398                 const unsigned int j)
02399 {
02400   return this->values[i*this->table_size[1]+j];
02401 }
02402 
02403 
02404 
02405 template <typename T>
02406 inline
02407 unsigned int
02408 Table<2,T>::n_rows () const
02409 {
02410   return this->table_size[0];
02411 }
02412 
02413 
02414 
02415 template <typename T>
02416 inline
02417 unsigned int
02418 Table<2,T>::n_cols () const
02419 {
02420   return this->table_size[1];
02421 }
02422 
02423 
02424 
02425 //---------------------------------------------------------------------------
02426 
02427 template <typename T>
02428 inline
02429 TransposeTable<T>::TransposeTable ()
02430 {}
02431 
02432 
02433 
02434 template <typename T>
02435 inline
02436 TransposeTable<T>::TransposeTable (const unsigned int size1,
02437                                    const unsigned int size2)
02438                 :
02439                 TableBase<2,T> (TableIndices<2> (size2, size1))
02440 {}
02441 
02442 
02443 
02444 template <typename T>
02445 inline
02446 void
02447 TransposeTable<T>::reinit (const unsigned int size1,
02448                            const unsigned int size2,
02449                            const bool         fast)
02450 {
02451   this->TableBase<2,T>::reinit (TableIndices<2> (size2, size1),fast);
02452 }
02453 
02454 
02455 
02456 template <typename T>
02457 inline
02458 typename std::vector<T>::const_reference
02459 TransposeTable<T>::operator () (const unsigned int i,
02460                                 const unsigned int j) const
02461 {
02462   Assert (i < this->table_size[1],
02463           ExcIndexRange (i, 0, this->table_size[1]));
02464   Assert (j < this->table_size[0],
02465           ExcIndexRange (j, 0, this->table_size[0]));
02466   return this->values[j*this->table_size[1]+i];
02467 }
02468 
02469 
02470 
02471 template <typename T>
02472 inline
02473 typename std::vector<T>::reference
02474 TransposeTable<T>::operator () (const unsigned int i,
02475                                 const unsigned int j)
02476 {
02477   Assert (i < this->table_size[1],
02478           ExcIndexRange (i, 0, this->table_size[1]));
02479   Assert (j < this->table_size[0],
02480           ExcIndexRange (j, 0, this->table_size[0]));
02481   return this->values[j*this->table_size[1]+i];
02482 }
02483 
02484 
02485 
02486 template <typename T>
02487 inline
02488 typename std::vector<T>::const_reference
02489 TransposeTable<T>::el (const unsigned int i,
02490                        const unsigned int j) const
02491 {
02492   return this->values[j*this->table_size[1]+i];
02493 }
02494 
02495 
02496 
02497 template <typename T>
02498 inline
02499 typename std::vector<T>::reference
02500 TransposeTable<T>::el (const unsigned int i,
02501                        const unsigned int j)
02502 {
02503   return this->values[j*this->table_size[1]+i];
02504 }
02505 
02506 
02507 
02508 template <typename T>
02509 inline
02510 unsigned int
02511 TransposeTable<T>::n_rows () const
02512 {
02513   return this->table_size[1];
02514 }
02515 
02516 
02517 
02518 template <typename T>
02519 inline
02520 unsigned int
02521 TransposeTable<T>::n_cols () const
02522 {
02523   return this->table_size[0];
02524 }
02525 
02526 
02527 
02528 //---------------------------------------------------------------------------
02529 
02530 
02531 template <typename T>
02532 inline
02533 Table<3,T>::Table ()
02534 {}
02535 
02536 
02537 
02538 template <typename T>
02539 inline
02540 Table<3,T>::Table (const unsigned int size1,
02541                    const unsigned int size2,
02542                    const unsigned int size3)
02543                 :
02544                 TableBase<3,T> (TableIndices<3> (size1, size2, size3))
02545 {}
02546 
02547 
02548 
02549 template <typename T>
02550 inline
02551 internal::TableBaseAccessors::Accessor<3,T,true,2>
02552 Table<3,T>::operator [] (const unsigned int i) const
02553 {
02554   Assert (i < this->table_size[0],
02555           ExcIndexRange (i, 0, this->table_size[0]));
02556   const unsigned int subobject_size = this->table_size[1] *
02557                                       this->table_size[2];
02558   return (internal::TableBaseAccessors::Accessor<3,T,true,2>
02559           (*this,
02560            this->values.begin() + i*subobject_size));
02561 }
02562 
02563 
02564 
02565 template <typename T>
02566 inline
02567 internal::TableBaseAccessors::Accessor<3,T,false,2>
02568 Table<3,T>::operator [] (const unsigned int i)
02569 {
02570   Assert (i < this->table_size[0],
02571           ExcIndexRange (i, 0, this->table_size[0]));
02572   const unsigned int subobject_size = this->table_size[1] *
02573                                       this->table_size[2];
02574   return (internal::TableBaseAccessors::Accessor<3,T,false,2>
02575           (*this,
02576            this->values.begin() + i*subobject_size));
02577 }
02578 
02579 
02580 
02581 template <typename T>
02582 inline
02583 typename std::vector<T>::const_reference
02584 Table<3,T>::operator () (const unsigned int i,
02585                          const unsigned int j,
02586                          const unsigned int k) const
02587 {
02588   Assert (i < this->table_size[0],
02589           ExcIndexRange (i, 0, this->table_size[0]));
02590   Assert (j < this->table_size[1],
02591           ExcIndexRange (j, 0, this->table_size[1]));
02592   Assert (k < this->table_size[2],
02593           ExcIndexRange (k, 0, this->table_size[2]));
02594   return this->values[(i*this->table_size[1]+j)
02595                    *this->table_size[2] + k];
02596 }
02597 
02598 
02599 
02600 template <typename T>
02601 inline
02602 typename std::vector<T>::reference
02603 Table<3,T>::operator () (const unsigned int i,
02604                          const unsigned int j,
02605                          const unsigned int k)
02606 {
02607   Assert (i < this->table_size[0],
02608           ExcIndexRange (i, 0, this->table_size[0]));
02609   Assert (j < this->table_size[1],
02610           ExcIndexRange (j, 0, this->table_size[1]));
02611   Assert (k < this->table_size[2],
02612           ExcIndexRange (k, 0, this->table_size[2]));
02613   return this->values[(i*this->table_size[1]+j)
02614                    *this->table_size[2] + k];
02615 }
02616 
02617 
02618 
02619 template <typename T>
02620 inline
02621 typename std::vector<T>::const_reference
02622 Table<3,T>::operator () (const TableIndices<3> &indices) const
02623 {
02624   return TableBase<3,T>::operator () (indices);
02625 }
02626 
02627 
02628 
02629 template <typename T>
02630 inline
02631 typename std::vector<T>::reference
02632 Table<3,T>::operator () (const TableIndices<3> &indices)
02633 {
02634   return TableBase<3,T>::operator () (indices);
02635 }
02636 
02637 
02638 
02639 template <typename T>
02640 inline
02641 Table<4,T>::Table ()
02642 {}
02643 
02644 
02645 
02646 template <typename T>
02647 inline
02648 Table<4,T>::Table (const unsigned int size1,
02649                    const unsigned int size2,
02650                    const unsigned int size3,
02651                    const unsigned int size4)
02652                 :
02653                 TableBase<4,T> (TableIndices<4> (size1, size2, size3, size4))
02654 {}
02655 
02656 
02657 
02658 template <typename T>
02659 inline
02660 internal::TableBaseAccessors::Accessor<4,T,true,3>
02661 Table<4,T>::operator [] (const unsigned int i) const
02662 {
02663   Assert (i < this->table_size[0],
02664           ExcIndexRange (i, 0, this->table_size[0]));
02665   const unsigned int subobject_size = this->table_size[1] *
02666                                       this->table_size[2] *
02667                                       this->table_size[3];
02668   return (internal::TableBaseAccessors::Accessor<4,T,true,3>
02669           (*this,
02670            this->values.begin() + i*subobject_size));
02671 }
02672 
02673 
02674 
02675 template <typename T>
02676 inline
02677 internal::TableBaseAccessors::Accessor<4,T,false,3>
02678 Table<4,T>::operator [] (const unsigned int i)
02679 {
02680   Assert (i < this->table_size[0],
02681           ExcIndexRange (i, 0, this->table_size[0]));
02682   const unsigned int subobject_size = this->table_size[1] *
02683                                       this->table_size[2] *
02684                                       this->table_size[3];
02685   return (internal::TableBaseAccessors::Accessor<4,T,false,3>
02686           (*this,
02687            this->values.begin() + i*subobject_size));
02688 }
02689 
02690 
02691 
02692 template <typename T>
02693 inline
02694 typename std::vector<T>::const_reference
02695 Table<4,T>::operator () (const unsigned int i,
02696                          const unsigned int j,
02697                          const unsigned int k,
02698                          const unsigned int l) const
02699 {
02700   Assert (i < this->table_size[0],
02701           ExcIndexRange (i, 0, this->table_size[0]));
02702   Assert (j < this->table_size[1],
02703           ExcIndexRange (j, 0, this->table_size[1]));
02704   Assert (k < this->table_size[2],
02705           ExcIndexRange (k, 0, this->table_size[2]));
02706   Assert (l < this->table_size[3],
02707           ExcIndexRange (l, 0, this->table_size[3]));
02708   return this->values[((i*this->table_size[1]+j)
02709                     *this->table_size[2] + k)
02710                    *this->table_size[3] + l];
02711 }
02712 
02713 
02714 
02715 template <typename T>
02716 inline
02717 typename std::vector<T>::reference
02718 Table<4,T>::operator () (const unsigned int i,
02719                          const unsigned int j,
02720                          const unsigned int k,
02721                          const unsigned int l)
02722 {
02723   Assert (i < this->table_size[0],
02724           ExcIndexRange (i, 0, this->table_size[0]));
02725   Assert (j < this->table_size[1],
02726           ExcIndexRange (j, 0, this->table_size[1]));
02727   Assert (k < this->table_size[2],
02728           ExcIndexRange (k, 0, this->table_size[2]));
02729   Assert (l < this->table_size[3],
02730           ExcIndexRange (l, 0, this->table_size[3]));
02731   return this->values[((i*this->table_size[1]+j)
02732                     *this->table_size[2] + k)
02733                    *this->table_size[3] + l];
02734 }
02735 
02736 
02737 
02738 template <typename T>
02739 inline
02740 typename std::vector<T>::const_reference
02741 Table<4,T>::operator () (const TableIndices<4> &indices) const
02742 {
02743   return TableBase<4,T>::operator () (indices);
02744 }
02745 
02746 
02747 
02748 template <typename T>
02749 inline
02750 typename std::vector<T>::reference
02751 Table<4,T>::operator () (const TableIndices<4> &indices)
02752 {
02753   return TableBase<4,T>::operator () (indices);
02754 }
02755 
02756 
02757 
02758 template <typename T>
02759 inline
02760 Table<5,T>::Table ()
02761 {}
02762 
02763 
02764 
02765 template <typename T>
02766 inline
02767 Table<5,T>::Table (const unsigned int size1,
02768                    const unsigned int size2,
02769                    const unsigned int size3,
02770                    const unsigned int size4,
02771                    const unsigned int size5)
02772                 :
02773                 TableBase<5,T> (TableIndices<5> (size1, size2, size3, size4, size5))
02774 {}
02775 
02776 
02777 
02778 template <typename T>
02779 inline
02780 internal::TableBaseAccessors::Accessor<5,T,true,4>
02781 Table<5,T>::operator [] (const unsigned int i) const
02782 {
02783   Assert (i < this->table_size[0],
02784           ExcIndexRange (i, 0, this->table_size[0]));
02785   const unsigned int subobject_size = this->table_size[1] *
02786                                       this->table_size[2] *
02787                                       this->table_size[3] *
02788                                       this->table_size[4];
02789   return (internal::TableBaseAccessors::Accessor<5,T,true,4>
02790           (*this,
02791            this->values.begin() + i*subobject_size));
02792 }
02793 
02794 
02795 
02796 template <typename T>
02797 inline
02798 internal::TableBaseAccessors::Accessor<5,T,false,4>
02799 Table<5,T>::operator [] (const unsigned int i)
02800 {
02801   Assert (i < this->table_size[0],
02802           ExcIndexRange (i, 0, this->table_size[0]));
02803   const unsigned int subobject_size = this->table_size[1] *
02804                                       this->table_size[2] *
02805                                       this->table_size[3] *
02806                                       this->table_size[4];
02807   return (internal::TableBaseAccessors::Accessor<5,T,false,4>
02808           (*this,
02809            this->values.begin() + i*subobject_size));
02810 }
02811 
02812 
02813 
02814 template <typename T>
02815 inline
02816 typename std::vector<T>::const_reference
02817 Table<5,T>::operator () (const unsigned int i,
02818                          const unsigned int j,
02819                          const unsigned int k,
02820                          const unsigned int l,
02821                          const unsigned int m) const
02822 {
02823   Assert (i < this->table_size[0],
02824           ExcIndexRange (i, 0, this->table_size[0]));
02825   Assert (j < this->table_size[1],
02826           ExcIndexRange (j, 0, this->table_size[1]));
02827   Assert (k < this->table_size[2],
02828           ExcIndexRange (k, 0, this->table_size[2]));
02829   Assert (l < this->table_size[3],
02830           ExcIndexRange (l, 0, this->table_size[3]));
02831   Assert (m < this->table_size[4],
02832           ExcIndexRange (m, 0, this->table_size[4]));
02833   return this->values[(((i*this->table_size[1]+j)
02834                      *this->table_size[2] + k)
02835                     *this->table_size[3] + l)
02836                    *this->table_size[4] + m];
02837 }
02838 
02839 
02840 
02841 template <typename T>
02842 inline
02843 typename std::vector<T>::reference
02844 Table<5,T>::operator () (const unsigned int i,
02845                          const unsigned int j,
02846                          const unsigned int k,
02847                          const unsigned int l,
02848                          const unsigned int m)
02849 {
02850   Assert (i < this->table_size[0],
02851           ExcIndexRange (i, 0, this->table_size[0]));
02852   Assert (j < this->table_size[1],
02853           ExcIndexRange (j, 0, this->table_size[1]));
02854   Assert (k < this->table_size[2],
02855           ExcIndexRange (k, 0, this->table_size[2]));
02856   Assert (l < this->table_size[3],
02857           ExcIndexRange (l, 0, this->table_size[3]));
02858   Assert (m < this->table_size[4],
02859           ExcIndexRange (m, 0, this->table_size[4]));
02860   return this->values[(((i*this->table_size[1]+j)
02861                      *this->table_size[2] + k)
02862                     *this->table_size[3] + l)
02863                    *this->table_size[4] + m];
02864 }
02865 
02866 
02867 
02868 template <typename T>
02869 inline
02870 typename std::vector<T>::const_reference
02871 Table<5,T>::operator () (const TableIndices<5> &indices) const
02872 {
02873   return TableBase<5,T>::operator () (indices);
02874 }
02875 
02876 
02877 
02878 template <typename T>
02879 inline
02880 typename std::vector<T>::reference
02881 Table<5,T>::operator () (const TableIndices<5> &indices)
02882 {
02883   return TableBase<5,T>::operator () (indices);
02884 }
02885 
02886 
02887 
02888 template <typename T>
02889 inline
02890 Table<6,T>::Table ()
02891 {}
02892 
02893 
02894 
02895 template <typename T>
02896 inline
02897 Table<6,T>::Table (const unsigned int size1,
02898                    const unsigned int size2,
02899                    const unsigned int size3,
02900                    const unsigned int size4,
02901                    const unsigned int size5,
02902                    const unsigned int size6)
02903                 :
02904                 TableBase<6,T> (TableIndices<6> (size1, size2, size3, size4, size5, size6))
02905 {}
02906 
02907 
02908 
02909 template <typename T>
02910 inline
02911 internal::TableBaseAccessors::Accessor<6,T,true,5>
02912 Table<6,T>::operator [] (const unsigned int i) const
02913 {
02914   Assert (i < this->table_size[0],
02915           ExcIndexRange (i, 0, this->table_size[0]));
02916   const unsigned int subobject_size = this->table_size[1] *
02917                                       this->table_size[2] *
02918                                       this->table_size[3] *
02919                                       this->table_size[4] *
02920                                       this->table_size[5];
02921   return (internal::TableBaseAccessors::Accessor<6,T,true,5>
02922           (*this,
02923            this->values.begin() + i*subobject_size));
02924 }
02925 
02926 
02927 
02928 template <typename T>
02929 inline
02930 internal::TableBaseAccessors::Accessor<6,T,false,5>
02931 Table<6,T>::operator [] (const unsigned int i)
02932 {
02933   Assert (i < this->table_size[0],
02934           ExcIndexRange (i, 0, this->table_size[0]));
02935   const unsigned int subobject_size = this->table_size[1] *
02936                                       this->table_size[2] *
02937                                       this->table_size[3] *
02938                                       this->table_size[4] *
02939                                       this->table_size[5];
02940   return (internal::TableBaseAccessors::Accessor<6,T,false,5>
02941           (*this,
02942            this->values.begin() + i*subobject_size));
02943 }
02944 
02945 
02946 
02947 template <typename T>
02948 inline
02949 typename std::vector<T>::const_reference
02950 Table<6,T>::operator () (const unsigned int i,
02951                          const unsigned int j,
02952                          const unsigned int k,
02953                          const unsigned int l,
02954                          const unsigned int m,
02955                          const unsigned int n) const
02956 {
02957   Assert (i < this->table_size[0],
02958           ExcIndexRange (i, 0, this->table_size[0]));
02959   Assert (j < this->table_size[1],
02960           ExcIndexRange (j, 0, this->table_size[1]));
02961   Assert (k < this->table_size[2],
02962           ExcIndexRange (k, 0, this->table_size[2]));
02963   Assert (l < this->table_size[3],
02964           ExcIndexRange (l, 0, this->table_size[3]));
02965   Assert (m < this->table_size[4],
02966           ExcIndexRange (m, 0, this->table_size[4]));
02967   Assert (n < this->table_size[5],
02968           ExcIndexRange (n, 0, this->table_size[5]));
02969   return this->values[((((i*this->table_size[1]+j)
02970                       *this->table_size[2] + k)
02971                      *this->table_size[3] + l)
02972                     *this->table_size[4] + m)
02973                    *this->table_size[5] + n];
02974 }
02975 
02976 
02977 
02978 template <typename T>
02979 inline
02980 typename std::vector<T>::reference
02981 Table<6,T>::operator () (const unsigned int i,
02982                          const unsigned int j,
02983                          const unsigned int k,
02984                          const unsigned int l,
02985                          const unsigned int m,
02986                          const unsigned int n)
02987 {
02988   Assert (i < this->table_size[0],
02989           ExcIndexRange (i, 0, this->table_size[0]));
02990   Assert (j < this->table_size[1],
02991           ExcIndexRange (j, 0, this->table_size[1]));
02992   Assert (k < this->table_size[2],
02993           ExcIndexRange (k, 0, this->table_size[2]));
02994   Assert (l < this->table_size[3],
02995           ExcIndexRange (l, 0, this->table_size[3]));
02996   Assert (m < this->table_size[4],
02997           ExcIndexRange (m, 0, this->table_size[4]));
02998   Assert (n < this->table_size[5],
02999           ExcIndexRange (n, 0, this->table_size[5]));
03000   return this->values[((((i*this->table_size[1]+j)
03001                       *this->table_size[2] + k)
03002                      *this->table_size[3] + l)
03003                     *this->table_size[4] + m)
03004                    *this->table_size[5] + n];
03005 }
03006 
03007 
03008 
03009 template <typename T>
03010 inline
03011 typename std::vector<T>::const_reference
03012 Table<6,T>::operator () (const TableIndices<6> &indices) const
03013 {
03014   return TableBase<6,T>::operator () (indices);
03015 }
03016 
03017 
03018 
03019 template <typename T>
03020 inline
03021 typename std::vector<T>::reference
03022 Table<6,T>::operator () (const TableIndices<6> &indices)
03023 {
03024   return TableBase<6,T>::operator () (indices);
03025 }
03026 
03027 
03028 
03029 template <typename T>
03030 inline
03031 Table<7,T>::Table ()
03032 {}
03033 
03034 
03035 
03036 template <typename T>
03037 inline
03038 Table<7,T>::Table (const unsigned int size1,
03039                    const unsigned int size2,
03040                    const unsigned int size3,
03041                    const unsigned int size4,
03042                    const unsigned int size5,
03043                    const unsigned int size6,
03044                    const unsigned int size7)
03045                 :
03046                 TableBase<7,T> (TableIndices<7> (size1, size2, size3, size4, size5, size6, size7))
03047 {}
03048 
03049 
03050 
03051 template <typename T>
03052 inline
03053 internal::TableBaseAccessors::Accessor<7,T,true,6>
03054 Table<7,T>::operator [] (const unsigned int i) const
03055 {
03056   Assert (i < this->table_size[0],
03057           ExcIndexRange (i, 0, this->table_size[0]));
03058   const unsigned int subobject_size = this->table_size[1] *
03059                                       this->table_size[2] *
03060                                       this->table_size[3] *
03061                                       this->table_size[4] *
03062                                       this->table_size[5] *
03063                                       this->table_size[6];
03064   return (internal::TableBaseAccessors::Accessor<7,T,true,6>
03065           (*this,
03066            this->values.begin() + i*subobject_size));
03067 }
03068 
03069 
03070 
03071 template <typename T>
03072 inline
03073 internal::TableBaseAccessors::Accessor<7,T,false,6>
03074 Table<7,T>::operator [] (const unsigned int i)
03075 {
03076   Assert (i < this->table_size[0],
03077           ExcIndexRange (i, 0, this->table_size[0]));
03078   const unsigned int subobject_size = this->table_size[1] *
03079                                       this->table_size[2] *
03080                                       this->table_size[3] *
03081                                       this->table_size[4] *
03082                                       this->table_size[5] *
03083                                       this->table_size[6];
03084   return (internal::TableBaseAccessors::Accessor<7,T,false,6>
03085           (*this,
03086            this->values.begin() + i*subobject_size));
03087 }
03088 
03089 
03090 
03091 template <typename T>
03092 inline
03093 typename std::vector<T>::const_reference
03094 Table<7,T>::operator () (const unsigned int i,
03095                          const unsigned int j,
03096                          const unsigned int k,
03097                          const unsigned int l,
03098                          const unsigned int m,
03099                          const unsigned int n,
03100                          const unsigned int o) const
03101 {
03102   Assert (i < this->table_size[0],
03103           ExcIndexRange (i, 0, this->table_size[0]));
03104   Assert (j < this->table_size[1],
03105           ExcIndexRange (j, 0, this->table_size[1]));
03106   Assert (k < this->table_size[2],
03107           ExcIndexRange (k, 0, this->table_size[2]));
03108   Assert (l < this->table_size[3],
03109           ExcIndexRange (l, 0, this->table_size[3]));
03110   Assert (m < this->table_size[4],
03111           ExcIndexRange (m, 0, this->table_size[4]));
03112   Assert (n < this->table_size[5],
03113           ExcIndexRange (n, 0, this->table_size[5]));
03114   Assert (o < this->table_size[6],
03115           ExcIndexRange (o, 0, this->table_size[6]));
03116   return this->values[(((((i*this->table_size[1]+j)
03117                        *this->table_size[2] + k)
03118                       *this->table_size[3] + l)
03119                      *this->table_size[4] + m)
03120                     *this->table_size[5] + n)
03121                    *this->table_size[6] + o];
03122 }
03123 
03124 
03125 
03126 template <typename T>
03127 inline
03128 typename std::vector<T>::reference
03129 Table<7,T>::operator () (const unsigned int i,
03130                          const unsigned int j,
03131                          const unsigned int k,
03132                          const unsigned int l,
03133                          const unsigned int m,
03134                          const unsigned int n,
03135                          const unsigned int o)
03136 {
03137   Assert (i < this->table_size[0],
03138           ExcIndexRange (i, 0, this->table_size[0]));
03139   Assert (j < this->table_size[1],
03140           ExcIndexRange (j, 0, this->table_size[1]));
03141   Assert (k < this->table_size[2],
03142           ExcIndexRange (k, 0, this->table_size[2]));
03143   Assert (l < this->table_size[3],
03144           ExcIndexRange (l, 0, this->table_size[3]));
03145   Assert (m < this->table_size[4],
03146           ExcIndexRange (m, 0, this->table_size[4]));
03147   Assert (n < this->table_size[5],
03148           ExcIndexRange (n, 0, this->table_size[5]));
03149   Assert (o < this->table_size[5],
03150           ExcIndexRange (o, 0, this->table_size[6]));
03151   return this->values[(((((i*this->table_size[1]+j)
03152                        *this->table_size[2] + k)
03153                       *this->table_size[3] + l)
03154                      *this->table_size[4] + m)
03155                     *this->table_size[5] + n)
03156                    *this->table_size[6] + o];
03157 }
03158 
03159 
03160 
03161 template <typename T>
03162 inline
03163 typename std::vector<T>::const_reference
03164 Table<7,T>::operator () (const TableIndices<7> &indices) const
03165 {
03166   return TableBase<7,T>::operator () (indices);
03167 }
03168 
03169 
03170 
03171 template <typename T>
03172 inline
03173 typename std::vector<T>::reference
03174 Table<7,T>::operator () (const TableIndices<7> &indices)
03175 {
03176   return TableBase<7,T>::operator () (indices);
03177 }
03178 
03179 
03180 #endif // DOXYGEN
03181 DEAL_II_NAMESPACE_CLOSE
03182 
03183 #endif
03184 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Wed May 23 2012 12:03:21 by doxygen 1.7.3