Reference documentation for deal.II version GIT 5ac9d67d2d 2023-06-07 21:45:01+00:00
\(\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\}}\)
matrix_iterator.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2021 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_matrix_iterator_h
17 #define dealii_matrix_iterator_h
18 
19 
20 #include <deal.II/base/config.h>
21 
23 
25 
32 template <class ACCESSOR>
34 {
35 public:
40 
44  using MatrixType = typename ACCESSOR::MatrixType;
45 
51  const size_type row = 0,
52  const size_type index = 0);
53 
60  template <class OtherAccessor>
62 
67  operator++();
68 
73  operator++(int);
74 
78  const ACCESSOR &
79  operator*() const;
80 
84  const ACCESSOR *
85  operator->() const;
86 
90  template <class OtherAccessor>
91  bool
93 
97  template <class OtherAccessor>
98  bool
100 
107  bool
108  operator<(const MatrixIterator &) const;
109 
114  bool
115  operator>(const MatrixIterator &) const;
116 
117 private:
121  ACCESSOR accessor;
122 
123  // Allow other iterators access to private data.
124  template <class OtherAccessor>
125  friend class MatrixIterator;
126 };
127 
128 
129 //----------------------------------------------------------------------//
130 
131 template <class ACCESSOR>
133  const size_type r,
134  const size_type i)
135  : accessor(matrix, r, i)
136 {}
137 
138 
139 template <class ACCESSOR>
140 template <class OtherAccessor>
142  const MatrixIterator<OtherAccessor> &other)
143  : accessor(other.accessor)
144 {}
145 
146 
147 template <class ACCESSOR>
150 {
151  accessor.advance();
152  return *this;
153 }
154 
155 
156 template <class ACCESSOR>
159 {
160  const MatrixIterator iter = *this;
161  accessor.advance();
162  return iter;
163 }
164 
165 
166 template <class ACCESSOR>
167 inline const ACCESSOR &
169 {
170  return accessor;
171 }
172 
173 
174 template <class ACCESSOR>
175 inline const ACCESSOR *
177 {
178  return &accessor;
179 }
180 
181 
182 template <class ACCESSOR>
183 template <class OtherAccessor>
184 inline bool
186  const MatrixIterator<OtherAccessor> &other) const
187 {
188  return (accessor == other.accessor);
189 }
190 
191 
192 template <class ACCESSOR>
193 template <class OtherAccessor>
194 inline bool
196  const MatrixIterator<OtherAccessor> &other) const
197 {
198  return !(*this == other);
199 }
200 
201 
202 template <class ACCESSOR>
203 inline bool
205 {
206  Assert(&accessor.get_matrix() == &other.accessor.get_matrix(),
207  ExcInternalError());
208 
209  return (accessor < other.accessor);
210 }
211 
212 
213 template <class ACCESSOR>
214 inline bool
216 {
217  return (other < *this);
218 }
219 
221 
222 #endif
MatrixIterator & operator++()
const ACCESSOR * operator->() const
bool operator==(const MatrixIterator< OtherAccessor > &) const
bool operator<(const MatrixIterator &) const
typename ACCESSOR::MatrixType MatrixType
bool operator!=(const MatrixIterator< OtherAccessor > &) const
friend class MatrixIterator
types::global_dof_index size_type
bool operator>(const MatrixIterator &) const
const ACCESSOR & operator*() const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:474
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:475
static ::ExceptionBase & ExcInternalError()
#define Assert(cond, exc)
Definition: exceptions.h:1614
@ matrix
Contents is actually a matrix.
unsigned int global_dof_index
Definition: types.h:82