Reference documentation for deal.II version Git 8ba89c874e 2021-08-04 22:06:33 -0600
\(\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\}}\)
Public Types | Public Member Functions | Protected Attributes | 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 *
 
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 *
 

Public Member Functions

 Iterator (const SparsityPatternBase *sp, const std::size_t linear_index)
 
 Iterator (const Accessor &accessor)
 
Iteratoroperator++ ()
 
Iterator operator++ (int)
 
Iteratoroperator-- ()
 
Iterator operator-- (int)
 
Iterator operator+ (const difference_type n) const
 
Iterator operator- (const difference_type n) const
 
difference_type operator- (const Iterator &p) const
 
Iteratoroperator+= (const difference_type n)
 
Iteratoroperator-= (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
 

Protected Attributes

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 278 of file sparsity_pattern.h.

Member Typedef Documentation

◆ size_type

Size type.

Definition at line 284 of file sparsity_pattern.h.

◆ container_pointer_type

Type of the stored pointer.

Definition at line 289 of file sparsity_pattern.h.

◆ iterator_category

using LinearIndexIterator< Iterator , Accessor >::iterator_category = std::random_access_iterator_tag
inherited

Iterator category.

Definition at line 145 of file linear_index_iterator.h.

◆ value_type

An alias for the type you get when you dereference an iterator of the current kind.

Definition at line 151 of file linear_index_iterator.h.

◆ difference_type

using LinearIndexIterator< Iterator , Accessor >::difference_type = std::ptrdiff_t
inherited

Difference type.

Definition at line 156 of file linear_index_iterator.h.

◆ reference

using LinearIndexIterator< Iterator , Accessor >::reference = const value_type &
inherited

Reference type.

Definition at line 161 of file linear_index_iterator.h.

◆ pointer

using LinearIndexIterator< Iterator , Accessor >::pointer = const value_type *
inherited

Pointer type.

Definition at line 166 of file linear_index_iterator.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.

Member Function Documentation

◆ operator++() [1/2]

Iterator & LinearIndexIterator< Iterator , Accessor >::operator++ ( )
inlineinherited

Prefix increment.

Definition at line 345 of file linear_index_iterator.h.

◆ operator++() [2/2]

Iterator LinearIndexIterator< Iterator , Accessor >::operator++ ( int  )
inlineinherited

Postfix increment.

Definition at line 354 of file linear_index_iterator.h.

◆ operator--() [1/2]

Iterator & LinearIndexIterator< Iterator , Accessor >::operator-- ( )
inlineinherited

Prefix decrement.

Definition at line 365 of file linear_index_iterator.h.

◆ operator--() [2/2]

Iterator LinearIndexIterator< Iterator , Accessor >::operator-- ( int  )
inlineinherited

Postfix decrement.

Definition at line 374 of file linear_index_iterator.h.

◆ operator+()

Iterator LinearIndexIterator< Iterator , Accessor >::operator+ ( const difference_type  n) const
inlineinherited

Return an iterator that is n entries ahead of the current one.

Definition at line 385 of file linear_index_iterator.h.

◆ operator-() [1/2]

Iterator LinearIndexIterator< Iterator , Accessor >::operator- ( const difference_type  n) const
inlineinherited

Return an iterator that is n entries behind the current one.

Definition at line 397 of file linear_index_iterator.h.

◆ operator-() [2/2]

LinearIndexIterator< Iterator , Accessor >::difference_type LinearIndexIterator< Iterator , Accessor >::operator- ( const Iterator &  p) const
inlineinherited

Return the distance between the current iterator and the argument. The distance is given by how many times one has to apply operator++() to the current iterator to get the argument (for a positive return value), or operator--() (for a negative return value).

Definition at line 431 of file linear_index_iterator.h.

◆ operator+=()

Iterator & LinearIndexIterator< Iterator , Accessor >::operator+= ( const difference_type  n)
inlineinherited

Increment the iterator position by n.

Definition at line 409 of file linear_index_iterator.h.

◆ operator-=()

Iterator & LinearIndexIterator< Iterator , Accessor >::operator-= ( const difference_type  n)
inlineinherited

Decrement the iterator position by n.

Definition at line 420 of file linear_index_iterator.h.

◆ operator*()

LinearIndexIterator< Iterator , Accessor >::reference LinearIndexIterator< Iterator , Accessor >::operator* ( ) const
inlineinherited

Dereferencing operator.

Definition at line 444 of file linear_index_iterator.h.

◆ operator->()

LinearIndexIterator< Iterator , Accessor >::pointer LinearIndexIterator< Iterator , Accessor >::operator-> ( ) const
inlineinherited

Dereferencing operator.

Definition at line 453 of file linear_index_iterator.h.

◆ operator<=()

bool LinearIndexIterator< Iterator , Accessor >::operator<= ( const Iterator &  other) const
inlineinherited

Comparison operator: uses the same ordering as operator<(), but also checks for equality.

This function is only valid if both iterators point into the same container.

Definition at line 462 of file linear_index_iterator.h.

◆ operator>=()

bool LinearIndexIterator< Iterator , Accessor >::operator>= ( const Iterator &  other) const
inlineinherited

Comparison operator: uses the same ordering as operator>(), but also checks for equality.

This function is only valid if both iterators point into the same container.

Definition at line 472 of file linear_index_iterator.h.

◆ operator<()

bool LinearIndexIterator< Iterator , Accessor >::operator< ( const Iterator &  other) const
inlineinherited

Comparison operator. Result is true if either the first row number is smaller or if the row numbers are equal and the first index is smaller.

This function is only valid if both iterators point into the same container.

Definition at line 482 of file linear_index_iterator.h.

◆ operator>()

bool LinearIndexIterator< Iterator , Accessor >::operator> ( const Iterator &  other) const
inlineinherited

Comparison operator. Works in the same way as operator<(), just the other way round.

Definition at line 495 of file linear_index_iterator.h.

Member Data Documentation

◆ accessor

Accessor LinearIndexIterator< Iterator , Accessor >::accessor
protectedinherited

Store an object of the accessor class.

Definition at line 326 of file linear_index_iterator.h.


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