Reference documentation for deal.II version 8.5.1
table.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2002 - 2017 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__table_h
17 #define dealii__table_h
18 
19 #include <deal.II/base/config.h>
20 #include <deal.II/base/exceptions.h>
21 #include <deal.II/base/subscriptor.h>
22 #include <deal.II/base/table_indices.h>
23 #include <deal.II/base/memory_consumption.h>
24 #include <deal.II/base/aligned_vector.h>
25 
26 #include <cstddef>
27 #include <algorithm>
28 
29 DEAL_II_NAMESPACE_OPEN
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 
62  namespace TableBaseAccessors
63  {
71  template <int N, typename T, bool Constness>
72  struct Types
73  {};
74 
80  template <int N, typename T> struct Types<N,T,true>
81  {
82  typedef const T value_type;
83  typedef const TableBase<N,T> TableType;
84 
85  typedef typename AlignedVector<T>::const_iterator iterator;
86  typedef typename AlignedVector<T>::const_iterator const_iterator;
87 
88  typedef typename AlignedVector<T>::const_reference reference;
89  typedef typename AlignedVector<T>::const_reference const_reference;
90  };
91 
97  template <int N, typename T> struct Types<N,T,false>
98  {
99  typedef T value_type;
100  typedef TableBase<N,T> TableType;
101 
102  typedef typename AlignedVector<T>::iterator iterator;
103  typedef typename AlignedVector<T>::const_iterator const_iterator;
104 
105  typedef typename AlignedVector<T>::reference reference;
106  typedef typename AlignedVector<T>::const_reference const_reference;
107  };
108 
109 
148  template <int N, typename T, bool C, unsigned int P>
149  class Accessor
150  {
151  public:
152  typedef typename Types<N,T,C>::TableType TableType;
153 
154  typedef typename Types<N,T,C>::iterator iterator;
155  typedef typename Types<N,T,C>::const_iterator const_iterator;
156 
157  typedef size_t size_type;
158  typedef ptrdiff_t difference_type;
159  private:
165  Accessor (const TableType &table,
166  const iterator data);
167 
171  Accessor ();
172 
173  public:
174 
182  Accessor (const Accessor &a);
183 
187  Accessor<N,T,C,P-1> operator [] (const unsigned int i) const;
188 
193  DeclException3 (ExcIndexRange, int, int, int,
194  << "Index " << N-P+1 << "has a value of "
195  << arg1 << " but needs to be in the range ["
196  << arg2 << "," << arg3 << "[.");
197  private:
203  const TableType &table;
204  const iterator data;
205 
206  // declare some other classes
207  // as friends. make sure to
208  // work around bugs in some
209  // compilers
210  template <int N1, typename T1> friend class ::Table;
211  template <int N1, typename T1, bool C1, unsigned int P1>
212  friend class Accessor;
213 # ifndef DEAL_II_TEMPL_SPEC_FRIEND_BUG
214  friend class ::Table<N,T>;
215  friend class Accessor<N,T,C,P+1>;
216 # endif
217  };
218 
219 
220 
230  template <int N, typename T, bool C>
231  class Accessor<N,T,C,1>
232  {
233  public:
239  typedef typename Types<N,T,C>::value_type value_type;
240 
241  typedef typename Types<N,T,C>::iterator iterator;
242  typedef typename Types<N,T,C>::const_iterator const_iterator;
243 
244  typedef typename Types<N,T,C>::reference reference;
245  typedef typename Types<N,T,C>::const_reference const_reference;
246 
247  typedef size_t size_type;
248  typedef ptrdiff_t difference_type;
249 
253  typedef typename Types<N,T,C>::TableType TableType;
254 
255  private:
256 
268  Accessor (const TableType &table,
269  const iterator data);
270 
274  Accessor ();
275 
276  public:
284  Accessor (const Accessor &a);
285 
286 
290  reference operator [] (const unsigned int) const;
291 
296  unsigned int size () const;
297 
301  iterator begin () const;
302 
306  iterator end () const;
307 
308  private:
314  const TableType &table;
315  const iterator data;
316 
317  // declare some other classes
318  // as friends. make sure to
319  // work around bugs in some
320  // compilers
321  template <int N1, typename T1> friend class ::Table;
322  template <int N1, typename T1, bool C1, unsigned int P1>
323  friend class Accessor;
324 # ifndef DEAL_II_TEMPL_SPEC_FRIEND_BUG
325  friend class ::Table<2,T>;
326  friend class Accessor<N,T,C,2>;
327 # endif
328  };
329  }
330 
331 } // namespace internal
332 
333 
334 
335 
402 template <int N, typename T>
403 class TableBase : public Subscriptor
404 {
405 public:
406  typedef T value_type;
407 
411  typedef typename AlignedVector<T>::size_type size_type;
412 
413 
417  TableBase ();
418 
423  TableBase (const TableIndices<N> &sizes);
424 
430  template <typename InputIterator>
431  TableBase (const TableIndices<N> &sizes,
432  InputIterator entries,
433  const bool C_style_indexing = true);
434 
438  TableBase (const TableBase<N,T> &src);
439 
444  template <typename T2>
445  TableBase (const TableBase<N,T2> &src);
446 
447 #ifdef DEAL_II_WITH_CXX11
448 
453  TableBase (TableBase<N,T> &&src);
454 #endif
455 
459  ~TableBase ();
460 
470 
478  template<typename T2>
480 
481 #ifdef DEAL_II_WITH_CXX11
482 
489 #endif
490 
494  bool operator == (const TableBase<N,T> &T2) const;
495 
500  void reset_values ();
501 
510  void reinit (const TableIndices<N> &new_size,
511  const bool omit_default_initialization = false);
512 
516  unsigned int size (const unsigned int i) const;
517 
521  const TableIndices<N> &size () const;
522 
527  size_type n_elements () const;
528 
533  bool empty () const;
534 
571  template <typename InputIterator>
572  void fill (InputIterator entries,
573  const bool C_style_indexing = true);
574 
578  void fill (const T &value);
579 
583  typename AlignedVector<T>::reference
584  operator () (const TableIndices<N> &indices);
585 
593  typename AlignedVector<T>::const_reference
594  operator () (const TableIndices<N> &indices) const;
595 
608  void swap (TableBase<N,T> &v);
609 
614  std::size_t memory_consumption () const;
615 
620  template <class Archive>
621  void serialize (Archive &ar, const unsigned int version);
622 
623 protected:
628  size_type position (const TableIndices<N> &indices) const;
629 
636  typename AlignedVector<T>::reference el (const TableIndices<N> &indices);
637 
648  typename AlignedVector<T>::const_reference el (const TableIndices<N> &indices) const;
649 
650 protected:
655 
660 
664  template <int, typename> friend class TableBase;
665 };
666 
667 
681 template <int N,typename T>
682 class Table : public TableBase<N,T>
683 {
684 };
685 
686 
699 template <typename T>
700 class Table<1,T> : public TableBase<1,T>
701 {
702 public:
707 
711  Table ();
712 
716  Table (const unsigned int size);
717 
755  template <typename InputIterator>
756  Table (const unsigned int size,
757  InputIterator entries,
758  const bool C_style_indexing = true);
759 
764  typename AlignedVector<T>::const_reference
765  operator [] (const unsigned int i) const;
766 
771  typename AlignedVector<T>::reference
772  operator [] (const unsigned int i);
773 
778  typename AlignedVector<T>::const_reference
779  operator () (const unsigned int i) const;
780 
785  typename AlignedVector<T>::reference
786  operator () (const unsigned int i);
787 
792  typename AlignedVector<T>::reference
793  operator () (const TableIndices<1> &indices);
794 
799  typename AlignedVector<T>::const_reference
800  operator () (const TableIndices<1> &indices) const;
801 };
802 
803 
804 
818 template <typename T>
819 class Table<2,T> : public TableBase<2,T>
820 {
821 public:
826 
830  Table ();
831 
835  Table (const unsigned int size1,
836  const unsigned int size2);
837 
876  template <typename InputIterator>
877  Table (const unsigned int size1,
878  const unsigned int size2,
879  InputIterator entries,
880  const bool C_style_indexing = true);
881 
887  void reinit (const unsigned int size1,
888  const unsigned int size2,
889  const bool omit_default_initialization = false);
890 
892 
899  ::internal::TableBaseAccessors::Accessor<2,T,true,1>
900  operator [] (const unsigned int i) const;
901 
908  ::internal::TableBaseAccessors::Accessor<2,T,false,1>
909  operator [] (const unsigned int i);
910 
917  typename AlignedVector<T>::const_reference
918  operator () (const unsigned int i,
919  const unsigned int j) const;
920 
921 
928  typename AlignedVector<T>::reference
929  operator () (const unsigned int i,
930  const unsigned int j);
931 
936  typename AlignedVector<T>::reference
937  operator () (const TableIndices<2> &indices);
938 
943  typename AlignedVector<T>::const_reference
944  operator () (const TableIndices<2> &indices) const;
945 
946 
951  unsigned int n_rows () const;
952 
957  unsigned int n_cols () const;
958 
959 protected:
970  typename AlignedVector<T>::reference el (const unsigned int i,
971  const unsigned int j);
972 
987  typename AlignedVector<T>::const_reference el (const unsigned int i,
988  const unsigned int j) const;
989 };
990 
991 
992 
1003 template <typename T>
1004 class Table<3,T> : public TableBase<3,T>
1005 {
1006 public:
1011 
1015  Table ();
1016 
1020  Table (const unsigned int size1,
1021  const unsigned int size2,
1022  const unsigned int size3);
1023 
1064  template <typename InputIterator>
1065  Table (const unsigned int size1,
1066  const unsigned int size2,
1067  const unsigned int size3,
1068  InputIterator entries,
1069  const bool C_style_indexing = true);
1070 
1078  ::internal::TableBaseAccessors::Accessor<3,T,true,2>
1079  operator [] (const unsigned int i) const;
1080 
1088  ::internal::TableBaseAccessors::Accessor<3,T,false,2>
1089  operator [] (const unsigned int i);
1090 
1097  typename AlignedVector<T>::const_reference operator () (const unsigned int i,
1098  const unsigned int j,
1099  const unsigned int k) const;
1100 
1101 
1108  typename AlignedVector<T>::reference operator () (const unsigned int i,
1109  const unsigned int j,
1110  const unsigned int k);
1111 
1116  typename AlignedVector<T>::reference operator () (const TableIndices<3> &indices);
1117 
1122  typename AlignedVector<T>::const_reference operator () (const TableIndices<3> &indices) const;
1123 };
1124 
1125 
1126 
1137 template <typename T>
1138 class Table<4,T> : public TableBase<4,T>
1139 {
1140 public:
1145 
1149  Table ();
1150 
1154  Table (const unsigned int size1,
1155  const unsigned int size2,
1156  const unsigned int size3,
1157  const unsigned int size4);
1158 
1166  ::internal::TableBaseAccessors::Accessor<4,T,true,3>
1167  operator [] (const unsigned int i) const;
1168 
1176  ::internal::TableBaseAccessors::Accessor<4,T,false,3>
1177  operator [] (const unsigned int i);
1178 
1185  typename AlignedVector<T>::const_reference operator () (const unsigned int i,
1186  const unsigned int j,
1187  const unsigned int k,
1188  const unsigned int l) const;
1189 
1190 
1197  typename AlignedVector<T>::reference operator () (const unsigned int i,
1198  const unsigned int j,
1199  const unsigned int k,
1200  const unsigned int l);
1201 
1206  typename AlignedVector<T>::reference
1207  operator () (const TableIndices<4> &indices);
1208 
1213  typename AlignedVector<T>::const_reference
1214  operator () (const TableIndices<4> &indices) const;
1215 };
1216 
1217 
1218 
1229 template <typename T>
1230 class Table<5,T> : public TableBase<5,T>
1231 {
1232 public:
1237 
1238 
1242  Table ();
1243 
1247  Table (const unsigned int size1,
1248  const unsigned int size2,
1249  const unsigned int size3,
1250  const unsigned int size4,
1251  const unsigned int size5);
1252 
1260  ::internal::TableBaseAccessors::Accessor<5,T,true,4>
1261  operator [] (const unsigned int i) const;
1262 
1270  ::internal::TableBaseAccessors::Accessor<5,T,false,4>
1271  operator [] (const unsigned int i);
1272 
1279  typename AlignedVector<T>::const_reference operator () (const unsigned int i,
1280  const unsigned int j,
1281  const unsigned int k,
1282  const unsigned int l,
1283  const unsigned int m) const;
1284 
1291  typename AlignedVector<T>::reference operator () (const unsigned int i,
1292  const unsigned int j,
1293  const unsigned int k,
1294  const unsigned int l,
1295  const unsigned int m);
1296 
1301  typename AlignedVector<T>::reference
1302  operator () (const TableIndices<5> &indices);
1303 
1308  typename AlignedVector<T>::const_reference
1309  operator () (const TableIndices<5> &indices) const;
1310 };
1311 
1312 
1313 
1324 template <typename T>
1325 class Table<6,T> : public TableBase<6,T>
1326 {
1327 public:
1332 
1336  Table ();
1337 
1341  Table (const unsigned int size1,
1342  const unsigned int size2,
1343  const unsigned int size3,
1344  const unsigned int size4,
1345  const unsigned int size5,
1346  const unsigned int size6);
1347 
1355  ::internal::TableBaseAccessors::Accessor<6,T,true,5>
1356  operator [] (const unsigned int i) const;
1357 
1365  ::internal::TableBaseAccessors::Accessor<6,T,false,5>
1366  operator [] (const unsigned int i);
1367 
1374  typename AlignedVector<T>::const_reference operator () (const unsigned int i,
1375  const unsigned int j,
1376  const unsigned int k,
1377  const unsigned int l,
1378  const unsigned int m,
1379  const unsigned int n) const;
1380 
1387  typename AlignedVector<T>::reference operator () (const unsigned int i,
1388  const unsigned int j,
1389  const unsigned int k,
1390  const unsigned int l,
1391  const unsigned int m,
1392  const unsigned int n);
1393 
1398  typename AlignedVector<T>::reference
1399  operator () (const TableIndices<6> &indices);
1400 
1405  typename AlignedVector<T>::const_reference
1406  operator () (const TableIndices<6> &indices) const;
1407 };
1408 
1409 
1420 template <typename T>
1421 class Table<7,T> : public TableBase<7,T>
1422 {
1423 public:
1428 
1432  Table ();
1433 
1437  Table (const unsigned int size1,
1438  const unsigned int size2,
1439  const unsigned int size3,
1440  const unsigned int size4,
1441  const unsigned int size5,
1442  const unsigned int size6,
1443  const unsigned int size7);
1444 
1452  ::internal::TableBaseAccessors::Accessor<7,T,true,6>
1453  operator [] (const unsigned int i) const;
1454 
1462  ::internal::TableBaseAccessors::Accessor<7,T,false,6>
1463  operator [] (const unsigned int i);
1464 
1471  typename AlignedVector<T>::const_reference operator () (const unsigned int i,
1472  const unsigned int j,
1473  const unsigned int k,
1474  const unsigned int l,
1475  const unsigned int m,
1476  const unsigned int n,
1477  const unsigned int o) const;
1478 
1485  typename AlignedVector<T>::reference operator () (const unsigned int i,
1486  const unsigned int j,
1487  const unsigned int k,
1488  const unsigned int l,
1489  const unsigned int m,
1490  const unsigned int n,
1491  const unsigned int o);
1492 
1497  typename AlignedVector<T>::reference
1498  operator () (const TableIndices<7> &indices);
1499 
1504  typename AlignedVector<T>::const_reference
1505  operator () (const TableIndices<7> &indices) const;
1506 };
1507 
1508 
1509 
1523 template <typename T>
1524 class TransposeTable : public TableBase<2,T>
1525 {
1526 public:
1531 
1535  TransposeTable ();
1536 
1540  TransposeTable (const unsigned int size1,
1541  const unsigned int size2);
1542 
1548  void reinit (const unsigned int size1,
1549  const unsigned int size2,
1550  const bool omit_default_initialization = false);
1551 
1558  typename AlignedVector<T>::const_reference operator () (const unsigned int i,
1559  const unsigned int j) const;
1560 
1567  typename AlignedVector<T>::reference operator () (const unsigned int i,
1568  const unsigned int j);
1569 
1574  unsigned int n_rows () const;
1575 
1580  unsigned int n_cols () const;
1581 
1582 protected:
1593  typename AlignedVector<T>::reference el (const unsigned int i,
1594  const unsigned int j);
1595 
1610  typename AlignedVector<T>::const_reference el (const unsigned int i,
1611  const unsigned int j) const;
1612 };
1613 
1614 
1615 
1616 
1617 /* --------------------- Template and inline functions ---------------- */
1618 
1619 #ifndef DOXYGEN
1620 
1621 template <int N, typename T>
1623 {}
1624 
1625 
1626 
1627 template <int N, typename T>
1629 {
1630  reinit (sizes);
1631 }
1632 
1633 
1634 
1635 template <int N, typename T>
1636 template <typename InputIterator>
1638 TableBase (const TableIndices<N> &sizes,
1639  InputIterator entries,
1640  const bool C_style_indexing)
1641 {
1642  reinit (sizes);
1643  fill (entries, C_style_indexing);
1644 }
1645 
1646 
1647 
1648 
1649 template <int N, typename T>
1651  :
1652  Subscriptor ()
1653 {
1654  reinit (src.table_size, true);
1655  values = src.values;
1656 }
1657 
1658 
1659 
1660 template <int N, typename T>
1661 template <typename T2>
1663 {
1664  reinit (src.table_size);
1665  if (src.n_elements() != 0)
1666  std::copy (src.values.begin(), src.values.end(), values.begin());
1667 }
1668 
1669 
1670 
1671 #ifdef DEAL_II_WITH_CXX11
1672 
1673 template <int N, typename T>
1675  :
1676  Subscriptor (std::move(src)),
1677  values (std::move(src.values)),
1678  table_size (src.table_size)
1679 {
1680  src.table_size = TableIndices<N>();
1681 }
1682 
1683 #endif
1684 
1685 
1686 
1687 template <int N, typename T>
1688 template <class Archive>
1689 inline
1690 void
1691 TableBase<N,T>::serialize (Archive &ar, const unsigned int)
1692 {
1693  ar &static_cast<Subscriptor &>(*this);
1694 
1695  ar &values &table_size;
1696 }
1697 
1698 
1699 
1700 namespace internal
1701 {
1702  namespace TableBaseAccessors
1703  {
1704  template <int N, typename T, bool C, unsigned int P>
1705  inline
1706  Accessor<N,T,C,P>::Accessor (const TableType &table,
1707  const iterator data)
1708  :
1709  table (table),
1710  data (data)
1711  {}
1712 
1713 
1714 
1715  template <int N, typename T, bool C, unsigned int P>
1716  inline
1717  Accessor<N,T,C,P>::Accessor (const Accessor &a)
1718  :
1719  table (a.table),
1720  data (a.data)
1721  {}
1722 
1723 
1724 
1725  template <int N, typename T, bool C, unsigned int P>
1726  inline
1727  Accessor<N,T,C,P>::Accessor ()
1728  :
1729  table (*static_cast<const TableType *>(0)),
1730  data (0)
1731  {
1732  // accessor objects are only
1733  // temporary objects, so should
1734  // not need to be copied around
1735  Assert (false, ExcInternalError());
1736  }
1737 
1738 
1739 
1740  template <int N, typename T, bool C, unsigned int P>
1741  inline
1742  Accessor<N,T,C,P-1>
1743  Accessor<N,T,C,P>::operator [] (const unsigned int i) const
1744  {
1745  Assert (i < table.size()[N-P],
1746  ExcIndexRange (i, 0, table.size()[N-P]));
1747 
1748  // access i-th
1749  // subobject. optimize on the
1750  // case i==0
1751  if (i==0)
1752  return Accessor<N,T,C,P-1> (table, data);
1753  else
1754  {
1755  // note: P>1, otherwise the
1756  // specialization would have
1757  // been taken!
1758  size_type subobject_size = table.size()[N-1];
1759  for (int p=P-1; p>1; --p)
1760  subobject_size *= table.size()[N-p];
1761  const iterator new_data = data + i*subobject_size;
1762  return Accessor<N,T,C,P-1> (table, new_data);
1763  }
1764  }
1765 
1766 
1767 
1768  template <int N, typename T, bool C>
1769  inline
1770  Accessor<N,T,C,1>::Accessor (const TableType &table,
1771  const iterator data)
1772  :
1773  table (table),
1774  data (data)
1775  {}
1776 
1777 
1778 
1779  template <int N, typename T, bool C>
1780  inline
1781  Accessor<N,T,C,1>::Accessor ()
1782  :
1783  table (*static_cast<const TableType *>(0)),
1784  data (0)
1785  {
1786  // accessor objects are only
1787  // temporary objects, so should
1788  // not need to be copied around
1789  Assert (false, ExcInternalError());
1790  }
1791 
1792 
1793 
1794  template <int N, typename T, bool C>
1795  inline
1796  Accessor<N,T,C,1>::Accessor (const Accessor &a)
1797  :
1798  table (a.table),
1799  data (a.data)
1800  {}
1801 
1802 
1803 
1804  template <int N, typename T, bool C>
1805  inline
1806  typename Accessor<N,T,C,1>::reference
1807  Accessor<N,T,C,1>::operator [] (const unsigned int i) const
1808  {
1809  Assert (i < table.size()[N-1],
1810  ExcIndexRange (i, 0, table.size()[N-1]));
1811  return *(data+i);
1812  }
1813 
1814 
1815 
1816  template <int N, typename T, bool C>
1817  inline
1818  unsigned int
1819  Accessor<N,T,C,1>::size () const
1820  {
1821  return table.size()[N-1];
1822  }
1823 
1824 
1825 
1826  template <int N, typename T, bool C>
1827  inline
1828  typename Accessor<N,T,C,1>::iterator
1829  Accessor<N,T,C,1>::begin () const
1830  {
1831  return data;
1832  }
1833 
1834 
1835 
1836  template <int N, typename T, bool C>
1837  inline
1838  typename Accessor<N,T,C,1>::iterator
1839  Accessor<N,T,C,1>::end () const
1840  {
1841  return data+table.size()[N-1];
1842  }
1843  }
1844 }
1845 
1846 
1847 
1848 template <int N, typename T>
1849 inline
1851 {}
1852 
1853 
1854 
1855 template <int N, typename T>
1856 inline
1859 {
1860  if (!m.empty())
1861  values = m.values;
1862  reinit (m.size(), true);
1863 
1864  return *this;
1865 }
1866 
1867 
1868 
1869 template <int N, typename T>
1870 template <typename T2>
1871 inline
1874 {
1875  reinit (m.size(), true);
1876  if (!empty())
1877  std::copy (m.values.begin(), m.values.begin() + n_elements(),
1878  values.begin());
1879 
1880  return *this;
1881 }
1882 
1883 
1884 
1885 #ifdef DEAL_II_WITH_CXX11
1886 
1887 template <int N, typename T>
1888 inline
1891 {
1892  static_cast<Subscriptor &>(*this) = std::move(m);
1893  values = std::move(m.values);
1894  table_size = m.table_size;
1896 
1897  return *this;
1898 }
1899 
1900 #endif
1901 
1902 
1903 
1904 template <int N, typename T>
1905 inline
1906 bool
1908 {
1909  return (values == T2.values);
1910 }
1911 
1912 
1913 
1914 template <int N, typename T>
1915 inline
1916 void
1918 {
1919  // use parallel set operation
1920  if (n_elements() != 0)
1921  values.fill(T());
1922 }
1923 
1924 
1925 
1926 template <int N, typename T>
1927 inline
1928 void
1929 TableBase<N,T>::fill (const T &value)
1930 {
1931  if (n_elements() != 0)
1932  values.fill(value);
1933 }
1934 
1935 
1936 
1937 
1938 template <int N, typename T>
1939 inline
1940 void
1941 TableBase<N,T>::reinit (const TableIndices<N> &new_sizes,
1942  const bool omit_default_initialization)
1943 {
1944  table_size = new_sizes;
1945 
1946  const size_type new_size = n_elements();
1947 
1948  // if zero size was given: free all memory
1949  if (new_size == 0)
1950  {
1951  values.resize (0);
1952  // set all sizes to zero, even
1953  // if one was previously
1954  // nonzero. This simplifies
1955  // some assertions.
1956  table_size = TableIndices<N>();
1957 
1958  return;
1959  }
1960 
1961  // adjust values field. If it was empty before, we can simply call resize(),
1962  // which can set all the data fields. Otherwise, select the fast resize and
1963  // manually fill in all the elements as required by the design of this
1964  // class. (Selecting another code for the empty case ensures that we touch
1965  // the memory only once for non-trivial classes that need to initialize the
1966  // memory also in resize_fast.)
1967  if (!omit_default_initialization)
1968  {
1969  if (values.empty())
1970  values.resize(new_size, T());
1971  else
1972  {
1973  values.resize_fast(new_size);
1974  values.fill(T());
1975  }
1976  }
1977  else
1978  values.resize_fast (new_size);
1979 }
1980 
1981 
1982 
1983 template <int N, typename T>
1984 inline
1985 const TableIndices<N> &
1986 TableBase<N,T>::size () const
1987 {
1988  return table_size;
1989 }
1990 
1991 
1992 
1993 template <int N, typename T>
1994 inline
1995 unsigned int
1996 TableBase<N,T>::size (const unsigned int i) const
1997 {
1998  Assert (i<N, ExcIndexRange(i,0,N));
1999  return table_size[i];
2000 }
2001 
2002 
2003 
2004 template <int N, typename T>
2005 inline
2008 {
2009  size_type s = 1;
2010  for (unsigned int n=0; n<N; ++n)
2011  s *= table_size[n];
2012  return s;
2013 }
2014 
2015 
2016 
2017 template <int N, typename T>
2018 inline
2019 bool
2020 TableBase<N,T>::empty () const
2021 {
2022  return (n_elements() == 0);
2023 }
2024 
2025 
2026 
2027 namespace internal
2028 {
2029  namespace Table
2030  {
2031  template <typename InputIterator, typename T>
2032  void fill_Fortran_style (InputIterator entries,
2033  TableBase<1,T> &table)
2034  {
2035  for (unsigned int i=0; i<table.size()[0]; ++i)
2036  table(TableIndices<1>(i)) = *entries++;
2037  }
2038 
2039 
2040  template <typename InputIterator, typename T>
2041  void fill_Fortran_style (InputIterator entries,
2042  TableBase<2,T> &table)
2043  {
2044  for (unsigned int j=0; j<table.size()[1]; ++j)
2045  for (unsigned int i=0; i<table.size()[0]; ++i)
2046  table(TableIndices<2>(i,j)) = *entries++;
2047  }
2048 
2049 
2050  template <typename InputIterator, typename T>
2051  void fill_Fortran_style (InputIterator entries,
2052  TableBase<3,T> &table)
2053  {
2054  for (unsigned int k=0; k<table.size()[2]; ++k)
2055  for (unsigned int j=0; j<table.size()[1]; ++j)
2056  for (unsigned int i=0; i<table.size()[0]; ++i)
2057  table(TableIndices<3>(i,j,k)) = *entries++;
2058  }
2059 
2060 
2061  template <typename InputIterator, typename T, int N>
2062  void fill_Fortran_style (InputIterator,
2063  TableBase<N,T> &)
2064  {
2065  Assert (false, ExcNotImplemented());
2066  }
2067  }
2068 }
2069 
2070 
2071 template <int N, typename T>
2072 template <typename InputIterator>
2073 inline
2074 void
2075 TableBase<N,T>::fill (InputIterator entries,
2076  const bool C_style_indexing)
2077 {
2078  Assert (n_elements() != 0,
2079  ExcMessage("Trying to fill an empty matrix."));
2080 
2081  if (C_style_indexing)
2082  for (typename AlignedVector<T>::iterator p = values.begin();
2083  p != values.end(); ++p)
2084  *p = *entries++;
2085  else
2086  internal::Table::fill_Fortran_style (entries, *this);
2087 }
2088 
2089 
2090 
2091 template <int N, typename T>
2092 inline
2093 void
2095 {
2096  values.swap(v.values);
2097  std::swap (table_size, v.table_size);
2098 }
2099 
2100 
2101 
2102 template <int N, typename T>
2103 inline
2104 std::size_t
2106 {
2107  return sizeof(*this) + MemoryConsumption::memory_consumption(values);
2108 }
2109 
2110 
2111 
2112 template <int N, typename T>
2113 inline
2115 TableBase<N,T>::position (const TableIndices<N> &indices) const
2116 {
2117  // specialize this for the
2118  // different numbers of dimensions,
2119  // to make the job somewhat easier
2120  // for the compiler. have the
2121  // general formula nevertheless:
2122  switch (N)
2123  {
2124  case 1:
2125  return indices[0];
2126  case 2:
2127  return size_type(indices[0])*table_size[1] + indices[1];
2128  case 3:
2129  return ((size_type(indices[0])*table_size[1] + indices[1])*table_size[2]
2130  + indices[2]);
2131  default:
2132  {
2133  size_type s = indices[0];
2134  for (unsigned int n=1; n<N; ++n)
2135  s = s*table_size[n] + indices[n];
2136  return s;
2137  }
2138  }
2139 }
2140 
2141 
2142 
2143 template <int N, typename T>
2144 inline
2145 typename AlignedVector<T>::const_reference
2146 TableBase<N,T>::operator () (const TableIndices<N> &indices) const
2147 {
2148  for (unsigned int n=0; n<N; ++n)
2149  Assert (indices[n] < table_size[n],
2150  ExcIndexRange (indices[n], 0, table_size[n]));
2151  return el(indices);
2152 }
2153 
2154 
2155 
2156 template <int N, typename T>
2157 inline
2158 typename AlignedVector<T>::reference
2160 {
2161  for (unsigned int n=0; n<N; ++n)
2162  Assert (indices[n] < table_size[n],
2163  ExcIndexRange (indices[n], 0, table_size[n]));
2164  return el(indices);
2165 }
2166 
2167 
2168 
2169 template <int N, typename T>
2170 inline
2171 typename AlignedVector<T>::const_reference
2172 TableBase<N,T>::el (const TableIndices<N> &indices) const
2173 {
2174  return values[position(indices)];
2175 }
2176 
2177 
2178 
2179 template <int N, typename T>
2180 inline
2181 typename AlignedVector<T>::reference
2182 TableBase<N,T>::el (const TableIndices<N> &indices)
2183 {
2184  Assert (position(indices) < values.size(),
2185  ExcIndexRange (position(indices), 0, values.size()));
2186  return values[position(indices)];
2187 }
2188 
2189 
2190 
2191 template <typename T>
2192 inline
2194 {}
2195 
2196 
2197 
2198 template <typename T>
2199 inline
2200 Table<1,T>::Table (const unsigned int size)
2201  :
2202  TableBase<1,T> (TableIndices<1> (size))
2203 {}
2204 
2205 
2206 
2207 template <typename T>
2208 template <typename InputIterator>
2209 inline
2210 Table<1,T>::Table (const unsigned int size,
2211  InputIterator entries,
2212  const bool C_style_indexing)
2213  :
2214  TableBase<1,T> (TableIndices<1> (size),
2215  entries,
2216  C_style_indexing)
2217 {}
2218 
2219 
2220 
2221 template <typename T>
2222 inline
2223 typename AlignedVector<T>::const_reference
2224 Table<1,T>::operator [] (const unsigned int i) const
2225 {
2226  Assert (i < this->table_size[0],
2227  ExcIndexRange (i, 0, this->table_size[0]));
2228  return this->values[i];
2229 }
2230 
2231 
2232 
2233 template <typename T>
2234 inline
2235 typename AlignedVector<T>::reference
2236 Table<1,T>::operator [] (const unsigned int i)
2237 {
2238  Assert (i < this->table_size[0],
2239  ExcIndexRange (i, 0, this->table_size[0]));
2240  return this->values[i];
2241 }
2242 
2243 
2244 
2245 template <typename T>
2246 inline
2247 typename AlignedVector<T>::const_reference
2248 Table<1,T>::operator () (const unsigned int i) const
2249 {
2250  Assert (i < this->table_size[0],
2251  ExcIndexRange (i, 0, this->table_size[0]));
2252  return this->values[i];
2253 }
2254 
2255 
2256 
2257 template <typename T>
2258 inline
2259 typename AlignedVector<T>::reference
2260 Table<1,T>::operator () (const unsigned int i)
2261 {
2262  Assert (i < this->table_size[0],
2263  ExcIndexRange (i, 0, this->table_size[0]));
2264  return this->values[i];
2265 }
2266 
2267 
2268 
2269 template <typename T>
2270 inline
2271 typename AlignedVector<T>::const_reference
2272 Table<1,T>::operator () (const TableIndices<1> &indices) const
2273 {
2274  return TableBase<1,T>::operator () (indices);
2275 }
2276 
2277 
2278 
2279 template <typename T>
2280 inline
2281 typename AlignedVector<T>::reference
2283 {
2284  return TableBase<1,T>::operator () (indices);
2285 }
2286 
2287 
2288 //---------------------------------------------------------------------------
2289 
2290 template <typename T>
2291 inline
2293 {}
2294 
2295 
2296 
2297 template <typename T>
2298 inline
2299 Table<2,T>::Table (const unsigned int size1,
2300  const unsigned int size2)
2301  :
2302  TableBase<2,T> (TableIndices<2> (size1, size2))
2303 {}
2304 
2305 
2306 
2307 template <typename T>
2308 template <typename InputIterator>
2309 inline
2310 Table<2,T>::Table (const unsigned int size1,
2311  const unsigned int size2,
2312  InputIterator entries,
2313  const bool C_style_indexing)
2314  :
2315  TableBase<2,T> (TableIndices<2> (size1, size2),
2316  entries,
2317  C_style_indexing)
2318 {}
2319 
2320 
2321 
2322 template <typename T>
2323 inline
2324 void
2325 Table<2,T>::reinit (const unsigned int size1,
2326  const unsigned int size2,
2327  const bool omit_default_initialization)
2328 {
2329  this->TableBase<2,T>::reinit (TableIndices<2> (size1, size2),omit_default_initialization);
2330 }
2331 
2332 
2333 
2334 template <typename T>
2335 inline
2336 ::internal::TableBaseAccessors::Accessor<2,T,true,1>
2337 Table<2,T>::operator [] (const unsigned int i) const
2338 {
2339  Assert (i < this->table_size[0],
2340  ExcIndexRange (i, 0, this->table_size[0]));
2341  return ::internal::TableBaseAccessors::Accessor<2,T,true,1>(*this,
2342  this->values.begin()+size_type(i)*n_cols());
2343 }
2344 
2345 
2346 
2347 template <typename T>
2348 inline
2349 ::internal::TableBaseAccessors::Accessor<2,T,false,1>
2350 Table<2,T>::operator [] (const unsigned int i)
2351 {
2352  Assert (i < this->table_size[0],
2353  ExcIndexRange (i, 0, this->table_size[0]));
2354  return ::internal::TableBaseAccessors::Accessor<2,T,false,1>(*this,
2355  this->values.begin()+size_type(i)*n_cols());
2356 }
2357 
2358 
2359 
2360 template <typename T>
2361 inline
2362 typename AlignedVector<T>::const_reference
2363 Table<2,T>::operator () (const unsigned int i,
2364  const unsigned int j) const
2365 {
2366  Assert (i < this->table_size[0],
2367  ExcIndexRange (i, 0, this->table_size[0]));
2368  Assert (j < this->table_size[1],
2369  ExcIndexRange (j, 0, this->table_size[1]));
2370  return this->values[size_type(i)*this->table_size[1]+j];
2371 }
2372 
2373 
2374 
2375 template <typename T>
2376 inline
2377 typename AlignedVector<T>::reference
2378 Table<2,T>::operator () (const unsigned int i,
2379  const unsigned int j)
2380 {
2381  Assert (i < this->table_size[0],
2382  ExcIndexRange (i, 0, this->table_size[0]));
2383  Assert (j < this->table_size[1],
2384  ExcIndexRange (j, 0, this->table_size[1]));
2385  return this->values[size_type(i)*this->table_size[1]+j];
2386 }
2387 
2388 
2389 
2390 template <typename T>
2391 inline
2392 typename AlignedVector<T>::const_reference
2393 Table<2,T>::operator () (const TableIndices<2> &indices) const
2394 {
2395  return TableBase<2,T>::operator () (indices);
2396 }
2397 
2398 
2399 
2400 template <typename T>
2401 inline
2402 typename AlignedVector<T>::reference
2404 {
2405  return TableBase<2,T>::operator () (indices);
2406 }
2407 
2408 
2409 
2410 template <typename T>
2411 inline
2412 typename AlignedVector<T>::const_reference
2413 Table<2,T>::el (const unsigned int i,
2414  const unsigned int j) const
2415 {
2416  return this->values[size_type(i)*this->table_size[1]+j];
2417 }
2418 
2419 
2420 
2421 template <typename T>
2422 inline
2423 typename AlignedVector<T>::reference
2424 Table<2,T>::el (const unsigned int i,
2425  const unsigned int j)
2426 {
2427  return this->values[size_type(i)*this->table_size[1]+j];
2428 }
2429 
2430 
2431 
2432 template <typename T>
2433 inline
2434 unsigned int
2435 Table<2,T>::n_rows () const
2436 {
2437  return this->table_size[0];
2438 }
2439 
2440 
2441 
2442 template <typename T>
2443 inline
2444 unsigned int
2445 Table<2,T>::n_cols () const
2446 {
2447  return this->table_size[1];
2448 }
2449 
2450 
2451 
2452 //---------------------------------------------------------------------------
2453 
2454 template <typename T>
2455 inline
2457 {}
2458 
2459 
2460 
2461 template <typename T>
2462 inline
2463 TransposeTable<T>::TransposeTable (const unsigned int size1,
2464  const unsigned int size2)
2465  :
2466  TableBase<2,T> (TableIndices<2> (size2, size1))
2467 {}
2468 
2469 
2470 
2471 template <typename T>
2472 inline
2473 void
2474 TransposeTable<T>::reinit (const unsigned int size1,
2475  const unsigned int size2,
2476  const bool omit_default_initialization)
2477 {
2478  this->TableBase<2,T>::reinit (TableIndices<2> (size2, size1), omit_default_initialization);
2479 }
2480 
2481 
2482 
2483 template <typename T>
2484 inline
2485 typename AlignedVector<T>::const_reference
2486 TransposeTable<T>::operator () (const unsigned int i,
2487  const unsigned int j) const
2488 {
2489  Assert (i < this->table_size[1],
2490  ExcIndexRange (i, 0, this->table_size[1]));
2491  Assert (j < this->table_size[0],
2492  ExcIndexRange (j, 0, this->table_size[0]));
2493  return this->values[size_type(j)*this->table_size[1]+i];
2494 }
2495 
2496 
2497 
2498 template <typename T>
2499 inline
2500 typename AlignedVector<T>::reference
2501 TransposeTable<T>::operator () (const unsigned int i,
2502  const unsigned int j)
2503 {
2504  Assert (i < this->table_size[1],
2505  ExcIndexRange (i, 0, this->table_size[1]));
2506  Assert (j < this->table_size[0],
2507  ExcIndexRange (j, 0, this->table_size[0]));
2508  return this->values[size_type(j)*this->table_size[1]+i];
2509 }
2510 
2511 
2512 
2513 template <typename T>
2514 inline
2515 typename AlignedVector<T>::const_reference
2516 TransposeTable<T>::el (const unsigned int i,
2517  const unsigned int j) const
2518 {
2519  return this->values[size_type(j)*this->table_size[1]+i];
2520 }
2521 
2522 
2523 
2524 template <typename T>
2525 inline
2526 typename AlignedVector<T>::reference
2527 TransposeTable<T>::el (const unsigned int i,
2528  const unsigned int j)
2529 {
2530  return this->values[size_type(j)*this->table_size[1]+i];
2531 }
2532 
2533 
2534 
2535 template <typename T>
2536 inline
2537 unsigned int
2539 {
2540  return this->table_size[1];
2541 }
2542 
2543 
2544 
2545 template <typename T>
2546 inline
2547 unsigned int
2549 {
2550  return this->table_size[0];
2551 }
2552 
2553 
2554 
2555 //---------------------------------------------------------------------------
2556 
2557 
2558 template <typename T>
2559 inline
2561 {}
2562 
2563 
2564 
2565 template <typename T>
2566 inline
2567 Table<3,T>::Table (const unsigned int size1,
2568  const unsigned int size2,
2569  const unsigned int size3)
2570  :
2571  TableBase<3,T> (TableIndices<3> (size1, size2, size3))
2572 {}
2573 
2574 
2575 
2576 template <typename T>
2577 template <typename InputIterator>
2578 inline
2579 Table<3,T>::Table (const unsigned int size1,
2580  const unsigned int size2,
2581  const unsigned int size3,
2582  InputIterator entries,
2583  const bool C_style_indexing)
2584  :
2585  TableBase<3,T> (TableIndices<3> (size1, size2, size3),
2586  entries,
2587  C_style_indexing)
2588 {}
2589 
2590 
2591 
2592 template <typename T>
2593 inline
2594 ::internal::TableBaseAccessors::Accessor<3,T,true,2>
2595 Table<3,T>::operator [] (const unsigned int i) const
2596 {
2597  Assert (i < this->table_size[0],
2598  ExcIndexRange (i, 0, this->table_size[0]));
2599  const size_type subobject_size = size_type(this->table_size[1]) *
2600  this->table_size[2];
2601  return (::internal::TableBaseAccessors::Accessor<3,T,true,2>
2602  (*this,
2603  this->values.begin() + i*subobject_size));
2604 }
2605 
2606 
2607 
2608 template <typename T>
2609 inline
2610 ::internal::TableBaseAccessors::Accessor<3,T,false,2>
2611 Table<3,T>::operator [] (const unsigned int i)
2612 {
2613  Assert (i < this->table_size[0],
2614  ExcIndexRange (i, 0, this->table_size[0]));
2615  const size_type subobject_size = size_type(this->table_size[1]) *
2616  this->table_size[2];
2617  return (::internal::TableBaseAccessors::Accessor<3,T,false,2>
2618  (*this,
2619  this->values.begin() + i*subobject_size));
2620 }
2621 
2622 
2623 
2624 template <typename T>
2625 inline
2626 typename AlignedVector<T>::const_reference
2627 Table<3,T>::operator () (const unsigned int i,
2628  const unsigned int j,
2629  const unsigned int k) const
2630 {
2631  Assert (i < this->table_size[0],
2632  ExcIndexRange (i, 0, this->table_size[0]));
2633  Assert (j < this->table_size[1],
2634  ExcIndexRange (j, 0, this->table_size[1]));
2635  Assert (k < this->table_size[2],
2636  ExcIndexRange (k, 0, this->table_size[2]));
2637  return this->values[(size_type(i)*this->table_size[1]+j)
2638  *this->table_size[2] + k];
2639 }
2640 
2641 
2642 
2643 template <typename T>
2644 inline
2645 typename AlignedVector<T>::reference
2646 Table<3,T>::operator () (const unsigned int i,
2647  const unsigned int j,
2648  const unsigned int k)
2649 {
2650  Assert (i < this->table_size[0],
2651  ExcIndexRange (i, 0, this->table_size[0]));
2652  Assert (j < this->table_size[1],
2653  ExcIndexRange (j, 0, this->table_size[1]));
2654  Assert (k < this->table_size[2],
2655  ExcIndexRange (k, 0, this->table_size[2]));
2656  return this->values[(size_type(i)*this->table_size[1]+j)
2657  *this->table_size[2] + k];
2658 }
2659 
2660 
2661 
2662 template <typename T>
2663 inline
2664 typename AlignedVector<T>::const_reference
2665 Table<3,T>::operator () (const TableIndices<3> &indices) const
2666 {
2667  return TableBase<3,T>::operator () (indices);
2668 }
2669 
2670 
2671 
2672 template <typename T>
2673 inline
2674 typename AlignedVector<T>::reference
2676 {
2677  return TableBase<3,T>::operator () (indices);
2678 }
2679 
2680 
2681 
2682 template <typename T>
2683 inline
2685 {}
2686 
2687 
2688 
2689 template <typename T>
2690 inline
2691 Table<4,T>::Table (const unsigned int size1,
2692  const unsigned int size2,
2693  const unsigned int size3,
2694  const unsigned int size4)
2695  :
2696  TableBase<4,T> (TableIndices<4> (size1, size2, size3, size4))
2697 {}
2698 
2699 
2700 
2701 template <typename T>
2702 inline
2703 ::internal::TableBaseAccessors::Accessor<4,T,true,3>
2704 Table<4,T>::operator [] (const unsigned int i) const
2705 {
2706  Assert (i < this->table_size[0],
2707  ExcIndexRange (i, 0, this->table_size[0]));
2708  const size_type subobject_size = size_type(this->table_size[1]) *
2709  this->table_size[2] *
2710  this->table_size[3];
2711  return (::internal::TableBaseAccessors::Accessor<4,T,true,3>
2712  (*this,
2713  this->values.begin() + i*subobject_size));
2714 }
2715 
2716 
2717 
2718 template <typename T>
2719 inline
2720 ::internal::TableBaseAccessors::Accessor<4,T,false,3>
2721 Table<4,T>::operator [] (const unsigned int i)
2722 {
2723  Assert (i < this->table_size[0],
2724  ExcIndexRange (i, 0, this->table_size[0]));
2725  const size_type subobject_size = size_type(this->table_size[1]) *
2726  this->table_size[2] *
2727  this->table_size[3];
2728  return (::internal::TableBaseAccessors::Accessor<4,T,false,3>
2729  (*this,
2730  this->values.begin() + i*subobject_size));
2731 }
2732 
2733 
2734 
2735 template <typename T>
2736 inline
2737 typename AlignedVector<T>::const_reference
2738 Table<4,T>::operator () (const unsigned int i,
2739  const unsigned int j,
2740  const unsigned int k,
2741  const unsigned int l) const
2742 {
2743  Assert (i < this->table_size[0],
2744  ExcIndexRange (i, 0, this->table_size[0]));
2745  Assert (j < this->table_size[1],
2746  ExcIndexRange (j, 0, this->table_size[1]));
2747  Assert (k < this->table_size[2],
2748  ExcIndexRange (k, 0, this->table_size[2]));
2749  Assert (l < this->table_size[3],
2750  ExcIndexRange (l, 0, this->table_size[3]));
2751  return this->values[((size_type(i)*this->table_size[1]+j)
2752  *this->table_size[2] + k)
2753  *this->table_size[3] + l];
2754 }
2755 
2756 
2757 
2758 template <typename T>
2759 inline
2760 typename AlignedVector<T>::reference
2761 Table<4,T>::operator () (const unsigned int i,
2762  const unsigned int j,
2763  const unsigned int k,
2764  const unsigned int l)
2765 {
2766  Assert (i < this->table_size[0],
2767  ExcIndexRange (i, 0, this->table_size[0]));
2768  Assert (j < this->table_size[1],
2769  ExcIndexRange (j, 0, this->table_size[1]));
2770  Assert (k < this->table_size[2],
2771  ExcIndexRange (k, 0, this->table_size[2]));
2772  Assert (l < this->table_size[3],
2773  ExcIndexRange (l, 0, this->table_size[3]));
2774  return this->values[((size_type(i)*this->table_size[1]+j)
2775  *this->table_size[2] + k)
2776  *this->table_size[3] + l];
2777 }
2778 
2779 
2780 
2781 template <typename T>
2782 inline
2783 typename AlignedVector<T>::const_reference
2784 Table<4,T>::operator () (const TableIndices<4> &indices) const
2785 {
2786  return TableBase<4,T>::operator () (indices);
2787 }
2788 
2789 
2790 
2791 template <typename T>
2792 inline
2793 typename AlignedVector<T>::reference
2795 {
2796  return TableBase<4,T>::operator () (indices);
2797 }
2798 
2799 
2800 
2801 template <typename T>
2802 inline
2804 {}
2805 
2806 
2807 
2808 template <typename T>
2809 inline
2810 Table<5,T>::Table (const unsigned int size1,
2811  const unsigned int size2,
2812  const unsigned int size3,
2813  const unsigned int size4,
2814  const unsigned int size5)
2815  :
2816  TableBase<5,T> (TableIndices<5> (size1, size2, size3, size4, size5))
2817 {}
2818 
2819 
2820 
2821 template <typename T>
2822 inline
2823 ::internal::TableBaseAccessors::Accessor<5,T,true,4>
2824 Table<5,T>::operator [] (const unsigned int i) const
2825 {
2826  Assert (i < this->table_size[0],
2827  ExcIndexRange (i, 0, this->table_size[0]));
2828  const size_type subobject_size = size_type(this->table_size[1]) *
2829  this->table_size[2] *
2830  this->table_size[3] *
2831  this->table_size[4];
2832  return (::internal::TableBaseAccessors::Accessor<5,T,true,4>
2833  (*this,
2834  this->values.begin() + i*subobject_size));
2835 }
2836 
2837 
2838 
2839 template <typename T>
2840 inline
2841 ::internal::TableBaseAccessors::Accessor<5,T,false,4>
2842 Table<5,T>::operator [] (const unsigned int i)
2843 {
2844  Assert (i < this->table_size[0],
2845  ExcIndexRange (i, 0, this->table_size[0]));
2846  const size_type subobject_size = size_type(this->table_size[1]) *
2847  this->table_size[2] *
2848  this->table_size[3] *
2849  this->table_size[4];
2850  return (::internal::TableBaseAccessors::Accessor<5,T,false,4>
2851  (*this,
2852  this->values.begin() + i*subobject_size));
2853 }
2854 
2855 
2856 
2857 template <typename T>
2858 inline
2859 typename AlignedVector<T>::const_reference
2860 Table<5,T>::operator () (const unsigned int i,
2861  const unsigned int j,
2862  const unsigned int k,
2863  const unsigned int l,
2864  const unsigned int m) const
2865 {
2866  Assert (i < this->table_size[0],
2867  ExcIndexRange (i, 0, this->table_size[0]));
2868  Assert (j < this->table_size[1],
2869  ExcIndexRange (j, 0, this->table_size[1]));
2870  Assert (k < this->table_size[2],
2871  ExcIndexRange (k, 0, this->table_size[2]));
2872  Assert (l < this->table_size[3],
2873  ExcIndexRange (l, 0, this->table_size[3]));
2874  Assert (m < this->table_size[4],
2875  ExcIndexRange (m, 0, this->table_size[4]));
2876  return this->values[(((size_type(i)*this->table_size[1]+j)
2877  *this->table_size[2] + k)
2878  *this->table_size[3] + l)
2879  *this->table_size[4] + m];
2880 }
2881 
2882 
2883 
2884 template <typename T>
2885 inline
2886 typename AlignedVector<T>::reference
2887 Table<5,T>::operator () (const unsigned int i,
2888  const unsigned int j,
2889  const unsigned int k,
2890  const unsigned int l,
2891  const unsigned int m)
2892 {
2893  Assert (i < this->table_size[0],
2894  ExcIndexRange (i, 0, this->table_size[0]));
2895  Assert (j < this->table_size[1],
2896  ExcIndexRange (j, 0, this->table_size[1]));
2897  Assert (k < this->table_size[2],
2898  ExcIndexRange (k, 0, this->table_size[2]));
2899  Assert (l < this->table_size[3],
2900  ExcIndexRange (l, 0, this->table_size[3]));
2901  Assert (m < this->table_size[4],
2902  ExcIndexRange (m, 0, this->table_size[4]));
2903  return this->values[(((size_type(i)*this->table_size[1]+j)
2904  *this->table_size[2] + k)
2905  *this->table_size[3] + l)
2906  *this->table_size[4] + m];
2907 }
2908 
2909 
2910 
2911 template <typename T>
2912 inline
2913 typename AlignedVector<T>::const_reference
2914 Table<5,T>::operator () (const TableIndices<5> &indices) const
2915 {
2916  return TableBase<5,T>::operator () (indices);
2917 }
2918 
2919 
2920 
2921 template <typename T>
2922 inline
2923 typename AlignedVector<T>::reference
2925 {
2926  return TableBase<5,T>::operator () (indices);
2927 }
2928 
2929 
2930 
2931 template <typename T>
2932 inline
2934 {}
2935 
2936 
2937 
2938 template <typename T>
2939 inline
2940 Table<6,T>::Table (const unsigned int size1,
2941  const unsigned int size2,
2942  const unsigned int size3,
2943  const unsigned int size4,
2944  const unsigned int size5,
2945  const unsigned int size6)
2946  :
2947  TableBase<6,T> (TableIndices<6> (size1, size2, size3, size4, size5, size6))
2948 {}
2949 
2950 
2951 
2952 template <typename T>
2953 inline
2954 ::internal::TableBaseAccessors::Accessor<6,T,true,5>
2955 Table<6,T>::operator [] (const unsigned int i) const
2956 {
2957  Assert (i < this->table_size[0],
2958  ExcIndexRange (i, 0, this->table_size[0]));
2959  const size_type subobject_size = size_type(this->table_size[1]) *
2960  this->table_size[2] *
2961  this->table_size[3] *
2962  this->table_size[4] *
2963  this->table_size[5];
2964  return (::internal::TableBaseAccessors::Accessor<6,T,true,5>
2965  (*this,
2966  this->values.begin() + i*subobject_size));
2967 }
2968 
2969 
2970 
2971 template <typename T>
2972 inline
2973 ::internal::TableBaseAccessors::Accessor<6,T,false,5>
2974 Table<6,T>::operator [] (const unsigned int i)
2975 {
2976  Assert (i < this->table_size[0],
2977  ExcIndexRange (i, 0, this->table_size[0]));
2978  const size_type subobject_size = size_type(this->table_size[1]) *
2979  this->table_size[2] *
2980  this->table_size[3] *
2981  this->table_size[4] *
2982  this->table_size[5];
2983  return (::internal::TableBaseAccessors::Accessor<6,T,false,5>
2984  (*this,
2985  this->values.begin() + i*subobject_size));
2986 }
2987 
2988 
2989 
2990 template <typename T>
2991 inline
2992 typename AlignedVector<T>::const_reference
2993 Table<6,T>::operator () (const unsigned int i,
2994  const unsigned int j,
2995  const unsigned int k,
2996  const unsigned int l,
2997  const unsigned int m,
2998  const unsigned int n) const
2999 {
3000  Assert (i < this->table_size[0],
3001  ExcIndexRange (i, 0, this->table_size[0]));
3002  Assert (j < this->table_size[1],
3003  ExcIndexRange (j, 0, this->table_size[1]));
3004  Assert (k < this->table_size[2],
3005  ExcIndexRange (k, 0, this->table_size[2]));
3006  Assert (l < this->table_size[3],
3007  ExcIndexRange (l, 0, this->table_size[3]));
3008  Assert (m < this->table_size[4],
3009  ExcIndexRange (m, 0, this->table_size[4]));
3010  Assert (n < this->table_size[5],
3011  ExcIndexRange (n, 0, this->table_size[5]));
3012  return this->values[((((size_type(i)*this->table_size[1]+j)
3013  *this->table_size[2] + k)
3014  *this->table_size[3] + l)
3015  *this->table_size[4] + m)
3016  *this->table_size[5] + n];
3017 }
3018 
3019 
3020 
3021 template <typename T>
3022 inline
3023 typename AlignedVector<T>::reference
3024 Table<6,T>::operator () (const unsigned int i,
3025  const unsigned int j,
3026  const unsigned int k,
3027  const unsigned int l,
3028  const unsigned int m,
3029  const unsigned int n)
3030 {
3031  Assert (i < this->table_size[0],
3032  ExcIndexRange (i, 0, this->table_size[0]));
3033  Assert (j < this->table_size[1],
3034  ExcIndexRange (j, 0, this->table_size[1]));
3035  Assert (k < this->table_size[2],
3036  ExcIndexRange (k, 0, this->table_size[2]));
3037  Assert (l < this->table_size[3],
3038  ExcIndexRange (l, 0, this->table_size[3]));
3039  Assert (m < this->table_size[4],
3040  ExcIndexRange (m, 0, this->table_size[4]));
3041  Assert (n < this->table_size[5],
3042  ExcIndexRange (n, 0, this->table_size[5]));
3043  return this->values[((((size_type(i)*this->table_size[1]+j)
3044  *this->table_size[2] + k)
3045  *this->table_size[3] + l)
3046  *this->table_size[4] + m)
3047  *this->table_size[5] + n];
3048 }
3049 
3050 
3051 
3052 template <typename T>
3053 inline
3054 typename AlignedVector<T>::const_reference
3055 Table<6,T>::operator () (const TableIndices<6> &indices) const
3056 {
3057  return TableBase<6,T>::operator () (indices);
3058 }
3059 
3060 
3061 
3062 template <typename T>
3063 inline
3064 typename AlignedVector<T>::reference
3066 {
3067  return TableBase<6,T>::operator () (indices);
3068 }
3069 
3070 
3071 
3072 template <typename T>
3073 inline
3075 {}
3076 
3077 
3078 
3079 template <typename T>
3080 inline
3081 Table<7,T>::Table (const unsigned int size1,
3082  const unsigned int size2,
3083  const unsigned int size3,
3084  const unsigned int size4,
3085  const unsigned int size5,
3086  const unsigned int size6,
3087  const unsigned int size7)
3088  :
3089  TableBase<7,T> (TableIndices<7> (size1, size2, size3, size4, size5, size6, size7))
3090 {}
3091 
3092 
3093 
3094 template <typename T>
3095 inline
3096 ::internal::TableBaseAccessors::Accessor<7,T,true,6>
3097 Table<7,T>::operator [] (const unsigned int i) const
3098 {
3099  Assert (i < this->table_size[0],
3100  ExcIndexRange (i, 0, this->table_size[0]));
3101  const size_type subobject_size = size_type(this->table_size[1]) *
3102  this->table_size[2] *
3103  this->table_size[3] *
3104  this->table_size[4] *
3105  this->table_size[5] *
3106  this->table_size[6];
3107  return (::internal::TableBaseAccessors::Accessor<7,T,true,6>
3108  (*this,
3109  this->values.begin() + i*subobject_size));
3110 }
3111 
3112 
3113 
3114 template <typename T>
3115 inline
3116 ::internal::TableBaseAccessors::Accessor<7,T,false,6>
3117 Table<7,T>::operator [] (const unsigned int i)
3118 {
3119  Assert (i < this->table_size[0],
3120  ExcIndexRange (i, 0, this->table_size[0]));
3121  const size_type subobject_size = size_type(this->table_size[1]) *
3122  this->table_size[2] *
3123  this->table_size[3] *
3124  this->table_size[4] *
3125  this->table_size[5] *
3126  this->table_size[6];
3127  return (::internal::TableBaseAccessors::Accessor<7,T,false,6>
3128  (*this,
3129  this->values.begin() + i*subobject_size));
3130 }
3131 
3132 
3133 
3134 template <typename T>
3135 inline
3136 typename AlignedVector<T>::const_reference
3137 Table<7,T>::operator () (const unsigned int i,
3138  const unsigned int j,
3139  const unsigned int k,
3140  const unsigned int l,
3141  const unsigned int m,
3142  const unsigned int n,
3143  const unsigned int o) const
3144 {
3145  Assert (i < this->table_size[0],
3146  ExcIndexRange (i, 0, this->table_size[0]));
3147  Assert (j < this->table_size[1],
3148  ExcIndexRange (j, 0, this->table_size[1]));
3149  Assert (k < this->table_size[2],
3150  ExcIndexRange (k, 0, this->table_size[2]));
3151  Assert (l < this->table_size[3],
3152  ExcIndexRange (l, 0, this->table_size[3]));
3153  Assert (m < this->table_size[4],
3154  ExcIndexRange (m, 0, this->table_size[4]));
3155  Assert (n < this->table_size[5],
3156  ExcIndexRange (n, 0, this->table_size[5]));
3157  Assert (o < this->table_size[6],
3158  ExcIndexRange (o, 0, this->table_size[6]));
3159  return this->values[(((((size_type(i)*this->table_size[1]+j)
3160  *this->table_size[2] + k)
3161  *this->table_size[3] + l)
3162  *this->table_size[4] + m)
3163  *this->table_size[5] + n)
3164  *this->table_size[6] + o];
3165 }
3166 
3167 
3168 
3169 template <typename T>
3170 inline
3171 typename AlignedVector<T>::reference
3172 Table<7,T>::operator () (const unsigned int i,
3173  const unsigned int j,
3174  const unsigned int k,
3175  const unsigned int l,
3176  const unsigned int m,
3177  const unsigned int n,
3178  const unsigned int o)
3179 {
3180  Assert (i < this->table_size[0],
3181  ExcIndexRange (i, 0, this->table_size[0]));
3182  Assert (j < this->table_size[1],
3183  ExcIndexRange (j, 0, this->table_size[1]));
3184  Assert (k < this->table_size[2],
3185  ExcIndexRange (k, 0, this->table_size[2]));
3186  Assert (l < this->table_size[3],
3187  ExcIndexRange (l, 0, this->table_size[3]));
3188  Assert (m < this->table_size[4],
3189  ExcIndexRange (m, 0, this->table_size[4]));
3190  Assert (n < this->table_size[5],
3191  ExcIndexRange (n, 0, this->table_size[5]));
3192  Assert (o < this->table_size[5],
3193  ExcIndexRange (o, 0, this->table_size[6]));
3194  return this->values[(((((size_type(i)*this->table_size[1]+j)
3195  *this->table_size[2] + k)
3196  *this->table_size[3] + l)
3197  *this->table_size[4] + m)
3198  *this->table_size[5] + n)
3199  *this->table_size[6] + o];
3200 }
3201 
3202 
3203 
3204 template <typename T>
3205 inline
3206 typename AlignedVector<T>::const_reference
3207 Table<7,T>::operator () (const TableIndices<7> &indices) const
3208 {
3209  return TableBase<7,T>::operator () (indices);
3210 }
3211 
3212 
3213 
3214 template <typename T>
3215 inline
3216 typename AlignedVector<T>::reference
3218 {
3219  return TableBase<7,T>::operator () (indices);
3220 }
3221 
3222 
3223 #endif // DOXYGEN
3224 
3225 
3226 
3234 template <int N, typename T>
3235 inline
3236 void swap (TableBase<N,T> &u, TableBase<N,T> &v)
3237 {
3238  u.swap (v);
3239 }
3240 
3241 DEAL_II_NAMESPACE_CLOSE
3242 
3243 #endif
bool operator==(const TableBase< N, T > &T2) const
TableBase< 6, T >::size_type size_type
Definition: table.h:1331
size_type position(const TableIndices< N > &indices) const
void serialize(Archive &ar, const unsigned int version)
void swap(TableBase< N, T > &v)
const TableIndices< N > & size() const
AlignedVector< T >::reference el(const unsigned int i, const unsigned int j)
TableBase< N, T > & operator=(const TableBase< N, T > &src)
STL namespace.
TableBase< 7, T >::size_type size_type
Definition: table.h:1427
TableBase< 4, T >::size_type size_type
Definition: table.h:1144
unsigned int n_cols() const
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
size_type n_elements() const
SymmetricTensor< 2, dim, Number > C(const Tensor< 2, dim, Number > &F)
TableBase< 2, T >::size_type size_type
Definition: table.h:825
static ::ExceptionBase & ExcMessage(std::string arg1)
TableBase< 5, T >::size_type size_type
Definition: table.h:1236
TableBase< 2, T >::size_type size_type
Definition: table.h:1530
void swap(BlockIndices &u, BlockIndices &v)
void reinit(const TableIndices< N > &new_size, const bool omit_default_initialization=false)
#define Assert(cond, exc)
Definition: exceptions.h:313
AlignedVector< T >::reference el(const TableIndices< N > &indices)
unsigned int n_rows() const
AlignedVector< T >::const_reference operator()(const unsigned int i, const unsigned int j) const
std_cxx11::enable_if< std_cxx11::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
std::size_t memory_consumption() const
void reset_values()
TableBase< 3, T >::size_type size_type
Definition: table.h:1010
static ::ExceptionBase & ExcNotImplemented()
Definition: table.h:33
bool empty() const
unsigned int size(const unsigned int i) const
TableIndices< N > table_size
Definition: table.h:659
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition: exceptions.h:588
AlignedVector< T >::size_type size_type
Definition: table.h:411
TableBase< 1, T >::size_type size_type
Definition: table.h:706
AlignedVector< T >::reference operator()(const TableIndices< N > &indices)
AlignedVector< T > values
Definition: table.h:654
void reinit(const unsigned int size1, const unsigned int size2, const bool omit_default_initialization=false)
void fill(InputIterator entries, const bool C_style_indexing=true)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
static ::ExceptionBase & ExcInternalError()