Teuchos - Trilinos Tools Package
Version of the Day
|
To be used with Checker for "raw" sparse matrix input. More...
#include <Teuchos_MatrixMarket_Raw_Graph_Adder.hpp>
Public Member Functions | |
GraphAdder () | |
Default constructor. More... | |
GraphAdder (const Ordinal expectedNumRows, const Ordinal expectedNumCols, const Ordinal expectedNumEntries, const bool tolerant=false, const bool debug=false) | |
Standard constructor. More... | |
void | operator() (const Ordinal i, const Ordinal j, const bool countAgainstTotal=true) |
Add an entry to the sparse graph. More... | |
void | print (std::ostream &out, const bool doMerge, const bool replace=false) |
Print the sparse graph data. More... | |
std::pair< size_type, size_type > | merge () |
Merge duplicate elements. More... | |
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. More... | |
const std::vector< element_type > & | getEntries () const |
A temporary const view of the entries of the graph. More... | |
void | clear () |
Clear all the added graph entries and reset metadata. More... | |
const Ordinal | numRows () const |
Computed number of rows. More... | |
const Ordinal | numCols () const |
Computed number of columns. More... | |
To be used with Checker for "raw" sparse matrix input.
Ordinal | The type of indices in the sparse matrix. |
This class implements the following interface, which is required by the Callback template parameter of Teuchos::MatrixMarket::CoordPatternReader:
For GraphAdder, the Ordinal template parameter is index_type. GraphAdder provides a simple implementation of the above interface which is useful for things like printing out a sparse graph's entries, or converting between storage formats.
Definition at line 161 of file Teuchos_MatrixMarket_Raw_Graph_Adder.hpp.
|
inline |
Default constructor.
If you call the default constructor, we assume that you want tolerant mode (in which the GraphAdder tries to infer the graph dimensions and number of entries from the actual graph data, not from any metadata). Tolerant mode is similar to what Matlab does if you give it an ASCII file of (i,j,Aij) triples. It may get the graph dimensions (m,n) wrong if the lower right entry of the graph is zero and is not supplied explicitly by calling operator().
Definition at line 177 of file Teuchos_MatrixMarket_Raw_Graph_Adder.hpp.
|
inline |
Standard constructor.
expectedNumRows | [in] Number of rows in the graph, as specified by the matrix metadata. |
expectedNumCols | [in] Number of columns in the graph, as specified by the matrix metadata. |
expectedNumEntries | [in] Number of entries in the graph, as specified by the matrix metadata. |
tolerant | [in] Whether the "expected" metadata is required to match what the read-in graph entries tell us. |
debug | [in] If true, we may print copious status output for debugging purposes. |
Definition at line 205 of file Teuchos_MatrixMarket_Raw_Graph_Adder.hpp.
|
inline |
Add an entry to the sparse graph.
If tolerant==false, this method will perform error checking to ensure that the graph data matches the metadata. For example, it will check that i and j are in bounds. If countAgainstTotal is true, it will also check to make sure you haven't added more than the expected number of graph entries. Regardless, this method will update the "actual" metadata.
i | [in] (1-based) row index |
j | [in] (1-based) column index |
Aij | [in] Value of the entry A(i,j) |
countAgainstTotal | [in] Whether to count the entry to insert against the total expected number of entries. The default is true. Make this false if you are inserting an entry that wasn't stored in the original Matrix Market file, which you're adding in order to preserve symmetry or some other related structural property of the matrix. |
Definition at line 241 of file Teuchos_MatrixMarket_Raw_Graph_Adder.hpp.
|
inline |
Print the sparse graph data.
We always print the data sorted. You may also merge duplicate entries if you prefer.
out | [out] Output stream to which to print |
doMerge | [in] Whether to merge entries before printing |
replace | [in] If merging, whether to replace duplicate entries; otherwise their values are added together. |
Definition at line 292 of file Teuchos_MatrixMarket_Raw_Graph_Adder.hpp.
|
inline |
Merge duplicate elements.
Merge elements of the sparse graph that have the same row and column indices ("duplicates"). Resize the array of elements to fit just the "unique" (not duplicate) elements.
Definition at line 321 of file Teuchos_MatrixMarket_Raw_Graph_Adder.hpp.
|
inline |
Merge duplicate elements and convert to zero-based CSR.
Merge elements of the sparse graph that have the same row and column indices ("duplicates"). Resize the array of elements to fit just the "unique" (not duplicate) elements. Return a CSR (compressed sparse row) version of the data, with zero-based indices.
We combine merge and conversion to CSR because the latter requires the former.
numUniqueElts | [out] Same as the first return value of merge(). |
numRemovedElts | [out] Same as the second return value of merge(). |
rowptr | [out] Array of numRows+1 offsets, where numRows is the number of rows in the sparse graph. For row i (zero-based indexing), the entries of that row are in indices rowptr[i] .. rowptr[i+1]-1 of colind and values. |
colind | [out] Column indices of the graph. Same number of entries as values. colind[k] is the column index of values[k]. |
Definition at line 376 of file Teuchos_MatrixMarket_Raw_Graph_Adder.hpp.
|
inline |
A temporary const view of the entries of the graph.
Definition at line 436 of file Teuchos_MatrixMarket_Raw_Graph_Adder.hpp.
|
inline |
Clear all the added graph entries and reset metadata.
Definition at line 441 of file Teuchos_MatrixMarket_Raw_Graph_Adder.hpp.
|
inline |
Computed number of rows.
"Computed" means "as seen from the matrix data."
Definition at line 451 of file Teuchos_MatrixMarket_Raw_Graph_Adder.hpp.
|
inline |
Computed number of columns.
"Computed" means "as seen from the matrix data."
Definition at line 456 of file Teuchos_MatrixMarket_Raw_Graph_Adder.hpp.