Reference documentation for deal.II version 8.1.0
table.h
1 // ---------------------------------------------------------------------
2 // @f$Id: table.h 30036 2013-07-18 16:55:32Z maier @f$
3 //
4 // Copyright (C) 2002 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 #ifndef __deal2__table_h
18 #define __deal2__table_h
19 
20 #include <deal.II/base/config.h>
22 #include <deal.II/base/subscriptor.h>
23 #include <deal.II/base/table_indices.h>
24 #include <deal.II/base/memory_consumption.h>
25 
26 #include <cstddef>
27 #include <algorithm>
28 
30 
31 // forward declaration
32 template <int N, typename T> class TableBase;
33 template <int N, typename T> class Table;
34 template <typename T> class Table<1,T>;
35 template <typename T> class Table<2,T>;
36 template <typename T> class Table<3,T>;
37 template <typename T> class Table<4,T>;
38 template <typename T> class Table<5,T>;
39 template <typename T> class Table<6,T>;
40 
41 
42 
43 namespace internal
44 {
45 
64  namespace TableBaseAccessors
65  {
74  template <int N, typename T, bool Constness>
75  struct Types
76  {};
77 
84  template <int N, typename T> struct Types<N,T,true>
85  {
86  typedef const T value_type;
87  typedef const TableBase<N,T> TableType;
88 
89  typedef typename std::vector<T>::const_iterator iterator;
90  typedef typename std::vector<T>::const_iterator const_iterator;
91 
92  typedef typename std::vector<T>::const_reference reference;
93  typedef typename std::vector<T>::const_reference const_reference;
94  };
95 
102  template <int N, typename T> struct Types<N,T,false>
103  {
104  typedef T value_type;
105  typedef TableBase<N,T> TableType;
106 
107  typedef typename std::vector<T>::iterator iterator;
108  typedef typename std::vector<T>::const_iterator const_iterator;
109 
110  typedef typename std::vector<T>::reference reference;
111  typedef typename std::vector<T>::const_reference const_reference;
112  };
113 
114 
154  template <int N, typename T, bool C, unsigned int P>
155  class Accessor
156  {
157  public:
158  typedef typename Types<N,T,C>::TableType TableType;
159 
160  typedef typename Types<N,T,C>::iterator iterator;
161  typedef typename Types<N,T,C>::const_iterator const_iterator;
162 
163  private:
172  Accessor (const TableType &table,
173  const iterator data);
174 
180  Accessor ();
181 
182  public:
183 
196  Accessor (const Accessor &a);
197 
202  Accessor<N,T,C,P-1> operator [] (const unsigned int i) const;
203 
211  DeclException3 (ExcIndexRange, int, int, int,
212  << "Index " << N-P+1 << "has a value of "
213  << arg1 << " but needs to be in the range ["
214  << arg2 << "," << arg3 << "[");
215  private:
224  const TableType &table;
225  const iterator data;
226 
227  // declare some other classes
228  // as friends. make sure to
229  // work around bugs in some
230  // compilers
231  template <int N1, typename T1> friend class ::Table;
232  template <int N1, typename T1, bool C1, unsigned int P1>
233  friend class Accessor;
234 # ifndef DEAL_II_TEMPL_SPEC_FRIEND_BUG
235  friend class ::Table<N,T>;
236  friend class Accessor<N,T,C,P+1>;
237 # endif
238  };
239 
240 
241 
252  template <int N, typename T, bool C>
253  class Accessor<N,T,C,1>
254  {
255  public:
266 
267  typedef typename Types<N,T,C>::iterator iterator;
268  typedef typename Types<N,T,C>::const_iterator const_iterator;
269 
270  typedef typename Types<N,T,C>::reference reference;
271  typedef typename Types<N,T,C>::const_reference const_reference;
272 
273  typedef size_t size_type;
274  typedef ptrdiff_t difference_type;
275 
281 
282  private:
283 
308  Accessor (const TableType &table,
309  const iterator data);
310 
315  Accessor ();
316 
317  public:
330  Accessor (const Accessor &a);
331 
332 
337  reference operator [] (const unsigned int) const;
338 
345  unsigned int size () const;
346 
352  iterator begin () const;
353 
359  iterator end () const;
360 
361  private:
370  const TableType &table;
371  const iterator data;
372 
373  // declare some other classes
374  // as friends. make sure to
375  // work around bugs in some
376  // compilers
377  template <int N1, typename T1> friend class ::Table;
378  template <int N1, typename T1, bool C1, unsigned int P1>
379  friend class Accessor;
380 # ifndef DEAL_II_TEMPL_SPEC_FRIEND_BUG
381  friend class ::Table<2,T>;
382  friend class Accessor<N,T,C,2>;
383 # endif
384  };
385  }
386 
387 } // namespace internal
388 
389 
390 
391 
466 template <int N, typename T>
467 class TableBase : public Subscriptor
468 {
469 public:
474  TableBase ();
475 
482  TableBase (const TableIndices<N> &sizes);
483 
488  TableBase (const TableBase<N,T> &src);
489 
495  template <typename T2>
496  TableBase (const TableBase<N,T2> &src);
497 
501  ~TableBase ();
502 
516 
527  template<typename T2>
529 
533  bool operator == (const TableBase<N,T> &T2) const;
534 
542  void reset_values ();
543 
553  void reinit (const TableIndices<N> &new_size,
554  const bool fast = false);
555 
560  unsigned int size (const unsigned int i) const;
561 
566  const TableIndices<N> &size () const;
567 
574  unsigned int n_elements () const;
575 
583  bool empty () const;
584 
609  template<typename T2>
610  void fill (const T2 *entries);
611 
616  void fill (const T &value);
617 
622  typename std::vector<T>::reference
623  operator () (const TableIndices<N> &indices);
624 
638  typename std::vector<T>::const_reference
639  operator () (const TableIndices<N> &indices) const;
640 
652  void swap (TableBase<N,T> &v);
653 
658  std::size_t memory_consumption () const;
659 
664  template <class Archive>
665  void serialize (Archive &ar, const unsigned int version);
666 
667 protected:
675  unsigned int position (const TableIndices<N> &indices) const;
676 
686  typename std::vector<T>::reference el (const TableIndices<N> &indices);
687 
706  typename std::vector<T>::const_reference el (const TableIndices<N> &indices) const;
707 
720  typename std::vector<T>::const_pointer data () const DEAL_II_DEPRECATED;
721 
722 protected:
726  std::vector<T> values;
727 
733 
738  template <int, typename> friend class TableBase;
739 };
740 
741 
756 template <int N,typename T>
757 class Table : public TableBase<N,T>
758 {
759 };
760 
761 
775 template <typename T>
776 class Table<1,T> : public TableBase<1,T>
777 {
778 public:
783  Table ();
784 
790  Table (const unsigned int size);
791 
799  typename std::vector<T>::const_reference
800  operator [] (const unsigned int i) const;
801 
809  typename std::vector<T>::reference
810  operator [] (const unsigned int i);
811 
819  typename std::vector<T>::const_reference
820  operator () (const unsigned int i) const;
821 
829  typename std::vector<T>::reference
830  operator () (const unsigned int i);
831 
838  typename std::vector<T>::reference
839  operator () (const TableIndices<1> &indices);
840 
847  typename std::vector<T>::const_reference
848  operator () (const TableIndices<1> &indices) const;
849 };
850 
851 
852 
866 template <typename T>
867 class Table<2,T> : public TableBase<2,T>
868 {
869 public:
874  Table ();
875 
881  Table (const unsigned int size1,
882  const unsigned int size2);
883 
894  void reinit (const unsigned int size1,
895  const unsigned int size2,
896  const bool fast = false);
897 
909  operator [] (const unsigned int i) const;
910 
922  operator [] (const unsigned int i);
923 
933  typename std::vector<T>::const_reference
934  operator () (const unsigned int i,
935  const unsigned int j) const;
936 
937 
947  typename std::vector<T>::reference
948  operator () (const unsigned int i,
949  const unsigned int j);
950 
957  typename std::vector<T>::reference
958  operator () (const TableIndices<2> &indices);
959 
966  typename std::vector<T>::const_reference
967  operator () (const TableIndices<2> &indices) const;
968 
969 
976  unsigned int n_rows () const;
977 
984  unsigned int n_cols () const;
985 
986 protected:
1002  typename std::vector<T>::reference el (const unsigned int i,
1003  const unsigned int j);
1004 
1029  typename std::vector<T>::const_reference el (const unsigned int i,
1030  const unsigned int j) const;
1031 };
1032 
1033 
1034 
1045 template <typename T>
1046 class Table<3,T> : public TableBase<3,T>
1047 {
1048 public:
1053  Table ();
1054 
1060  Table (const unsigned int size1,
1061  const unsigned int size2,
1062  const unsigned int size3);
1063 
1076  operator [] (const unsigned int i) const;
1077 
1090  operator [] (const unsigned int i);
1091 
1101  typename std::vector<T>::const_reference operator () (const unsigned int i,
1102  const unsigned int j,
1103  const unsigned int k) const;
1104 
1105 
1115  typename std::vector<T>::reference operator () (const unsigned int i,
1116  const unsigned int j,
1117  const unsigned int k);
1118 
1125  typename std::vector<T>::reference operator () (const TableIndices<3> &indices);
1126 
1133  typename std::vector<T>::const_reference operator () (const TableIndices<3> &indices) const;
1134 };
1135 
1136 
1137 
1148 template <typename T>
1149 class Table<4,T> : public TableBase<4,T>
1150 {
1151 public:
1156  Table ();
1157 
1163  Table (const unsigned int size1,
1164  const unsigned int size2,
1165  const unsigned int size3,
1166  const unsigned int size4);
1167 
1180  operator [] (const unsigned int i) const;
1181 
1194  operator [] (const unsigned int i);
1195 
1205  typename std::vector<T>::const_reference operator () (const unsigned int i,
1206  const unsigned int j,
1207  const unsigned int k,
1208  const unsigned int l) const;
1209 
1210 
1220  typename std::vector<T>::reference operator () (const unsigned int i,
1221  const unsigned int j,
1222  const unsigned int k,
1223  const unsigned int l);
1224 
1231  typename std::vector<T>::reference
1232  operator () (const TableIndices<4> &indices);
1233 
1240  typename std::vector<T>::const_reference
1241  operator () (const TableIndices<4> &indices) const;
1242 };
1243 
1244 
1245 
1256 template <typename T>
1257 class Table<5,T> : public TableBase<5,T>
1258 {
1259 public:
1264  Table ();
1265 
1271  Table (const unsigned int size1,
1272  const unsigned int size2,
1273  const unsigned int size3,
1274  const unsigned int size4,
1275  const unsigned int size5);
1276 
1289  operator [] (const unsigned int i) const;
1290 
1303  operator [] (const unsigned int i);
1304 
1314  typename std::vector<T>::const_reference operator () (const unsigned int i,
1315  const unsigned int j,
1316  const unsigned int k,
1317  const unsigned int l,
1318  const unsigned int m) const;
1319 
1329  typename std::vector<T>::reference operator () (const unsigned int i,
1330  const unsigned int j,
1331  const unsigned int k,
1332  const unsigned int l,
1333  const unsigned int m);
1334 
1341  typename std::vector<T>::reference
1342  operator () (const TableIndices<5> &indices);
1343 
1350  typename std::vector<T>::const_reference
1351  operator () (const TableIndices<5> &indices) const;
1352 };
1353 
1354 
1355 
1366 template <typename T>
1367 class Table<6,T> : public TableBase<6,T>
1368 {
1369 public:
1374  Table ();
1375 
1381  Table (const unsigned int size1,
1382  const unsigned int size2,
1383  const unsigned int size3,
1384  const unsigned int size4,
1385  const unsigned int size5,
1386  const unsigned int size6);
1387 
1400  operator [] (const unsigned int i) const;
1401 
1414  operator [] (const unsigned int i);
1415 
1425  typename std::vector<T>::const_reference operator () (const unsigned int i,
1426  const unsigned int j,
1427  const unsigned int k,
1428  const unsigned int l,
1429  const unsigned int m,
1430  const unsigned int n) const;
1431 
1441  typename std::vector<T>::reference operator () (const unsigned int i,
1442  const unsigned int j,
1443  const unsigned int k,
1444  const unsigned int l,
1445  const unsigned int m,
1446  const unsigned int n);
1447 
1454  typename std::vector<T>::reference
1455  operator () (const TableIndices<6> &indices);
1456 
1463  typename std::vector<T>::const_reference
1464  operator () (const TableIndices<6> &indices) const;
1465 };
1466 
1467 
1478 template <typename T>
1479 class Table<7,T> : public TableBase<7,T>
1480 {
1481 public:
1486  Table ();
1487 
1493  Table (const unsigned int size1,
1494  const unsigned int size2,
1495  const unsigned int size3,
1496  const unsigned int size4,
1497  const unsigned int size5,
1498  const unsigned int size6,
1499  const unsigned int size7);
1500 
1513  operator [] (const unsigned int i) const;
1514 
1527  operator [] (const unsigned int i);
1528 
1538  typename std::vector<T>::const_reference operator () (const unsigned int i,
1539  const unsigned int j,
1540  const unsigned int k,
1541  const unsigned int l,
1542  const unsigned int m,
1543  const unsigned int n,
1544  const unsigned int o) const;
1545 
1555  typename std::vector<T>::reference operator () (const unsigned int i,
1556  const unsigned int j,
1557  const unsigned int k,
1558  const unsigned int l,
1559  const unsigned int m,
1560  const unsigned int n,
1561  const unsigned int o);
1562 
1569  typename std::vector<T>::reference
1570  operator () (const TableIndices<7> &indices);
1571 
1578  typename std::vector<T>::const_reference
1579  operator () (const TableIndices<7> &indices) const;
1580 };
1581 
1582 
1583 
1597 template <typename T>
1598 class TransposeTable : public TableBase<2,T>
1599 {
1600 public:
1605  TransposeTable ();
1606 
1612  TransposeTable (const unsigned int size1,
1613  const unsigned int size2);
1614 
1625  void reinit (const unsigned int size1,
1626  const unsigned int size2,
1627  const bool fast = false);
1628 
1638  typename std::vector<T>::const_reference operator () (const unsigned int i,
1639  const unsigned int j) const;
1640 
1650  typename std::vector<T>::reference operator () (const unsigned int i,
1651  const unsigned int j);
1652 
1659  unsigned int n_rows () const;
1660 
1667  unsigned int n_cols () const;
1668 
1669 protected:
1685  typename std::vector<T>::reference el (const unsigned int i,
1686  const unsigned int j);
1687 
1712  typename std::vector<T>::const_reference el (const unsigned int i,
1713  const unsigned int j) const;
1714 };
1715 
1716 
1717 
1718 
1719 /* --------------------- Template and inline functions ---------------- */
1720 
1721 #ifndef DOXYGEN
1722 
1723 template <int N, typename T>
1725 {}
1726 
1727 
1728 
1729 template <int N, typename T>
1731 {
1732  reinit (sizes);
1733 }
1734 
1735 
1736 
1737 template <int N, typename T>
1739  :
1740  Subscriptor ()
1741 {
1742  reinit (src.table_size);
1743  if (src.n_elements() != 0)
1744  std::copy (src.values.begin(), src.values.end(), values.begin());
1745 }
1746 
1747 
1748 
1749 template <int N, typename T>
1750 template <typename T2>
1752 {
1753  reinit (src.table_size);
1754  if (src.n_elements() != 0)
1755  std::copy (src.values.begin(), src.values.end(), values.begin());
1756 }
1757 
1758 
1759 
1760 template <int N, typename T>
1761 template <class Archive>
1762 inline
1763 void
1764 TableBase<N,T>::serialize (Archive &ar, const unsigned int)
1765 {
1766  ar &static_cast<Subscriptor &>(*this);
1767 
1768  ar &values &table_size;
1769 }
1770 
1771 
1772 
1773 namespace internal
1774 {
1775  namespace TableBaseAccessors
1776  {
1777  template <int N, typename T, bool C, unsigned int P>
1778  inline
1779  Accessor<N,T,C,P>::Accessor (const TableType &table,
1780  const iterator data)
1781  :
1782  table (table),
1783  data (data)
1784  {}
1785 
1786 
1787 
1788  template <int N, typename T, bool C, unsigned int P>
1789  inline
1790  Accessor<N,T,C,P>::Accessor (const Accessor &a)
1791  :
1792  table (a.table),
1793  data (a.data)
1794  {}
1795 
1796 
1797 
1798  template <int N, typename T, bool C, unsigned int P>
1799  inline
1800  Accessor<N,T,C,P>::Accessor ()
1801  :
1802  table (*static_cast<const TableType *>(0)),
1803  data (0)
1804  {
1805  // accessor objects are only
1806  // temporary objects, so should
1807  // not need to be copied around
1808  Assert (false, ExcInternalError());
1809  }
1810 
1811 
1812 
1813  template <int N, typename T, bool C, unsigned int P>
1814  inline
1815  Accessor<N,T,C,P-1>
1816  Accessor<N,T,C,P>::operator [] (const unsigned int i) const
1817  {
1818  Assert (i < table.size()[N-P],
1819  ExcIndexRange (i, 0, table.size()[N-P]));
1820 
1821  // access i-th
1822  // subobject. optimize on the
1823  // case i==0
1824  if (i==0)
1825  return Accessor<N,T,C,P-1> (table, data);
1826  else
1827  {
1828  // note: P>1, otherwise the
1829  // specialization would have
1830  // been taken!
1831  unsigned int subobject_size = table.size()[N-1];
1832  for (int p=P-1; p>1; --p)
1833  subobject_size *= table.size()[N-p];
1834  const iterator new_data = data + i*subobject_size;
1835  return Accessor<N,T,C,P-1> (table, new_data);
1836  }
1837  }
1838 
1839 
1840 
1841  template <int N, typename T, bool C>
1842  inline
1843  Accessor<N,T,C,1>::Accessor (const TableType &table,
1844  const iterator data)
1845  :
1846  table (table),
1847  data (data)
1848  {}
1849 
1850 
1851 
1852  template <int N, typename T, bool C>
1853  inline
1854  Accessor<N,T,C,1>::Accessor ()
1855  :
1856  table (*static_cast<const TableType *>(0)),
1857  data (0)
1858  {
1859  // accessor objects are only
1860  // temporary objects, so should
1861  // not need to be copied around
1862  Assert (false, ExcInternalError());
1863  }
1864 
1865 
1866 
1867  template <int N, typename T, bool C>
1868  inline
1869  Accessor<N,T,C,1>::Accessor (const Accessor &a)
1870  :
1871  table (a.table),
1872  data (a.data)
1873  {}
1874 
1875 
1876 
1877  template <int N, typename T, bool C>
1878  inline
1879  typename Accessor<N,T,C,1>::reference
1880  Accessor<N,T,C,1>::operator [] (const unsigned int i) const
1881  {
1882  Assert (i < table.size()[N-1],
1883  ExcIndexRange (i, 0, table.size()[N-1]));
1884  return *(data+i);
1885  }
1886 
1887 
1888 
1889  template <int N, typename T, bool C>
1890  inline
1891  unsigned int
1892  Accessor<N,T,C,1>::size () const
1893  {
1894  return table.size()[N-1];
1895  }
1896 
1897 
1898 
1899  template <int N, typename T, bool C>
1900  inline
1901  typename Accessor<N,T,C,1>::iterator
1902  Accessor<N,T,C,1>::begin () const
1903  {
1904  return data;
1905  }
1906 
1907 
1908 
1909  template <int N, typename T, bool C>
1910  inline
1911  typename Accessor<N,T,C,1>::iterator
1912  Accessor<N,T,C,1>::end () const
1913  {
1914  return data+table.size()[N-1];
1915  }
1916  }
1917 }
1918 
1919 
1920 
1921 template <int N, typename T>
1922 inline
1924 {}
1925 
1926 
1927 
1928 template <int N, typename T>
1929 inline
1932 {
1933  reinit (m.size());
1934  if (!empty())
1935  std::copy (m.values.begin(), m.values.end(), values.begin());
1936 
1937  return *this;
1938 }
1939 
1940 
1941 
1942 template <int N, typename T>
1943 template <typename T2>
1944 inline
1947 {
1948  reinit (m.size());
1949  if (!empty())
1950  std::copy (m.values.begin(), m.values.begin() + n_elements(),
1951  values.begin());
1952 
1953  return *this;
1954 }
1955 
1956 
1957 template <int N, typename T>
1958 inline
1959 bool
1961 {
1962  return (values == T2.values);
1963 }
1964 
1965 
1966 
1967 template <int N, typename T>
1968 inline
1969 void
1971 {
1972  if (n_elements() != 0)
1973  std::fill (values.begin(), values.end(), T());
1974 }
1975 
1976 
1977 
1978 template <int N, typename T>
1979 inline
1980 void
1981 TableBase<N,T>::fill (const T &value)
1982 {
1983  if (n_elements() != 0)
1984  std::fill (values.begin(), values.end(), value);
1985 }
1986 
1987 
1988 
1989 
1990 template <int N, typename T>
1991 inline
1992 void
1993 TableBase<N,T>::reinit (const TableIndices<N> &new_sizes,
1994  const bool fast)
1995 {
1996  table_size = new_sizes;
1997 
1998  const unsigned int new_size = n_elements();
1999 
2000  // if zero size was given: free all
2001  // memory
2002  if (new_size == 0)
2003  {
2004  values.resize (0);
2005  // set all sizes to zero, even
2006  // if one was previously
2007  // nonzero. This simplifies
2008  // some assertions.
2009  table_size = TableIndices<N>();
2010 
2011  return;
2012  }
2013 
2014  // if new size is nonzero:
2015  // if necessary allocate
2016  // additional memory
2017  values.resize (new_size);
2018 
2019  // reinitialize contents of old or
2020  // new memory. note that we
2021  // actually need to do this here,
2022  // even in the case that we
2023  // reallocated memory, since per
2024  // C++ standard, clause 5.3.4/15
2025  // the newly allocated objects are
2026  // only default initialized by
2027  // operator new[] if they are
2028  // non-POD type. In other words, if
2029  // we have a table of doubles, then
2030  // their values after calling 'new
2031  // double[val_size]' is
2032  // indetermined.
2033  if (fast == false)
2034  reset_values ();
2035 }
2036 
2037 
2038 
2039 template <int N, typename T>
2040 inline
2041 const TableIndices<N> &
2042 TableBase<N,T>::size () const
2043 {
2044  return table_size;
2045 }
2046 
2047 
2048 
2049 template <int N, typename T>
2050 inline
2051 unsigned int
2052 TableBase<N,T>::size (const unsigned int i) const
2053 {
2054  Assert (i<N, ExcIndexRange(i,0,N));
2055  return table_size[i];
2056 }
2057 
2058 
2059 
2060 template <int N, typename T>
2061 inline
2062 unsigned int
2064 {
2065  unsigned int s = 1;
2066  for (unsigned int n=0; n<N; ++n)
2067  s *= table_size[n];
2068  return s;
2069 }
2070 
2071 
2072 
2073 template <int N, typename T>
2074 inline
2075 bool
2076 TableBase<N,T>::empty () const
2077 {
2078  return (n_elements() == 0);
2079 }
2080 
2081 
2082 
2083 template <int N, typename T>
2084 template <typename T2>
2085 inline
2086 void
2087 TableBase<N,T>::fill (const T2 *entries)
2088 {
2089  Assert (n_elements() != 0,
2090  ExcMessage("Trying to fill an empty matrix."));
2091 
2092  std::copy (entries, entries+n_elements(), values.begin());
2093 }
2094 
2095 
2096 
2097 template <int N, typename T>
2098 inline
2099 void
2101 {
2102  values.swap(v.values);
2103  std::swap (table_size, v.table_size);
2104 }
2105 
2106 
2107 
2108 template <int N, typename T>
2109 inline
2110 std::size_t
2112 {
2113  return sizeof(*this) + MemoryConsumption::memory_consumption(values);
2114 }
2115 
2116 
2117 
2118 template <int N, typename T>
2119 inline
2120 unsigned int
2121 TableBase<N,T>::position (const TableIndices<N> &indices) const
2122 {
2123  // specialize this for the
2124  // different numbers of dimensions,
2125  // to make the job somewhat easier
2126  // for the compiler. have the
2127  // general formula nevertheless:
2128  switch (N)
2129  {
2130  case 1:
2131  return indices[0];
2132  case 2:
2133  return indices[0]*table_size[1] + indices[1];
2134  case 3:
2135  return ((indices[0]*table_size[1] + indices[1])*table_size[2]
2136  + indices[2]);
2137  default:
2138  {
2139  unsigned int s = indices[0];
2140  for (unsigned int n=1; n<N; ++n)
2141  s = s*table_size[n] + indices[n];
2142  return s;
2143  }
2144  }
2145 }
2146 
2147 
2148 
2149 template <int N, typename T>
2150 inline
2151 typename std::vector<T>::const_reference
2152 TableBase<N,T>::operator () (const TableIndices<N> &indices) const
2153 {
2154  for (unsigned int n=0; n<N; ++n)
2155  Assert (indices[n] < table_size[n],
2156  ExcIndexRange (indices[n], 0, table_size[n]));
2157  return el(indices);
2158 }
2159 
2160 
2161 
2162 template <int N, typename T>
2163 inline
2164 typename std::vector<T>::reference
2166 {
2167  for (unsigned int n=0; n<N; ++n)
2168  Assert (indices[n] < table_size[n],
2169  ExcIndexRange (indices[n], 0, table_size[n]));
2170  return el(indices);
2171 }
2172 
2173 
2174 
2175 template <int N, typename T>
2176 inline
2177 typename std::vector<T>::const_reference
2178 TableBase<N,T>::el (const TableIndices<N> &indices) const
2179 {
2180  return values[position(indices)];
2181 }
2182 
2183 
2184 
2185 template <int N, typename T>
2186 inline
2187 typename std::vector<T>::reference
2188 TableBase<N,T>::el (const TableIndices<N> &indices)
2189 {
2190  Assert (position(indices) < values.size(),
2191  ExcIndexRange (position(indices), 0, values.size()));
2192  return values[position(indices)];
2193 }
2194 
2195 
2196 
2197 template <int N, typename T>
2198 inline
2199 typename std::vector<T>::const_pointer
2200 TableBase<N,T>::data () const
2201 {
2202  if (values.size() == 0)
2203  return typename std::vector<T>::const_pointer();
2204  else
2205  return &values[0];
2206 }
2207 
2208 
2209 
2210 
2211 template <typename T>
2212 inline
2214 {}
2215 
2216 
2217 
2218 template <typename T>
2219 inline
2220 Table<1,T>::Table (const unsigned int size)
2221  :
2222  TableBase<1,T> (TableIndices<1> (size))
2223 {}
2224 
2225 
2226 
2227 template <typename T>
2228 inline
2229 typename std::vector<T>::const_reference
2230 Table<1,T>::operator [] (const unsigned int i) const
2231 {
2232  Assert (i < this->table_size[0],
2233  ExcIndexRange (i, 0, this->table_size[0]));
2234  return this->values[i];
2235 }
2236 
2237 
2238 
2239 template <typename T>
2240 inline
2241 typename std::vector<T>::reference
2242 Table<1,T>::operator [] (const unsigned int i)
2243 {
2244  Assert (i < this->table_size[0],
2245  ExcIndexRange (i, 0, this->table_size[0]));
2246  return this->values[i];
2247 }
2248 
2249 
2250 
2251 template <typename T>
2252 inline
2253 typename std::vector<T>::const_reference
2254 Table<1,T>::operator () (const unsigned int i) const
2255 {
2256  Assert (i < this->table_size[0],
2257  ExcIndexRange (i, 0, this->table_size[0]));
2258  return this->values[i];
2259 }
2260 
2261 
2262 
2263 template <typename T>
2264 inline
2265 typename std::vector<T>::reference
2266 Table<1,T>::operator () (const unsigned int i)
2267 {
2268  Assert (i < this->table_size[0],
2269  ExcIndexRange (i, 0, this->table_size[0]));
2270  return this->values[i];
2271 }
2272 
2273 
2274 
2275 template <typename T>
2276 inline
2277 typename std::vector<T>::const_reference
2278 Table<1,T>::operator () (const TableIndices<1> &indices) const
2279 {
2280  return TableBase<1,T>::operator () (indices);
2281 }
2282 
2283 
2284 
2285 template <typename T>
2286 inline
2287 typename std::vector<T>::reference
2289 {
2290  return TableBase<1,T>::operator () (indices);
2291 }
2292 
2293 
2294 //---------------------------------------------------------------------------
2295 
2296 template <typename T>
2297 inline
2299 {}
2300 
2301 
2302 
2303 template <typename T>
2304 inline
2305 Table<2,T>::Table (const unsigned int size1,
2306  const unsigned int size2)
2307  :
2308  TableBase<2,T> (TableIndices<2> (size1, size2))
2309 {}
2310 
2311 
2312 
2313 template <typename T>
2314 inline
2315 void
2316 Table<2,T>::reinit (const unsigned int size1,
2317  const unsigned int size2,
2318  const bool fast)
2319 {
2320  this->TableBase<2,T>::reinit (TableIndices<2> (size1, size2),fast);
2321 }
2322 
2323 
2324 
2325 template <typename T>
2326 inline
2327 ::internal::TableBaseAccessors::Accessor<2,T,true,1>
2328 Table<2,T>::operator [] (const unsigned int i) const
2329 {
2330  Assert (i < this->table_size[0],
2331  ExcIndexRange (i, 0, this->table_size[0]));
2332  return ::internal::TableBaseAccessors::Accessor<2,T,true,1>(*this,
2333  this->values.begin()+i*n_cols());
2334 }
2335 
2336 
2337 
2338 template <typename T>
2339 inline
2340 ::internal::TableBaseAccessors::Accessor<2,T,false,1>
2341 Table<2,T>::operator [] (const unsigned int i)
2342 {
2343  Assert (i < this->table_size[0],
2344  ExcIndexRange (i, 0, this->table_size[0]));
2345  return ::internal::TableBaseAccessors::Accessor<2,T,false,1>(*this,
2346  this->values.begin()+i*n_cols());
2347 }
2348 
2349 
2350 
2351 template <typename T>
2352 inline
2353 typename std::vector<T>::const_reference
2354 Table<2,T>::operator () (const unsigned int i,
2355  const unsigned int j) const
2356 {
2357  Assert (i < this->table_size[0],
2358  ExcIndexRange (i, 0, this->table_size[0]));
2359  Assert (j < this->table_size[1],
2360  ExcIndexRange (j, 0, this->table_size[1]));
2361  return this->values[i*this->table_size[1]+j];
2362 }
2363 
2364 
2365 
2366 template <typename T>
2367 inline
2368 typename std::vector<T>::reference
2369 Table<2,T>::operator () (const unsigned int i,
2370  const unsigned int j)
2371 {
2372  Assert (i < this->table_size[0],
2373  ExcIndexRange (i, 0, this->table_size[0]));
2374  Assert (j < this->table_size[1],
2375  ExcIndexRange (j, 0, this->table_size[1]));
2376  return this->values[i*this->table_size[1]+j];
2377 }
2378 
2379 
2380 
2381 template <typename T>
2382 inline
2383 typename std::vector<T>::const_reference
2384 Table<2,T>::operator () (const TableIndices<2> &indices) const
2385 {
2386  return TableBase<2,T>::operator () (indices);
2387 }
2388 
2389 
2390 
2391 template <typename T>
2392 inline
2393 typename std::vector<T>::reference
2395 {
2396  return TableBase<2,T>::operator () (indices);
2397 }
2398 
2399 
2400 
2401 template <typename T>
2402 inline
2403 typename std::vector<T>::const_reference
2404 Table<2,T>::el (const unsigned int i,
2405  const unsigned int j) const
2406 {
2407  return this->values[i*this->table_size[1]+j];
2408 }
2409 
2410 
2411 
2412 template <typename T>
2413 inline
2414 typename std::vector<T>::reference
2415 Table<2,T>::el (const unsigned int i,
2416  const unsigned int j)
2417 {
2418  return this->values[i*this->table_size[1]+j];
2419 }
2420 
2421 
2422 
2423 template <typename T>
2424 inline
2425 unsigned int
2426 Table<2,T>::n_rows () const
2427 {
2428  return this->table_size[0];
2429 }
2430 
2431 
2432 
2433 template <typename T>
2434 inline
2435 unsigned int
2436 Table<2,T>::n_cols () const
2437 {
2438  return this->table_size[1];
2439 }
2440 
2441 
2442 
2443 //---------------------------------------------------------------------------
2444 
2445 template <typename T>
2446 inline
2448 {}
2449 
2450 
2451 
2452 template <typename T>
2453 inline
2454 TransposeTable<T>::TransposeTable (const unsigned int size1,
2455  const unsigned int size2)
2456  :
2457  TableBase<2,T> (TableIndices<2> (size2, size1))
2458 {}
2459 
2460 
2461 
2462 template <typename T>
2463 inline
2464 void
2465 TransposeTable<T>::reinit (const unsigned int size1,
2466  const unsigned int size2,
2467  const bool fast)
2468 {
2469  this->TableBase<2,T>::reinit (TableIndices<2> (size2, size1),fast);
2470 }
2471 
2472 
2473 
2474 template <typename T>
2475 inline
2476 typename std::vector<T>::const_reference
2477 TransposeTable<T>::operator () (const unsigned int i,
2478  const unsigned int j) const
2479 {
2480  Assert (i < this->table_size[1],
2481  ExcIndexRange (i, 0, this->table_size[1]));
2482  Assert (j < this->table_size[0],
2483  ExcIndexRange (j, 0, this->table_size[0]));
2484  return this->values[j*this->table_size[1]+i];
2485 }
2486 
2487 
2488 
2489 template <typename T>
2490 inline
2491 typename std::vector<T>::reference
2492 TransposeTable<T>::operator () (const unsigned int i,
2493  const unsigned int j)
2494 {
2495  Assert (i < this->table_size[1],
2496  ExcIndexRange (i, 0, this->table_size[1]));
2497  Assert (j < this->table_size[0],
2498  ExcIndexRange (j, 0, this->table_size[0]));
2499  return this->values[j*this->table_size[1]+i];
2500 }
2501 
2502 
2503 
2504 template <typename T>
2505 inline
2506 typename std::vector<T>::const_reference
2507 TransposeTable<T>::el (const unsigned int i,
2508  const unsigned int j) const
2509 {
2510  return this->values[j*this->table_size[1]+i];
2511 }
2512 
2513 
2514 
2515 template <typename T>
2516 inline
2517 typename std::vector<T>::reference
2518 TransposeTable<T>::el (const unsigned int i,
2519  const unsigned int j)
2520 {
2521  return this->values[j*this->table_size[1]+i];
2522 }
2523 
2524 
2525 
2526 template <typename T>
2527 inline
2528 unsigned int
2530 {
2531  return this->table_size[1];
2532 }
2533 
2534 
2535 
2536 template <typename T>
2537 inline
2538 unsigned int
2540 {
2541  return this->table_size[0];
2542 }
2543 
2544 
2545 
2546 //---------------------------------------------------------------------------
2547 
2548 
2549 template <typename T>
2550 inline
2552 {}
2553 
2554 
2555 
2556 template <typename T>
2557 inline
2558 Table<3,T>::Table (const unsigned int size1,
2559  const unsigned int size2,
2560  const unsigned int size3)
2561  :
2562  TableBase<3,T> (TableIndices<3> (size1, size2, size3))
2563 {}
2564 
2565 
2566 
2567 template <typename T>
2568 inline
2569 ::internal::TableBaseAccessors::Accessor<3,T,true,2>
2570 Table<3,T>::operator [] (const unsigned int i) const
2571 {
2572  Assert (i < this->table_size[0],
2573  ExcIndexRange (i, 0, this->table_size[0]));
2574  const unsigned int subobject_size = this->table_size[1] *
2575  this->table_size[2];
2577  (*this,
2578  this->values.begin() + i*subobject_size));
2579 }
2580 
2581 
2582 
2583 template <typename T>
2584 inline
2585 ::internal::TableBaseAccessors::Accessor<3,T,false,2>
2586 Table<3,T>::operator [] (const unsigned int i)
2587 {
2588  Assert (i < this->table_size[0],
2589  ExcIndexRange (i, 0, this->table_size[0]));
2590  const unsigned int subobject_size = this->table_size[1] *
2591  this->table_size[2];
2593  (*this,
2594  this->values.begin() + i*subobject_size));
2595 }
2596 
2597 
2598 
2599 template <typename T>
2600 inline
2601 typename std::vector<T>::const_reference
2602 Table<3,T>::operator () (const unsigned int i,
2603  const unsigned int j,
2604  const unsigned int k) const
2605 {
2606  Assert (i < this->table_size[0],
2607  ExcIndexRange (i, 0, this->table_size[0]));
2608  Assert (j < this->table_size[1],
2609  ExcIndexRange (j, 0, this->table_size[1]));
2610  Assert (k < this->table_size[2],
2611  ExcIndexRange (k, 0, this->table_size[2]));
2612  return this->values[(i*this->table_size[1]+j)
2613  *this->table_size[2] + k];
2614 }
2615 
2616 
2617 
2618 template <typename T>
2619 inline
2620 typename std::vector<T>::reference
2621 Table<3,T>::operator () (const unsigned int i,
2622  const unsigned int j,
2623  const unsigned int k)
2624 {
2625  Assert (i < this->table_size[0],
2626  ExcIndexRange (i, 0, this->table_size[0]));
2627  Assert (j < this->table_size[1],
2628  ExcIndexRange (j, 0, this->table_size[1]));
2629  Assert (k < this->table_size[2],
2630  ExcIndexRange (k, 0, this->table_size[2]));
2631  return this->values[(i*this->table_size[1]+j)
2632  *this->table_size[2] + k];
2633 }
2634 
2635 
2636 
2637 template <typename T>
2638 inline
2639 typename std::vector<T>::const_reference
2640 Table<3,T>::operator () (const TableIndices<3> &indices) const
2641 {
2642  return TableBase<3,T>::operator () (indices);
2643 }
2644 
2645 
2646 
2647 template <typename T>
2648 inline
2649 typename std::vector<T>::reference
2651 {
2652  return TableBase<3,T>::operator () (indices);
2653 }
2654 
2655 
2656 
2657 template <typename T>
2658 inline
2660 {}
2661 
2662 
2663 
2664 template <typename T>
2665 inline
2666 Table<4,T>::Table (const unsigned int size1,
2667  const unsigned int size2,
2668  const unsigned int size3,
2669  const unsigned int size4)
2670  :
2671  TableBase<4,T> (TableIndices<4> (size1, size2, size3, size4))
2672 {}
2673 
2674 
2675 
2676 template <typename T>
2677 inline
2678 ::internal::TableBaseAccessors::Accessor<4,T,true,3>
2679 Table<4,T>::operator [] (const unsigned int i) const
2680 {
2681  Assert (i < this->table_size[0],
2682  ExcIndexRange (i, 0, this->table_size[0]));
2683  const unsigned int subobject_size = this->table_size[1] *
2684  this->table_size[2] *
2685  this->table_size[3];
2687  (*this,
2688  this->values.begin() + i*subobject_size));
2689 }
2690 
2691 
2692 
2693 template <typename T>
2694 inline
2695 ::internal::TableBaseAccessors::Accessor<4,T,false,3>
2696 Table<4,T>::operator [] (const unsigned int i)
2697 {
2698  Assert (i < this->table_size[0],
2699  ExcIndexRange (i, 0, this->table_size[0]));
2700  const unsigned int subobject_size = this->table_size[1] *
2701  this->table_size[2] *
2702  this->table_size[3];
2704  (*this,
2705  this->values.begin() + i*subobject_size));
2706 }
2707 
2708 
2709 
2710 template <typename T>
2711 inline
2712 typename std::vector<T>::const_reference
2713 Table<4,T>::operator () (const unsigned int i,
2714  const unsigned int j,
2715  const unsigned int k,
2716  const unsigned int l) const
2717 {
2718  Assert (i < this->table_size[0],
2719  ExcIndexRange (i, 0, this->table_size[0]));
2720  Assert (j < this->table_size[1],
2721  ExcIndexRange (j, 0, this->table_size[1]));
2722  Assert (k < this->table_size[2],
2723  ExcIndexRange (k, 0, this->table_size[2]));
2724  Assert (l < this->table_size[3],
2725  ExcIndexRange (l, 0, this->table_size[3]));
2726  return this->values[((i*this->table_size[1]+j)
2727  *this->table_size[2] + k)
2728  *this->table_size[3] + l];
2729 }
2730 
2731 
2732 
2733 template <typename T>
2734 inline
2735 typename std::vector<T>::reference
2736 Table<4,T>::operator () (const unsigned int i,
2737  const unsigned int j,
2738  const unsigned int k,
2739  const unsigned int l)
2740 {
2741  Assert (i < this->table_size[0],
2742  ExcIndexRange (i, 0, this->table_size[0]));
2743  Assert (j < this->table_size[1],
2744  ExcIndexRange (j, 0, this->table_size[1]));
2745  Assert (k < this->table_size[2],
2746  ExcIndexRange (k, 0, this->table_size[2]));
2747  Assert (l < this->table_size[3],
2748  ExcIndexRange (l, 0, this->table_size[3]));
2749  return this->values[((i*this->table_size[1]+j)
2750  *this->table_size[2] + k)
2751  *this->table_size[3] + l];
2752 }
2753 
2754 
2755 
2756 template <typename T>
2757 inline
2758 typename std::vector<T>::const_reference
2759 Table<4,T>::operator () (const TableIndices<4> &indices) const
2760 {
2761  return TableBase<4,T>::operator () (indices);
2762 }
2763 
2764 
2765 
2766 template <typename T>
2767 inline
2768 typename std::vector<T>::reference
2770 {
2771  return TableBase<4,T>::operator () (indices);
2772 }
2773 
2774 
2775 
2776 template <typename T>
2777 inline
2779 {}
2780 
2781 
2782 
2783 template <typename T>
2784 inline
2785 Table<5,T>::Table (const unsigned int size1,
2786  const unsigned int size2,
2787  const unsigned int size3,
2788  const unsigned int size4,
2789  const unsigned int size5)
2790  :
2791  TableBase<5,T> (TableIndices<5> (size1, size2, size3, size4, size5))
2792 {}
2793 
2794 
2795 
2796 template <typename T>
2797 inline
2798 ::internal::TableBaseAccessors::Accessor<5,T,true,4>
2799 Table<5,T>::operator [] (const unsigned int i) const
2800 {
2801  Assert (i < this->table_size[0],
2802  ExcIndexRange (i, 0, this->table_size[0]));
2803  const unsigned int subobject_size = this->table_size[1] *
2804  this->table_size[2] *
2805  this->table_size[3] *
2806  this->table_size[4];
2808  (*this,
2809  this->values.begin() + i*subobject_size));
2810 }
2811 
2812 
2813 
2814 template <typename T>
2815 inline
2816 ::internal::TableBaseAccessors::Accessor<5,T,false,4>
2817 Table<5,T>::operator [] (const unsigned int i)
2818 {
2819  Assert (i < this->table_size[0],
2820  ExcIndexRange (i, 0, this->table_size[0]));
2821  const unsigned int subobject_size = this->table_size[1] *
2822  this->table_size[2] *
2823  this->table_size[3] *
2824  this->table_size[4];
2826  (*this,
2827  this->values.begin() + i*subobject_size));
2828 }
2829 
2830 
2831 
2832 template <typename T>
2833 inline
2834 typename std::vector<T>::const_reference
2835 Table<5,T>::operator () (const unsigned int i,
2836  const unsigned int j,
2837  const unsigned int k,
2838  const unsigned int l,
2839  const unsigned int m) const
2840 {
2841  Assert (i < this->table_size[0],
2842  ExcIndexRange (i, 0, this->table_size[0]));
2843  Assert (j < this->table_size[1],
2844  ExcIndexRange (j, 0, this->table_size[1]));
2845  Assert (k < this->table_size[2],
2846  ExcIndexRange (k, 0, this->table_size[2]));
2847  Assert (l < this->table_size[3],
2848  ExcIndexRange (l, 0, this->table_size[3]));
2849  Assert (m < this->table_size[4],
2850  ExcIndexRange (m, 0, this->table_size[4]));
2851  return this->values[(((i*this->table_size[1]+j)
2852  *this->table_size[2] + k)
2853  *this->table_size[3] + l)
2854  *this->table_size[4] + m];
2855 }
2856 
2857 
2858 
2859 template <typename T>
2860 inline
2861 typename std::vector<T>::reference
2862 Table<5,T>::operator () (const unsigned int i,
2863  const unsigned int j,
2864  const unsigned int k,
2865  const unsigned int l,
2866  const unsigned int m)
2867 {
2868  Assert (i < this->table_size[0],
2869  ExcIndexRange (i, 0, this->table_size[0]));
2870  Assert (j < this->table_size[1],
2871  ExcIndexRange (j, 0, this->table_size[1]));
2872  Assert (k < this->table_size[2],
2873  ExcIndexRange (k, 0, this->table_size[2]));
2874  Assert (l < this->table_size[3],
2875  ExcIndexRange (l, 0, this->table_size[3]));
2876  Assert (m < this->table_size[4],
2877  ExcIndexRange (m, 0, this->table_size[4]));
2878  return this->values[(((i*this->table_size[1]+j)
2879  *this->table_size[2] + k)
2880  *this->table_size[3] + l)
2881  *this->table_size[4] + m];
2882 }
2883 
2884 
2885 
2886 template <typename T>
2887 inline
2888 typename std::vector<T>::const_reference
2889 Table<5,T>::operator () (const TableIndices<5> &indices) const
2890 {
2891  return TableBase<5,T>::operator () (indices);
2892 }
2893 
2894 
2895 
2896 template <typename T>
2897 inline
2898 typename std::vector<T>::reference
2900 {
2901  return TableBase<5,T>::operator () (indices);
2902 }
2903 
2904 
2905 
2906 template <typename T>
2907 inline
2909 {}
2910 
2911 
2912 
2913 template <typename T>
2914 inline
2915 Table<6,T>::Table (const unsigned int size1,
2916  const unsigned int size2,
2917  const unsigned int size3,
2918  const unsigned int size4,
2919  const unsigned int size5,
2920  const unsigned int size6)
2921  :
2922  TableBase<6,T> (TableIndices<6> (size1, size2, size3, size4, size5, size6))
2923 {}
2924 
2925 
2926 
2927 template <typename T>
2928 inline
2929 ::internal::TableBaseAccessors::Accessor<6,T,true,5>
2930 Table<6,T>::operator [] (const unsigned int i) const
2931 {
2932  Assert (i < this->table_size[0],
2933  ExcIndexRange (i, 0, this->table_size[0]));
2934  const unsigned int subobject_size = this->table_size[1] *
2935  this->table_size[2] *
2936  this->table_size[3] *
2937  this->table_size[4] *
2938  this->table_size[5];
2940  (*this,
2941  this->values.begin() + i*subobject_size));
2942 }
2943 
2944 
2945 
2946 template <typename T>
2947 inline
2948 ::internal::TableBaseAccessors::Accessor<6,T,false,5>
2949 Table<6,T>::operator [] (const unsigned int i)
2950 {
2951  Assert (i < this->table_size[0],
2952  ExcIndexRange (i, 0, this->table_size[0]));
2953  const unsigned int subobject_size = this->table_size[1] *
2954  this->table_size[2] *
2955  this->table_size[3] *
2956  this->table_size[4] *
2957  this->table_size[5];
2959  (*this,
2960  this->values.begin() + i*subobject_size));
2961 }
2962 
2963 
2964 
2965 template <typename T>
2966 inline
2967 typename std::vector<T>::const_reference
2968 Table<6,T>::operator () (const unsigned int i,
2969  const unsigned int j,
2970  const unsigned int k,
2971  const unsigned int l,
2972  const unsigned int m,
2973  const unsigned int n) const
2974 {
2975  Assert (i < this->table_size[0],
2976  ExcIndexRange (i, 0, this->table_size[0]));
2977  Assert (j < this->table_size[1],
2978  ExcIndexRange (j, 0, this->table_size[1]));
2979  Assert (k < this->table_size[2],
2980  ExcIndexRange (k, 0, this->table_size[2]));
2981  Assert (l < this->table_size[3],
2982  ExcIndexRange (l, 0, this->table_size[3]));
2983  Assert (m < this->table_size[4],
2984  ExcIndexRange (m, 0, this->table_size[4]));
2985  Assert (n < this->table_size[5],
2986  ExcIndexRange (n, 0, this->table_size[5]));
2987  return this->values[((((i*this->table_size[1]+j)
2988  *this->table_size[2] + k)
2989  *this->table_size[3] + l)
2990  *this->table_size[4] + m)
2991  *this->table_size[5] + n];
2992 }
2993 
2994 
2995 
2996 template <typename T>
2997 inline
2998 typename std::vector<T>::reference
2999 Table<6,T>::operator () (const unsigned int i,
3000  const unsigned int j,
3001  const unsigned int k,
3002  const unsigned int l,
3003  const unsigned int m,
3004  const unsigned int n)
3005 {
3006  Assert (i < this->table_size[0],
3007  ExcIndexRange (i, 0, this->table_size[0]));
3008  Assert (j < this->table_size[1],
3009  ExcIndexRange (j, 0, this->table_size[1]));
3010  Assert (k < this->table_size[2],
3011  ExcIndexRange (k, 0, this->table_size[2]));
3012  Assert (l < this->table_size[3],
3013  ExcIndexRange (l, 0, this->table_size[3]));
3014  Assert (m < this->table_size[4],
3015  ExcIndexRange (m, 0, this->table_size[4]));
3016  Assert (n < this->table_size[5],
3017  ExcIndexRange (n, 0, this->table_size[5]));
3018  return this->values[((((i*this->table_size[1]+j)
3019  *this->table_size[2] + k)
3020  *this->table_size[3] + l)
3021  *this->table_size[4] + m)
3022  *this->table_size[5] + n];
3023 }
3024 
3025 
3026 
3027 template <typename T>
3028 inline
3029 typename std::vector<T>::const_reference
3030 Table<6,T>::operator () (const TableIndices<6> &indices) const
3031 {
3032  return TableBase<6,T>::operator () (indices);
3033 }
3034 
3035 
3036 
3037 template <typename T>
3038 inline
3039 typename std::vector<T>::reference
3041 {
3042  return TableBase<6,T>::operator () (indices);
3043 }
3044 
3045 
3046 
3047 template <typename T>
3048 inline
3050 {}
3051 
3052 
3053 
3054 template <typename T>
3055 inline
3056 Table<7,T>::Table (const unsigned int size1,
3057  const unsigned int size2,
3058  const unsigned int size3,
3059  const unsigned int size4,
3060  const unsigned int size5,
3061  const unsigned int size6,
3062  const unsigned int size7)
3063  :
3064  TableBase<7,T> (TableIndices<7> (size1, size2, size3, size4, size5, size6, size7))
3065 {}
3066 
3067 
3068 
3069 template <typename T>
3070 inline
3071 ::internal::TableBaseAccessors::Accessor<7,T,true,6>
3072 Table<7,T>::operator [] (const unsigned int i) const
3073 {
3074  Assert (i < this->table_size[0],
3075  ExcIndexRange (i, 0, this->table_size[0]));
3076  const unsigned int subobject_size = this->table_size[1] *
3077  this->table_size[2] *
3078  this->table_size[3] *
3079  this->table_size[4] *
3080  this->table_size[5] *
3081  this->table_size[6];
3083  (*this,
3084  this->values.begin() + i*subobject_size));
3085 }
3086 
3087 
3088 
3089 template <typename T>
3090 inline
3091 ::internal::TableBaseAccessors::Accessor<7,T,false,6>
3092 Table<7,T>::operator [] (const unsigned int i)
3093 {
3094  Assert (i < this->table_size[0],
3095  ExcIndexRange (i, 0, this->table_size[0]));
3096  const unsigned int subobject_size = this->table_size[1] *
3097  this->table_size[2] *
3098  this->table_size[3] *
3099  this->table_size[4] *
3100  this->table_size[5] *
3101  this->table_size[6];
3103  (*this,
3104  this->values.begin() + i*subobject_size));
3105 }
3106 
3107 
3108 
3109 template <typename T>
3110 inline
3111 typename std::vector<T>::const_reference
3112 Table<7,T>::operator () (const unsigned int i,
3113  const unsigned int j,
3114  const unsigned int k,
3115  const unsigned int l,
3116  const unsigned int m,
3117  const unsigned int n,
3118  const unsigned int o) const
3119 {
3120  Assert (i < this->table_size[0],
3121  ExcIndexRange (i, 0, this->table_size[0]));
3122  Assert (j < this->table_size[1],
3123  ExcIndexRange (j, 0, this->table_size[1]));
3124  Assert (k < this->table_size[2],
3125  ExcIndexRange (k, 0, this->table_size[2]));
3126  Assert (l < this->table_size[3],
3127  ExcIndexRange (l, 0, this->table_size[3]));
3128  Assert (m < this->table_size[4],
3129  ExcIndexRange (m, 0, this->table_size[4]));
3130  Assert (n < this->table_size[5],
3131  ExcIndexRange (n, 0, this->table_size[5]));
3132  Assert (o < this->table_size[6],
3133  ExcIndexRange (o, 0, this->table_size[6]));
3134  return this->values[(((((i*this->table_size[1]+j)
3135  *this->table_size[2] + k)
3136  *this->table_size[3] + l)
3137  *this->table_size[4] + m)
3138  *this->table_size[5] + n)
3139  *this->table_size[6] + o];
3140 }
3141 
3142 
3143 
3144 template <typename T>
3145 inline
3146 typename std::vector<T>::reference
3147 Table<7,T>::operator () (const unsigned int i,
3148  const unsigned int j,
3149  const unsigned int k,
3150  const unsigned int l,
3151  const unsigned int m,
3152  const unsigned int n,
3153  const unsigned int o)
3154 {
3155  Assert (i < this->table_size[0],
3156  ExcIndexRange (i, 0, this->table_size[0]));
3157  Assert (j < this->table_size[1],
3158  ExcIndexRange (j, 0, this->table_size[1]));
3159  Assert (k < this->table_size[2],
3160  ExcIndexRange (k, 0, this->table_size[2]));
3161  Assert (l < this->table_size[3],
3162  ExcIndexRange (l, 0, this->table_size[3]));
3163  Assert (m < this->table_size[4],
3164  ExcIndexRange (m, 0, this->table_size[4]));
3165  Assert (n < this->table_size[5],
3166  ExcIndexRange (n, 0, this->table_size[5]));
3167  Assert (o < this->table_size[5],
3168  ExcIndexRange (o, 0, this->table_size[6]));
3169  return this->values[(((((i*this->table_size[1]+j)
3170  *this->table_size[2] + k)
3171  *this->table_size[3] + l)
3172  *this->table_size[4] + m)
3173  *this->table_size[5] + n)
3174  *this->table_size[6] + o];
3175 }
3176 
3177 
3178 
3179 template <typename T>
3180 inline
3181 typename std::vector<T>::const_reference
3182 Table<7,T>::operator () (const TableIndices<7> &indices) const
3183 {
3184  return TableBase<7,T>::operator () (indices);
3185 }
3186 
3187 
3188 
3189 template <typename T>
3190 inline
3191 typename std::vector<T>::reference
3193 {
3194  return TableBase<7,T>::operator () (indices);
3195 }
3196 
3197 
3198 #endif // DOXYGEN
3199 
3200 
3201 
3209 template <int N, typename T>
3210 inline
3211 void swap (TableBase<N,T> &u, TableBase<N,T> &v)
3212 {
3213  u.swap (v);
3214 }
3215 
3216 DEAL_II_NAMESPACE_CLOSE
3217 
3218 #endif
unsigned int n_rows() const
void reinit(const TableIndices< N > &new_size, const bool fast=false)
std::vector< T >::const_pointer data() const DEAL_II_DEPRECATED
void serialize(Archive &ar, const unsigned int version)
void swap(TableBase< N, T > &v)
::ExceptionBase & ExcMessage(std::string arg1)
unsigned int n_elements() const
TableBase< N, T > & operator=(const TableBase< N, T > &src)
STL namespace.
Accessor< N, T, C, P-1 > operator[](const unsigned int i) const
const TableIndices< N > & size() const
std::vector< T >::reference operator()(const TableIndices< N > &indices)
#define Assert(cond, exc)
Definition: exceptions.h:299
std::size_t memory_consumption(const T &t)
std::vector< T >::reference el(const unsigned int i, const unsigned int j)
std::size_t memory_consumption() const
::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
Types< N, T, C >::value_type value_type
Definition: table.h:265
BlockCompressedSparsityPattern CompressedBlockSparsityPattern DEAL_II_DEPRECATED
void swap(VectorBase &u, VectorBase &v)
DeclException3(ExcIndexRange, int, int, int,<< "Index "<< N-P+1<< "has a value of "<< arg1<< " but needs to be in the range ["<< arg2<< ","<< arg3<< "[")
unsigned int position(const TableIndices< N > &indices) const
std::vector< T >::const_reference operator()(const unsigned int i, const unsigned int j) const
void fill(const T2 *entries)
void reset_values()
void reinit(const unsigned int size1, const unsigned int size2, const bool fast=false)
Definition: table.h:33
std::vector< T >::reference el(const TableIndices< N > &indices)
TableIndices< N > table_size
Definition: table.h:732
unsigned int size(const unsigned int i) const
::ExceptionBase & ExcInternalError()
std::vector< T > values
Definition: table.h:726
unsigned int n_cols() const
bool empty() const
bool operator==(const TableBase< N, T > &T2) const