Reference documentation for deal.II version Git d902c8c1aa 2019-12-15 00:36:45 -0500
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
Public Types | Public Member Functions | List of all members
SparsityPatternIterators::Iterator Class Reference

#include <deal.II/lac/sparsity_pattern.h>

Inheritance diagram for SparsityPatternIterators::Iterator:
[legend]

Public Types

using size_type = types::global_dof_index
 
using container_pointer_type = SparsityPatternBase *
 
- Public Types inherited from LinearIndexIterator< Iterator, Accessor >
using iterator_category = std::random_access_iterator_tag
 
using value_type = Accessor
 
using difference_type = std::ptrdiff_t
 
using reference = const value_type &
 
using pointer = const value_type *
 
using size_type = typename value_type::size_type
 

Public Member Functions

 Iterator (const SparsityPatternBase *sp, const std::size_t linear_index)
 
 Iterator (const Accessor &accessor)
 
- Public Member Functions inherited from LinearIndexIterator< Iterator, Accessor >
Iterator & operator= (const Iterator &it)
 
Iterator & operator++ ()
 
Iterator operator++ (int)
 
Iterator & operator-- ()
 
Iterator operator-- (int)
 
Iterator operator+ (const difference_type n) const
 
Iterator operator- (const difference_type n) const
 
difference_type operator- (const Iterator &p) const
 
Iterator & operator+= (const difference_type n)
 
Iterator & operator-= (const difference_type n)
 
reference operator* () const
 
pointer operator-> () const
 
bool operator== (const Iterator &) const
 
bool operator!= (const Iterator &) const
 
bool operator<= (const Iterator &) const
 
bool operator>= (const Iterator &) const
 
bool operator< (const Iterator &) const
 
bool operator> (const Iterator &) const
 

Additional Inherited Members

- Protected Member Functions inherited from LinearIndexIterator< Iterator, Accessor >
 LinearIndexIterator (const Accessor accessor)
 
- Protected Attributes inherited from LinearIndexIterator< Iterator, Accessor >
Accessor accessor
 

Detailed Description

An iterator class for walking over the elements of a sparsity pattern.

The typical use for these iterators is to iterate over the elements of a sparsity pattern (or, since they also serve as the basis for iterating over the elements of an associated matrix, over the elements of a sparse matrix), or over the elements of individual rows. There is no guarantee that the elements of a row are actually traversed in an order in which column numbers monotonically increase. See the documentation of the SparsityPattern class for more information.

Note
This class operates directly on the internal data structures of the SparsityPatternBase class. As a consequence, some operations are cheap and some are not. In particular, it is cheap to access the column index of the sparsity pattern entry pointed to. On the other hand, it is expensive to access the row index (this requires \(O(\log(N))\) operations for a matrix with \(N\) row). As a consequence, when you design algorithms that use these iterators, it is common practice to not loop over all elements of a sparsity pattern at once, but to have an outer loop over all rows and within this loop iterate over the elements of this row. This way, you only ever need to dereference the iterator to obtain the column indices whereas the (expensive) lookup of the row index can be avoided by using the loop index instead.

Definition at line 281 of file sparsity_pattern.h.

Member Typedef Documentation

◆ size_type

Size type.

Definition at line 287 of file sparsity_pattern.h.

◆ container_pointer_type

Type of the stored pointer.

Definition at line 292 of file sparsity_pattern.h.

Constructor & Destructor Documentation

◆ Iterator() [1/2]

SparsityPatternIterators::Iterator::Iterator ( const SparsityPatternBase sp,
const std::size_t  linear_index 
)

Constructor. Create an iterator into the sparsity pattern sp for the given global index (i.e., the index of the given element counting from the zeroth row).

◆ Iterator() [2/2]

SparsityPatternIterators::Iterator::Iterator ( const Accessor accessor)

Constructor. Create an iterator into the sparsity pattern sp for a given accessor.


The documentation for this class was generated from the following file: