10#ifndef __Teuchos_MatrixMarket_Raw_Graph_Adder_hpp 
   11#define __Teuchos_MatrixMarket_Raw_Graph_Adder_hpp 
   14#include "Teuchos_ArrayRCP.hpp" 
   15#include "Teuchos_CommHelpers.hpp" 
   17#include "Teuchos_MatrixMarket_Banner.hpp" 
   18#include "Teuchos_MatrixMarket_CoordDataReader.hpp" 
   53      template<
class Ordinal>
 
   64          rowIndex_ (
i), colIndex_ (
j) {}
 
 
   68          return rowIndex_ == rhs.rowIndex_ && colIndex_ == rhs.colIndex_;
 
 
   73          return ! (*
this == rhs);
 
 
   78          if (rowIndex_ < rhs.rowIndex_)
 
   80          else if (rowIndex_ > rhs.rowIndex_)
 
   83            return colIndex_ < rhs.colIndex_;
 
 
   94        Ordinal rowIndex_, colIndex_;
 
 
  101      template<
class Ordinal>
 
  105        out << 
elt.rowIndex () << 
" " << 
elt.colIndex ();
 
  128      template<
class Ordinal>
 
  131        typedef Ordinal index_type;
 
  133        typedef typename std::vector<element_type>::size_type size_type;
 
  148          expectedNumEntries_(0),
 
 
  177               const bool debug=
false) :
 
 
  215              i > expectedNumRows_ || 
j > expectedNumCols_;
 
  218              std::invalid_argument, 
"Graph is " << expectedNumRows_ << 
" x " 
  219              << expectedNumCols_ << 
", so entry A(" << 
i << 
"," << 
j 
  220              << 
") is out of range.");
 
  223                std::invalid_argument, 
"Cannot add entry A(" << 
i << 
"," << 
j 
  224                << 
")  to graph; already have expected number " 
  225                "of entries " << expectedNumEntries_ << 
".");
 
  236          seenNumRows_ = std::max (seenNumRows_, 
i);
 
  237          seenNumCols_ = std::max (seenNumCols_, 
j);
 
 
  264              (
replace, std::logic_error, 
"replace = true not implemented!");
 
  268            std::sort (elts_.begin(), elts_.end());
 
  271          typedef std::ostream_iterator<element_type> 
iter_type;
 
  272          std::copy (elts_.begin(), elts_.end(), 
iter_type (out, 
"\n"));
 
 
  288        std::pair<size_type, size_type>
 
  291          typedef typename std::vector<element_type>::iterator 
iter_type;
 
  300          std::sort (elts_.begin(), elts_.end());
 
  304          it = std::unique(elts_.begin(), elts_.end());
 
  305          size_type 
numUnique = std::distance(elts_.begin(),
it);
 
  307          elts_.resize( std::distance(elts_.begin(),
it) );
 
 
  359          const Ordinal 
nrows = tolerant_ ? seenNumRows_ : expectedNumRows_;
 
  368          typedef typename std::vector<element_type>::const_iterator 
iter_type;
 
  371            const Ordinal 
i = 
it->rowIndex ();
 
  372            const Ordinal 
j = 
it->colIndex ();
 
  375              "current graph entry's row index " << 
i << 
" is less then what " 
  376              "should be the current row index lower bound " << 
curRow << 
".");
 
  383              static_cast<size_t> (
curInd) >= elts_.size (),
 
  384              std::logic_error, 
"The current index " << 
curInd << 
" into ind " 
  385              "is >= the number of matrix entries " << elts_.size ()
 
 
  419        const Ordinal 
numRows()
 const { 
return seenNumRows_; }
 
  424        const Ordinal 
numCols()
 const { 
return seenNumCols_; }
 
  427        Ordinal expectedNumRows_, expectedNumCols_, expectedNumEntries_;
 
  428        Ordinal seenNumRows_, seenNumCols_, seenNumEntries_;
 
  433        std::vector<element_type> elts_;
 
 
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
 
Templated Parameter List class.
 
Reference-counted smart pointer for managing arrays.
 
To be used with Checker for "raw" sparse matrix input.
 
GraphAdder(const Ordinal expectedNumRows, const Ordinal expectedNumCols, const Ordinal expectedNumEntries, const bool tolerant=false, const bool debug=false)
Standard constructor.
 
void clear()
Clear all the added graph entries and reset metadata.
 
const Ordinal numCols() const
Computed number of columns.
 
const std::vector< element_type > & getEntries() const
A temporary const view of the entries of the graph.
 
std::pair< size_type, size_type > merge()
Merge duplicate elements.
 
void mergeAndConvertToCSR(size_type &numUniqueElts, size_type &numRemovedElts, Teuchos::ArrayRCP< Ordinal > &rowptr, Teuchos::ArrayRCP< Ordinal > &colind)
Merge duplicate elements and convert to zero-based CSR.
 
void operator()(const Ordinal i, const Ordinal j, const bool countAgainstTotal=true)
Add an entry to the sparse graph.
 
const Ordinal numRows() const
Computed number of rows.
 
void print(std::ostream &out, const bool doMerge, const bool replace=false)
Print the sparse graph data.
 
GraphAdder()
Default constructor.
 
Stores one entry of a sparse graph.
 
Ordinal rowIndex() const
Row index (zero-based) of this GraphElement.
 
GraphElement()
Default constructor: an invalid entry of the graph.
 
Ordinal colIndex() const
Column index (zero-based) of this GraphElement.
 
GraphElement(const Ordinal i, const Ordinal j)
Create a sparse graph entry at (i,j).
 
bool operator==(const GraphElement &rhs) const
Compare row and column indices.
 
bool operator<(const GraphElement &rhs) const
Lexicographic order first by row index, then by column index.
 
bool operator!=(const GraphElement &rhs) const
Compare row and column indices.
 
Smart reference counting pointer class for automatic garbage collection.
 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
 
Matrix Market file utilities.
 
"Raw" input of sparse matrices from Matrix Market files.
 
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
 
This structure defines some basic traits for the ordinal field type.