Reference documentation for deal.II version 9.6.2
 
\(\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\}}\)
Loading...
Searching...
No Matches
SparseMatrixIterators::Accessor< number, false >::Reference Class Reference
Inheritance diagram for SparseMatrixIterators::Accessor< number, false >::Reference:

Public Types

using size_type
 

Public Member Functions

 Reference (const Accessor *accessor, const bool dummy)
 
 operator number () const
 
const Referenceoperator= (const number n) const
 
const Referenceoperator+= (const number n) const
 
const Referenceoperator-= (const number n) const
 
const Referenceoperator*= (const number n) const
 
const Referenceoperator/= (const number n) const
 
number value () const
 
number & value ()
 
const SparseMatrix< number > & get_matrix () const
 
size_type row () const
 
size_type index () const
 
size_type global_index () const
 
size_type column () const
 
bool is_valid_entry () const
 
bool operator== (const Accessor &) const
 
bool operator< (const Accessor &) const
 
bool operator== (const Accessor &) const
 
bool operator< (const Accessor &) const
 

Protected Member Functions

void advance ()
 

Static Protected Member Functions

static ::ExceptionBaseDummyAccessor ()
 

Protected Attributes

const SparsityPatterncontainer
 
std::size_t linear_index
 

Private Attributes

const Accessoraccessor
 

Detailed Description

template<typename number>
class SparseMatrixIterators::Accessor< number, false >::Reference

Reference class. This is what the accessor class returns when you call the value() function. The reference acts just as if it were a reference to the actual value of a matrix entry, i.e. you can read and write it, you can add and multiply to it, etc, but since the matrix does not give away the address of this matrix entry, we have to go through functions to do all this.

The constructor takes a pointer to an accessor object that describes which element of the matrix it points to. This creates an ambiguity when one writes code like iterator->value()=0 (instead of iterator->value()=0.0), since the right hand side is an integer that can both be converted to a number (i.e., most commonly a double) or to another object of type Reference. The compiler then complains about not knowing which conversion to take.

For some reason, adding another overload operator=(int) doesn't seem to cure the problem. We avoid it, however, by adding a second, dummy argument to the Reference constructor, that is unused, but makes sure there is no second matching conversion sequence using a one-argument right hand side.

The testcase oliver_01 checks that this actually works as intended.

Definition at line 216 of file sparse_matrix.h.

Member Typedef Documentation

◆ size_type

Constructor & Destructor Documentation

◆ Reference()

template<typename number>
SparseMatrixIterators::Accessor< number, false >::Reference::Reference ( const Accessor< number, false > * accessor,
const bool dummy )

Constructor. For the second argument, see the general class documentation.

Member Function Documentation

◆ operator number()

template<typename number>
SparseMatrixIterators::Accessor< number, false >::Reference::operator number ( ) const

Conversion operator to the data type of the matrix.

◆ operator=()

template<typename number>
const Reference & SparseMatrixIterators::Accessor< number, false >::Reference::operator= ( const number n) const

Set the element of the matrix we presently point to to n.

◆ operator+=()

template<typename number>
const Reference & SparseMatrixIterators::Accessor< number, false >::Reference::operator+= ( const number n) const

Add n to the element of the matrix we presently point to.

◆ operator-=()

template<typename number>
const Reference & SparseMatrixIterators::Accessor< number, false >::Reference::operator-= ( const number n) const

Subtract n from the element of the matrix we presently point to.

◆ operator*=()

template<typename number>
const Reference & SparseMatrixIterators::Accessor< number, false >::Reference::operator*= ( const number n) const

Multiply the element of the matrix we presently point to by n.

◆ operator/=()

template<typename number>
const Reference & SparseMatrixIterators::Accessor< number, false >::Reference::operator/= ( const number n) const

Divide the element of the matrix we presently point to by n.

◆ value() [1/2]

number SparseMatrixIterators::Accessor< number, Constness >::value ( ) const

Value of this matrix entry.

◆ value() [2/2]

number & SparseMatrixIterators::Accessor< number, Constness >::value ( )

Value of this matrix entry.

◆ get_matrix()

const SparseMatrix< number > & SparseMatrixIterators::Accessor< number, Constness >::get_matrix ( ) const

Return a reference to the matrix into which this accessor points. Note that in the present case, this is a constant reference.

◆ row()

size_type SparsityPatternIterators::Accessor::row ( ) const

Row number of the element represented by this object. This function can only be called for entries for which is_valid_entry() is true.

◆ index()

size_type SparsityPatternIterators::Accessor::index ( ) const

Index within the current row of the element represented by this object. This function can only be called for entries for which is_valid_entry() is true.

◆ global_index()

size_type SparsityPatternIterators::Accessor::global_index ( ) const

This function returns the how-many'th entry within the entire sparsity pattern the current iterator points to. While the order of entries in a sparsity pattern is generally not important, this function allows indexing entries of the sparsity pattern using a linear index.

This function can only be called for entries for which is_valid_entry() is true.

◆ column()

size_type SparsityPatternIterators::Accessor::column ( ) const

Column number of the element represented by this object. This function can only be called for entries for which is_valid_entry() is true.

◆ is_valid_entry()

bool SparsityPatternIterators::Accessor::is_valid_entry ( ) const

Return whether the sparsity pattern entry pointed to by this iterator is valid or not. Note that after compressing the sparsity pattern, all entries are valid. However, before compression, the sparsity pattern allocated some memory to be used while still adding new nonzero entries; if you create iterators in this phase of the sparsity pattern's lifetime, you will iterate over elements that are not valid. If this is so, then this function will return false.

◆ operator==() [1/2]

bool SparsityPatternIterators::Accessor::operator== ( const Accessor< number, false > & ) const

Comparison. True, if both iterators point to the same matrix position.

◆ operator<() [1/2]

bool SparsityPatternIterators::Accessor::operator< ( const Accessor< number, false > & ) const

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 sparsity pattern.

◆ DummyAccessor()

static ::ExceptionBase & SparsityPatternIterators::Accessor::DummyAccessor ( )
staticprotected
Note
The message that will be printed by this exception reads:
"The instance of this class was initialized" " without SparsityPattern object, which" " means that it is a dummy accessor that can" " not do any operations."

◆ advance()

void SparsityPatternIterators::Accessor::advance ( )
protected

Move the accessor to the next nonzero entry in the matrix.

◆ operator==() [2/2]

bool SparsityPatternIterators::Accessor::operator== ( const Accessor & ) const
inherited

Comparison. True, if both iterators point to the same matrix position.

◆ operator<() [2/2]

bool SparsityPatternIterators::Accessor::operator< ( const Accessor & ) const
inherited

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 sparsity pattern.

Member Data Documentation

◆ accessor

template<typename number>
const Accessor* SparseMatrixIterators::Accessor< number, false >::Reference::accessor
private

Pointer to the accessor that denotes which element we presently point to.

Definition at line 265 of file sparse_matrix.h.

◆ container

const SparsityPattern* SparsityPatternIterators::Accessor::container
protected

The sparsity pattern we operate on accessed.

Definition at line 229 of file sparsity_pattern.h.

◆ linear_index

std::size_t SparsityPatternIterators::Accessor::linear_index
protected

Index in global sparsity pattern. This index represents the location the iterator/accessor points to within the array of the SparsityPattern class that stores the column numbers. It is also the index within the values array of a sparse matrix that stores the corresponding value of this site.

Definition at line 238 of file sparsity_pattern.h.


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