42#ifndef __Teuchos_MatrixMarket_Raw_Graph_Adder_hpp
43#define __Teuchos_MatrixMarket_Raw_Graph_Adder_hpp
85 template<
class Ordinal>
105 return ! (*
this ==
rhs);
133 template<
class Ordinal>
137 out <<
elt.rowIndex () <<
" " <<
elt.colIndex ();
160 template<
class Ordinal>
165 typedef typename std::vector<element_type>::size_type
size_type;
209 const bool debug=
false) :
252 <<
") is out of range.");
255 std::invalid_argument,
"Cannot add entry A(" <<
i <<
"," <<
j
256 <<
") to graph; already have expected number "
296 (
replace, std::logic_error,
"replace = true not implemented!");
303 typedef std::ostream_iterator<element_type>
iter_type;
320 std::pair<size_type, size_type>
323 typedef typename std::vector<element_type>::iterator
iter_type;
400 typedef typename std::vector<element_type>::const_iterator
iter_type;
403 const Ordinal
i =
it->rowIndex ();
404 const Ordinal
j =
it->colIndex ();
407 "current graph entry's row index " <<
i <<
" is less then what "
408 "should be the current row index lower bound " <<
curRow <<
".");
416 std::logic_error,
"The current index " <<
curInd <<
" into ind "
417 "is >= the number of matrix entries " <<
elts_.
size ()
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
Templated Parameter List class.
Reference-counted smart pointer for managing arrays.
int size(const Comm< Ordinal > &comm)
Get the number of processes in the communicator.
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.
GraphElement< Ordinal > element_type
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.
std::vector< element_type >::size_type size_type
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.
std::vector< element_type > elts_
The actual matrix entries, stored as an array of structs.
GraphAdder()
Default constructor.
Ordinal expectedNumEntries_
Stores one entry of a sparse graph.
Ordinal rowIndex() const
Row index (zero-based) of this GraphElement.
bool operator!=(const GraphElement &rhs)
Compare row and column indices.
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)
Compare row and column indices.
bool operator<(const GraphElement &rhs) const
Lexicographic order first by row index, then by column index.
Concrete serial communicator subclass.
#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.
std::ostream & operator<<(std::ostream &out, const Element< Scalar, Ordinal > &elt)
Print out an Element to the given output stream.
This structure defines some basic traits for the ordinal field type.