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\}}\)
matrix_iterator.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2019 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 
34 template <class ACCESSOR>
36 {
37 public:
42 
46  using MatrixType = typename ACCESSOR::MatrixType;
47 
53  const size_type row = 0,
54  const size_type index = 0);
55 
62  template <class OtherAccessor>
64 
69  operator++();
70 
75  operator++(int);
76 
80  const ACCESSOR &operator*() const;
81 
85  const ACCESSOR *operator->() const;
86 
90  bool
91  operator==(const MatrixIterator &) const;
92 
96  bool
97  operator!=(const MatrixIterator &) const;
98 
105  bool
106  operator<(const MatrixIterator &) const;
107 
112  bool
113  operator>(const MatrixIterator &) const;
114 
115 private:
119  ACCESSOR accessor;
120 
121  // Allow other iterators access to private data.
122  template <class OtherAccessor>
123  friend class MatrixIterator;
124 };
125 
126 
127 //----------------------------------------------------------------------//
128 
129 template <class ACCESSOR>
131  const size_type r,
132  const size_type i)
133  : accessor(matrix, r, i)
134 {}
135 
136 
137 template <class ACCESSOR>
138 template <class OtherAccessor>
140  const MatrixIterator<OtherAccessor> &other)
141  : accessor(other.accessor)
142 {}
143 
144 
145 template <class ACCESSOR>
148 {
149  accessor.advance();
150  return *this;
151 }
152 
153 
154 template <class ACCESSOR>
157 {
158  const MatrixIterator iter = *this;
159  accessor.advance();
160  return iter;
161 }
162 
163 
164 template <class ACCESSOR>
165 inline const ACCESSOR &MatrixIterator<ACCESSOR>::operator*() const
166 {
167  return accessor;
168 }
169 
170 
171 template <class ACCESSOR>
172 inline const ACCESSOR *MatrixIterator<ACCESSOR>::operator->() const
173 {
174  return &accessor;
175 }
176 
177 
178 template <class ACCESSOR>
179 inline bool
181 {
182  return (accessor == other.accessor);
183 }
184 
185 
186 template <class ACCESSOR>
187 inline bool
189 {
190  return !(*this == other);
191 }
192 
193 
194 template <class ACCESSOR>
195 inline bool
197 {
198  Assert(&accessor.get_matrix() == &other.accessor.get_matrix(),
199  ExcInternalError());
200 
201  return (accessor < other.accessor);
202 }
203 
204 
205 template <class ACCESSOR>
206 inline bool
208 {
209  return (other < *this);
210 }
211 
213 
214 #endif
MatrixIterator::operator->
const ACCESSOR * operator->() const
Definition: matrix_iterator.h:172
MatrixIterator::MatrixIterator
friend class MatrixIterator
Definition: matrix_iterator.h:123
MatrixIterator::operator++
MatrixIterator & operator++()
Definition: matrix_iterator.h:147
MatrixIterator
Definition: matrix_iterator.h:35
MatrixIterator::operator>
bool operator>(const MatrixIterator &) const
Definition: matrix_iterator.h:207
MatrixIterator::accessor
ACCESSOR accessor
Definition: matrix_iterator.h:119
types::global_dof_index
unsigned int global_dof_index
Definition: types.h:76
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
LAPACKSupport::matrix
@ matrix
Contents is actually a matrix.
Definition: lapack_support.h:60
MatrixIterator::operator!=
bool operator!=(const MatrixIterator &) const
Definition: matrix_iterator.h:188
exceptions.h
unsigned int
StandardExceptions::ExcInternalError
static ::ExceptionBase & ExcInternalError()
Assert
#define Assert(cond, exc)
Definition: exceptions.h:1419
MatrixIterator::operator==
bool operator==(const MatrixIterator &) const
Definition: matrix_iterator.h:180
MatrixIterator::MatrixType
typename ACCESSOR::MatrixType MatrixType
Definition: matrix_iterator.h:46
MatrixIterator::operator*
const ACCESSOR & operator*() const
Definition: matrix_iterator.h:165
config.h
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
MatrixIterator::operator<
bool operator<(const MatrixIterator &) const
Definition: matrix_iterator.h:196