Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
Teuchos::MatrixMarket::Raw::Element< Scalar, Ordinal > Class Template Reference

Stores one entry of a sparse matrix. More...

#include <Teuchos_MatrixMarket_Raw_Adder.hpp>

Public Member Functions

 Element ()
 Default constructor: an invalid entry of the matrix. More...
 
 Element (const Ordinal i, const Ordinal j, const Scalar &Aij)
 Create a sparse matrix entry at (i,j) with value Aij. More...
 
bool operator== (const Element &rhs)
 Ignore the matrix value for comparisons. More...
 
bool operator!= (const Element &rhs)
 Ignore the matrix value for comparisons. More...
 
bool operator< (const Element &rhs) const
 Lexicographic order first by row index, then by column index. More...
 
template<class BinaryFunction >
void merge (const Element &rhs, const BinaryFunction &f)
 Merge rhs into this Element, using custom binary function. More...
 
void merge (const Element &rhs, const bool replace=false)
 Merge rhs into this Element, either by addition or replacement. More...
 
Ordinal rowIndex () const
 Row index (zero-based) of this Element. More...
 
Ordinal colIndex () const
 Column index (zero-based) of this Element. More...
 
Scalar value () const
 Value (A(rowIndex(), colIndex()) of this Element. More...
 

Detailed Description

template<class Scalar, class Ordinal>
class Teuchos::MatrixMarket::Raw::Element< Scalar, Ordinal >

Stores one entry of a sparse matrix.

Author
Mark Hoemmen
Template Parameters
ScalarThe type of entries of the sparse matrix.
OrdinalThe type of indices of the sparse matrix.

This class is mainly useful as an implementation detail of Adder. We expose it to users only if they wish to convert the sparse matrix read in by Adder into a storage format other than CSR (compressed sparse row).

An array of Elements implements the so-called "array of structs" representation of a coordinate format sparse matrix. An Element has a row and column index (each of type Ordinal) and a value (of type Scalar). Elements also have equality and ordering comparisons. The equality comparison only tests the row and column index, and is intended to simplify merging matrix entries with the same row and column indices. The ordering comparison means that std::sort of a sequence of Elements will put them in an order suitable for extracting the CSR (compressed sparse row) representation of the sparse matrix.

Definition at line 55 of file Teuchos_MatrixMarket_Raw_Adder.hpp.

Constructor & Destructor Documentation

template<class Scalar , class Ordinal >
Teuchos::MatrixMarket::Raw::Element< Scalar, Ordinal >::Element ( )
inline

Default constructor: an invalid entry of the matrix.

Definition at line 58 of file Teuchos_MatrixMarket_Raw_Adder.hpp.

template<class Scalar , class Ordinal >
Teuchos::MatrixMarket::Raw::Element< Scalar, Ordinal >::Element ( const Ordinal  i,
const Ordinal  j,
const Scalar &  Aij 
)
inline

Create a sparse matrix entry at (i,j) with value Aij.

Definition at line 65 of file Teuchos_MatrixMarket_Raw_Adder.hpp.

Member Function Documentation

template<class Scalar , class Ordinal >
bool Teuchos::MatrixMarket::Raw::Element< Scalar, Ordinal >::operator== ( const Element< Scalar, Ordinal > &  rhs)
inline

Ignore the matrix value for comparisons.

Definition at line 69 of file Teuchos_MatrixMarket_Raw_Adder.hpp.

template<class Scalar , class Ordinal >
bool Teuchos::MatrixMarket::Raw::Element< Scalar, Ordinal >::operator!= ( const Element< Scalar, Ordinal > &  rhs)
inline

Ignore the matrix value for comparisons.

Definition at line 74 of file Teuchos_MatrixMarket_Raw_Adder.hpp.

template<class Scalar , class Ordinal >
bool Teuchos::MatrixMarket::Raw::Element< Scalar, Ordinal >::operator< ( const Element< Scalar, Ordinal > &  rhs) const
inline

Lexicographic order first by row index, then by column index.

Definition at line 79 of file Teuchos_MatrixMarket_Raw_Adder.hpp.

template<class Scalar , class Ordinal >
template<class BinaryFunction >
void Teuchos::MatrixMarket::Raw::Element< Scalar, Ordinal >::merge ( const Element< Scalar, Ordinal > &  rhs,
const BinaryFunction &  f 
)
inline

Merge rhs into this Element, using custom binary function.

This replaces the current value Aij with f(rhs.value_, Aij). The object f must be a binary function that takes two Scalar arguments and returns a Scalar.

Definition at line 95 of file Teuchos_MatrixMarket_Raw_Adder.hpp.

template<class Scalar , class Ordinal >
void Teuchos::MatrixMarket::Raw::Element< Scalar, Ordinal >::merge ( const Element< Scalar, Ordinal > &  rhs,
const bool  replace = false 
)
inline

Merge rhs into this Element, either by addition or replacement.

Parameters
rhs[in] Element to merge in.
replace[in] If true, replace this Element's value with that of rhs. If false, add rhs to this Element's value.

Definition at line 114 of file Teuchos_MatrixMarket_Raw_Adder.hpp.

template<class Scalar , class Ordinal >
Ordinal Teuchos::MatrixMarket::Raw::Element< Scalar, Ordinal >::rowIndex ( ) const
inline

Row index (zero-based) of this Element.

Definition at line 133 of file Teuchos_MatrixMarket_Raw_Adder.hpp.

template<class Scalar , class Ordinal >
Ordinal Teuchos::MatrixMarket::Raw::Element< Scalar, Ordinal >::colIndex ( ) const
inline

Column index (zero-based) of this Element.

Definition at line 136 of file Teuchos_MatrixMarket_Raw_Adder.hpp.

template<class Scalar , class Ordinal >
Scalar Teuchos::MatrixMarket::Raw::Element< Scalar, Ordinal >::value ( ) const
inline

Value (A(rowIndex(), colIndex()) of this Element.

Definition at line 139 of file Teuchos_MatrixMarket_Raw_Adder.hpp.


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