Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
table_indices.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2005 - 2020 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.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_table_indices_h
17 #define dealii_table_indices_h
18 
19 
20 #include <deal.II/base/config.h>
21 
24 
25 #include <algorithm>
26 #include <iterator>
27 #include <ostream>
28 
29 
31 
32 
44 template <int N>
46 {
47 public:
48  static_assert(N > 0,
49  "TableIndices objects need to represent at least one index.");
50 
51 
55  constexpr TableIndices() = default;
56 
64  template <typename... T>
65  constexpr TableIndices(const T... indices);
66 
70  DEAL_II_CONSTEXPR std::size_t operator[](const unsigned int i) const;
71 
75  DEAL_II_CONSTEXPR std::size_t &operator[](const unsigned int i);
76 
80  constexpr bool
81  operator==(const TableIndices<N> &other) const;
82 
86  constexpr bool
87  operator!=(const TableIndices<N> &other) const;
88 
94  sort();
95 
100  template <class Archive>
101  void
102  serialize(Archive &ar, const unsigned int version);
103 
104 protected:
108  std::size_t indices[N]{};
109 };
110 
111 
112 
113 /* --------------------- Template and inline functions ---------------- */
114 
115 template <int N>
116 template <typename... T>
117 constexpr TableIndices<N>::TableIndices(const T... args)
118  : indices{static_cast<const unsigned int>(args)...}
119 {
122  "Not all of the parameters have integral type!");
123  static_assert(sizeof...(T) == N, "Wrong number of constructor arguments!");
124 }
125 
126 
127 template <int N>
128 DEAL_II_CONSTEXPR inline std::size_t TableIndices<N>::
129  operator[](const unsigned int i) const
130 {
131  AssertIndexRange(i, N);
132  return indices[i];
133 }
134 
135 
136 template <int N>
137 DEAL_II_CONSTEXPR inline std::size_t &TableIndices<N>::
138  operator[](const unsigned int i)
139 {
140  AssertIndexRange(i, N);
141  return indices[i];
142 }
143 
144 
145 template <int N>
146 constexpr bool
148 {
149  return std::equal(std::begin(indices),
150  std::end(indices),
151  std::begin(other.indices));
152 }
153 
154 
155 template <int N>
156 constexpr bool
158 {
159  return !(*this == other);
160 }
161 
162 
163 template <int N>
164 DEAL_II_CONSTEXPR inline void
166 {
167  std::sort(std::begin(indices), std::end(indices));
168 }
169 
170 
171 template <int N>
172 template <class Archive>
173 inline void
174 TableIndices<N>::serialize(Archive &ar, const unsigned int)
175 {
176  ar &indices;
177 }
178 
179 
186 template <int N>
187 std::ostream &
188 operator<<(std::ostream &out, const TableIndices<N> &indices)
189 {
190  out << '[';
191  for (unsigned int i = 0; i < N; ++i)
192  {
193  out << indices[i];
194  if (i + 1 != N)
195  out << ',';
196  }
197  out << ']';
198 
199  return out;
200 }
201 
202 
204 
205 #endif
TableIndices
Definition: table_indices.h:45
AssertIndexRange
#define AssertIndexRange(index, range)
Definition: exceptions.h:1649
TableIndices::serialize
void serialize(Archive &ar, const unsigned int version)
Definition: table_indices.h:174
TableIndices::TableIndices
constexpr TableIndices()=default
DEAL_II_CONSTEXPR
#define DEAL_II_CONSTEXPR
Definition: config.h:102
LAPACKSupport::T
static const char T
Definition: lapack_support.h:163
TrilinosWrappers::internal::begin
VectorType::value_type * begin(VectorType &V)
Definition: trilinos_sparse_matrix.cc:51
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
TrilinosWrappers::internal::end
VectorType::value_type * end(VectorType &V)
Definition: trilinos_sparse_matrix.cc:65
exceptions.h
value
static const bool value
Definition: dof_tools_constraints.cc:433
TableIndices::operator!=
constexpr bool operator!=(const TableIndices< N > &other) const
Definition: table_indices.h:157
TableIndices< N >
Algorithms::OutputOperator::operator<<
OutputOperator< VectorType > & operator<<(OutputOperator< VectorType > &out, unsigned int step)
Definition: operator.h:173
TableIndices::operator==
constexpr bool operator==(const TableIndices< N > &other) const
Definition: table_indices.h:147
TableIndices::operator[]
constexpr std::size_t operator[](const unsigned int i) const
Definition: table_indices.h:129
TableIndices::indices
std::size_t indices[N]
Definition: table_indices.h:108
template_constraints.h
config.h
TableIndices::sort
constexpr void sort()
Definition: table_indices.h:165
LAPACKSupport::N
static const char N
Definition: lapack_support.h:159
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
internal::TemplateConstraints::all_true
Definition: template_constraints.h:44