Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
MatrixMarket_Tpetra_decl.hpp
1// @HEADER
2// *****************************************************************************
3// Tpetra: Templated Linear Algebra Services Package
4//
5// Copyright 2008 NTESS and the Tpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef __MatrixMarket_Tpetra_hpp
11#define __MatrixMarket_Tpetra_hpp
12
25#include "Tpetra_CrsMatrix.hpp"
26#include "Tpetra_Operator.hpp"
27#include "Tpetra_Vector.hpp"
29#include "Teuchos_MatrixMarket_Raw_Adder.hpp"
30#include "Teuchos_MatrixMarket_Raw_Graph_Adder.hpp"
31#include "Teuchos_MatrixMarket_SymmetrizingAdder.hpp"
32#include "Teuchos_MatrixMarket_SymmetrizingGraphAdder.hpp"
33#include "Teuchos_MatrixMarket_assignScalar.hpp"
34#include "Teuchos_MatrixMarket_Banner.hpp"
35#include "Teuchos_MatrixMarket_CoordDataReader.hpp"
36#include "Teuchos_SetScientific.hpp"
37#include "Teuchos_TimeMonitor.hpp"
38
39extern "C" {
40#include "mmio_Tpetra.h"
41}
42#include "Tpetra_Distribution.hpp"
43
44#include <algorithm>
45#include <fstream>
46#include <iostream>
47#include <iterator>
48#include <vector>
49#include <stdexcept>
50#include <numeric>
51
52namespace Tpetra {
53
109template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
111 public:
115 typedef Teuchos::RCP<sparse_matrix_type> sparse_matrix_ptr;
116
134
138 node_type>
140
142 typedef MultiVector<scalar_type,
145 node_type>
147
149 typedef Vector<scalar_type,
152 node_type>
154
156
158 using trcp_tcomm_t = Teuchos::RCP<const Teuchos::Comm<int>>;
159
160 private:
166 typedef Teuchos::ArrayRCP<int>::size_type size_type;
167
178 static Teuchos::RCP<const map_type>
179 makeRangeMap(const trcp_tcomm_t& pComm,
181
209 static Teuchos::RCP<const map_type>
210 makeRowMap(const Teuchos::RCP<const map_type>& pRowMap,
211 const trcp_tcomm_t& pComm,
213
228 static Teuchos::RCP<const map_type>
229 makeDomainMap(const Teuchos::RCP<const map_type>& pRangeMap,
231 const global_ordinal_type numCols);
232
305 static void
306 distribute(Teuchos::ArrayRCP<size_t>& myNumEntriesPerRow,
307 Teuchos::ArrayRCP<size_t>& myRowPtr,
308 Teuchos::ArrayRCP<global_ordinal_type>& myColInd,
309 Teuchos::ArrayRCP<scalar_type>& myValues,
310 const Teuchos::RCP<const map_type>& pRowMap,
311 Teuchos::ArrayRCP<size_t>& numEntriesPerRow,
312 Teuchos::ArrayRCP<size_t>& rowPtr,
313 Teuchos::ArrayRCP<global_ordinal_type>& colInd,
314 Teuchos::ArrayRCP<scalar_type>& values,
315 const bool debug = false);
316
330 static Teuchos::RCP<sparse_matrix_type>
331 makeMatrix(Teuchos::ArrayRCP<size_t>& myNumEntriesPerRow,
332 Teuchos::ArrayRCP<size_t>& myRowPtr,
333 Teuchos::ArrayRCP<global_ordinal_type>& myColInd,
334 Teuchos::ArrayRCP<scalar_type>& myValues,
335 const Teuchos::RCP<const map_type>& pRowMap,
336 const Teuchos::RCP<const map_type>& pRangeMap,
337 const Teuchos::RCP<const map_type>& pDomainMap,
338 const bool callFillComplete = true);
339
345 static Teuchos::RCP<sparse_matrix_type>
346 makeMatrix(Teuchos::ArrayRCP<size_t>& myNumEntriesPerRow,
347 Teuchos::ArrayRCP<size_t>& myRowPtr,
348 Teuchos::ArrayRCP<global_ordinal_type>& myColInd,
349 Teuchos::ArrayRCP<scalar_type>& myValues,
350 const Teuchos::RCP<const map_type>& pRowMap,
351 const Teuchos::RCP<const map_type>& pRangeMap,
352 const Teuchos::RCP<const map_type>& pDomainMap,
353 const Teuchos::RCP<Teuchos::ParameterList>& constructorParams,
354 const Teuchos::RCP<Teuchos::ParameterList>& fillCompleteParams);
355
360 static Teuchos::RCP<sparse_matrix_type>
361 makeMatrix(Teuchos::ArrayRCP<size_t>& myNumEntriesPerRow,
362 Teuchos::ArrayRCP<size_t>& myRowPtr,
363 Teuchos::ArrayRCP<global_ordinal_type>& myColInd,
364 Teuchos::ArrayRCP<scalar_type>& myValues,
365 const Teuchos::RCP<const map_type>& rowMap,
366 Teuchos::RCP<const map_type>& colMap,
367 const Teuchos::RCP<const map_type>& domainMap,
368 const Teuchos::RCP<const map_type>& rangeMap,
369 const bool callFillComplete = true);
370
371 private:
388 static Teuchos::RCP<const Teuchos::MatrixMarket::Banner>
389 readBanner(std::istream& in,
390 size_t& lineNumber,
391 const bool tolerant = false,
392 const bool /* debug */ = false,
393 const bool isGraph = false);
394
417 static Teuchos::Tuple<global_ordinal_type, 3>
418 readCoordDims(std::istream& in,
419 size_t& lineNumber,
420 const Teuchos::RCP<const Teuchos::MatrixMarket::Banner>& pBanner,
421 const trcp_tcomm_t& pComm,
422 const bool tolerant = false,
423 const bool /* debug */ = false);
424
435 typedef Teuchos::MatrixMarket::SymmetrizingAdder<Teuchos::MatrixMarket::Raw::Adder<scalar_type, global_ordinal_type>> adder_type;
436
437 typedef Teuchos::MatrixMarket::SymmetrizingGraphAdder<Teuchos::MatrixMarket::Raw::GraphAdder<global_ordinal_type>> graph_adder_type;
438
464 static Teuchos::RCP<adder_type>
465 makeAdder(const Teuchos::RCP<const Teuchos::Comm<int>>& pComm,
466 Teuchos::RCP<const Teuchos::MatrixMarket::Banner>& pBanner,
467 const Teuchos::Tuple<global_ordinal_type, 3>& dims,
468 const bool tolerant = false,
469 const bool debug = false);
470
496 static Teuchos::RCP<graph_adder_type>
497 makeGraphAdder(const Teuchos::RCP<const Teuchos::Comm<int>>& pComm,
498 Teuchos::RCP<const Teuchos::MatrixMarket::Banner>& pBanner,
499 const Teuchos::Tuple<global_ordinal_type, 3>& dims,
500 const bool tolerant = false,
501 const bool debug = false);
502
504 static Teuchos::RCP<sparse_graph_type>
505 readSparseGraphHelper(std::istream& in,
506 const Teuchos::RCP<const Teuchos::Comm<int>>& pComm,
507 const Teuchos::RCP<const map_type>& rowMap,
508 Teuchos::RCP<const map_type>& colMap,
509 const Teuchos::RCP<Teuchos::ParameterList>& constructorParams,
510 const bool tolerant,
511 const bool debug);
512
513 public:
537 static Teuchos::RCP<sparse_graph_type>
538 readSparseGraphFile(const std::string& filename,
539 const trcp_tcomm_t& comm,
540 const bool callFillComplete = true,
541 const bool tolerant = false,
542 const bool debug = false);
543
572 static Teuchos::RCP<sparse_graph_type>
573 readSparseGraphFile(const std::string& filename,
574 const Teuchos::RCP<const Teuchos::Comm<int>>& pComm,
575 const Teuchos::RCP<Teuchos::ParameterList>& constructorParams,
576 const Teuchos::RCP<Teuchos::ParameterList>& fillCompleteParams,
577 const bool tolerant = false,
578 const bool debug = false);
579
617 static Teuchos::RCP<sparse_graph_type>
618 readSparseGraphFile(const std::string& filename,
619 const Teuchos::RCP<const map_type>& rowMap,
620 Teuchos::RCP<const map_type>& colMap,
621 const Teuchos::RCP<const map_type>& domainMap,
622 const Teuchos::RCP<const map_type>& rangeMap,
623 const bool callFillComplete = true,
624 const bool tolerant = false,
625 const bool debug = false);
626
652 static Teuchos::RCP<sparse_graph_type>
653 readSparseGraph(std::istream& in,
654 const Teuchos::RCP<const Teuchos::Comm<int>>& pComm,
655 const bool callFillComplete = true,
656 const bool tolerant = false,
657 const bool debug = false);
658
688 static Teuchos::RCP<sparse_graph_type>
689 readSparseGraph(std::istream& in,
690 const Teuchos::RCP<const Teuchos::Comm<int>>& pComm,
691 const Teuchos::RCP<Teuchos::ParameterList>& constructorParams,
692 const Teuchos::RCP<Teuchos::ParameterList>& fillCompleteParams,
693 const bool tolerant = false,
694 const bool debug = false);
695
736 static Teuchos::RCP<sparse_graph_type>
737 readSparseGraph(std::istream& in,
738 const Teuchos::RCP<const map_type>& rowMap,
739 Teuchos::RCP<const map_type>& colMap,
740 const Teuchos::RCP<const map_type>& domainMap,
741 const Teuchos::RCP<const map_type>& rangeMap,
742 const bool callFillComplete = true,
743 const bool tolerant = false,
744 const bool debug = false);
745
746#include "MatrixMarket_TpetraNew.hpp"
747
771 static Teuchos::RCP<sparse_matrix_type>
772 readSparseFile(const std::string& filename,
773 const trcp_tcomm_t& comm,
774 const bool callFillComplete = true,
775 const bool tolerant = false,
776 const bool debug = false);
777
806 static Teuchos::RCP<sparse_matrix_type>
807 readSparseFile(const std::string& filename,
808 const trcp_tcomm_t& comm,
809 const Teuchos::RCP<Teuchos::ParameterList>& constructorParams,
810 const Teuchos::RCP<Teuchos::ParameterList>& fillCompleteParams,
811 const bool tolerant = false,
812 const bool debug = false);
813
851 static Teuchos::RCP<sparse_matrix_type>
852 readSparseFile(const std::string& filename,
853 const Teuchos::RCP<const map_type>& rowMap,
854 Teuchos::RCP<const map_type>& colMap,
855 const Teuchos::RCP<const map_type>& domainMap,
856 const Teuchos::RCP<const map_type>& rangeMap,
857 const bool callFillComplete = true,
858 const bool tolerant = false,
859 const bool debug = false);
860
886 static Teuchos::RCP<sparse_matrix_type>
887 readSparse(std::istream& in,
888 const Teuchos::RCP<const Teuchos::Comm<int>>& pComm,
889 const bool callFillComplete = true,
890 const bool tolerant = false,
891 const bool debug = false);
892
921 static Teuchos::RCP<sparse_matrix_type>
922 readSparse(std::istream& in,
923 const Teuchos::RCP<const Teuchos::Comm<int>>& pComm,
924 const Teuchos::RCP<Teuchos::ParameterList>& constructorParams,
925 const Teuchos::RCP<Teuchos::ParameterList>& fillCompleteParams,
926 const bool tolerant = false,
927 const bool debug = false);
928
969 static Teuchos::RCP<sparse_matrix_type>
970 readSparse(std::istream& in,
971 const Teuchos::RCP<const map_type>& rowMap,
972 Teuchos::RCP<const map_type>& colMap,
973 const Teuchos::RCP<const map_type>& domainMap,
974 const Teuchos::RCP<const map_type>& rangeMap,
975 const bool callFillComplete = true,
976 const bool tolerant = false,
977 const bool debug = false);
978
1008 static Teuchos::RCP<multivector_type>
1009 readDenseFile(const std::string& filename,
1010 const trcp_tcomm_t& comm,
1011 Teuchos::RCP<const map_type>& map,
1012 const bool tolerant = false,
1013 const bool debug = false,
1014 const bool binary = false);
1015
1026 static std::ifstream openInFileOnRankZero(
1027 const trcp_tcomm_t& comm,
1028 const std::string& filename, const bool safe = true,
1029 std::ios_base::openmode mode = std::ios_base::in);
1030
1060 static Teuchos::RCP<vector_type>
1061 readVectorFile(const std::string& filename,
1062 const trcp_tcomm_t& comm,
1063 Teuchos::RCP<const map_type>& map,
1064 const bool tolerant = false,
1065 const bool debug = false);
1066
1134
1135 static Teuchos::RCP<multivector_type>
1136 readDense(std::istream& in,
1137 const trcp_tcomm_t& comm,
1138 Teuchos::RCP<const map_type>& map,
1139 const bool tolerant = false,
1140 const bool debug = false,
1141 const bool binary = false);
1142
1144 static Teuchos::RCP<vector_type>
1145 readVector(std::istream& in,
1146 const trcp_tcomm_t& comm,
1147 Teuchos::RCP<const map_type>& map,
1148 const bool tolerant = false,
1149 const bool debug = false);
1150
1172 static Teuchos::RCP<const map_type>
1173 readMapFile(const std::string& filename,
1174 const trcp_tcomm_t& comm,
1175 const bool tolerant = false,
1176 const bool debug = false,
1177 const bool binary = false);
1178
1179 private:
1180 template <class MultiVectorScalarType>
1181 static Teuchos::RCP<Tpetra::MultiVector<MultiVectorScalarType,
1184 node_type>>
1185 readDenseImpl(std::istream& in,
1186 const trcp_tcomm_t& comm,
1187 Teuchos::RCP<const map_type>& map,
1188 const Teuchos::RCP<Teuchos::FancyOStream>& err,
1189 const bool tolerant = false,
1190 const bool debug = false,
1191 const bool binary = false);
1192
1193 template <class VectorScalarType>
1194 static Teuchos::RCP<Tpetra::Vector<VectorScalarType,
1197 node_type>>
1198 readVectorImpl(std::istream& in,
1199 const trcp_tcomm_t& comm,
1200 Teuchos::RCP<const map_type>& map,
1201 const Teuchos::RCP<Teuchos::FancyOStream>& err,
1202 const bool tolerant = false,
1203 const bool debug = false);
1204
1205 public:
1226 static Teuchos::RCP<const map_type>
1227 readMap(std::istream& in,
1228 const trcp_tcomm_t& comm,
1229 const bool tolerant = false,
1230 const bool debug = false,
1231 const bool binary = false);
1232
1259 static Teuchos::RCP<const map_type>
1260 readMap(std::istream& in,
1261 const trcp_tcomm_t& comm,
1262 const Teuchos::RCP<Teuchos::FancyOStream>& err,
1263 const bool tolerant = false,
1264 const bool debug = false,
1265 const bool binary = false);
1266
1267 private:
1278 static int
1279 encodeDataType(const std::string& dataType);
1280
1281 public:
1312 static Teuchos::RCP<sparse_matrix_type>
1313 readSparsePerRank(const std::string& filename_prefix,
1314 const std::string& filename_suffix,
1315 const Teuchos::RCP<const map_type>& rowMap,
1316 Teuchos::RCP<const map_type>& colMap,
1317 const Teuchos::RCP<const map_type>& domainMap,
1318 const Teuchos::RCP<const map_type>& rangeMap,
1319 const bool callFillComplete = true,
1320 const bool tolerant = false,
1321 const int ranksToReadAtOnce = 8,
1322 const bool debug = false); // end readSparsePerRank
1323
1324}; // class MatrixMarketReader
1325
1354template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
1356 public:
1360 typedef Teuchos::RCP<sparse_matrix_type> sparse_matrix_ptr;
1361
1374
1376 typedef MultiVector<scalar_type,
1379 node_type>
1385
1388
1390 using trcp_tcomm_t = Teuchos::RCP<const Teuchos::Comm<int>>;
1391
1423 static void
1424 writeSparseFile(const std::string& filename,
1426 const std::string& matrixName,
1427 const std::string& matrixDescription,
1428 const bool debug = false);
1429
1431 static void
1432 writeSparseFile(const std::string& filename,
1433 const Teuchos::RCP<const sparse_matrix_type>& pMatrix,
1434 const std::string& matrixName,
1435 const std::string& matrixDescription,
1436 const bool debug = false);
1437
1457 static void
1458 writeSparseFile(const std::string& filename,
1460 const bool debug = false);
1461
1463 static void
1464 writeSparseFile(const std::string& filename,
1465 const Teuchos::RCP<const sparse_matrix_type>& pMatrix,
1466 const bool debug = false);
1467
1498 static void
1499 writeSparse(std::ostream& out,
1501 const std::string& matrixName,
1502 const std::string& matrixDescription,
1503 const bool debug = false);
1504
1506 static void
1507 writeSparse(std::ostream& out,
1508 const Teuchos::RCP<const sparse_matrix_type>& pMatrix,
1509 const std::string& matrixName,
1510 const std::string& matrixDescription,
1511 const bool debug = false);
1512
1543 static void
1544 writeSparseGraph(std::ostream& out,
1545 const crs_graph_type& graph,
1546 const std::string& graphName,
1547 const std::string& graphDescription,
1548 const bool debug = false);
1549
1555 static void
1556 writeSparseGraph(std::ostream& out,
1557 const crs_graph_type& graph,
1558 const bool debug = false);
1559
1594 static void
1595 writeSparseGraphFile(const std::string& filename,
1596 const crs_graph_type& graph,
1597 const std::string& graphName,
1598 const std::string& graphDescription,
1599 const bool debug = false);
1600
1605 static void
1606 writeSparseGraphFile(const std::string& filename,
1607 const crs_graph_type& graph,
1608 const bool debug = false);
1609
1618 static void
1619 writeSparseGraphFile(const std::string& filename,
1620 const Teuchos::RCP<const crs_graph_type>& pGraph,
1621 const std::string& graphName,
1622 const std::string& graphDescription,
1623 const bool debug = false);
1624
1634 static void
1635 writeSparseGraphFile(const std::string& filename,
1636 const Teuchos::RCP<const crs_graph_type>& pGraph,
1637 const bool debug = false);
1638
1661 static void
1662 writeSparse(std::ostream& out,
1664 const bool debug = false);
1665
1667 static void
1668 writeSparse(std::ostream& out,
1669 const Teuchos::RCP<const sparse_matrix_type>& pMatrix,
1670 const bool debug = false);
1671
1700 static void
1701 writeDenseFile(const std::string& filename,
1702 const multivector_type& X,
1703 const std::string& matrixName,
1704 const std::string& matrixDescription,
1705 const Teuchos::RCP<Teuchos::FancyOStream>& err = Teuchos::null,
1706 const Teuchos::RCP<Teuchos::FancyOStream>& dbg = Teuchos::null);
1707
1713 static void
1714 writeDenseFile(const std::string& filename,
1715 const Teuchos::RCP<const multivector_type>& X,
1716 const std::string& matrixName,
1717 const std::string& matrixDescription,
1718 const Teuchos::RCP<Teuchos::FancyOStream>& err = Teuchos::null,
1719 const Teuchos::RCP<Teuchos::FancyOStream>& dbg = Teuchos::null);
1720
1726 static void
1727 writeDenseFile(const std::string& filename,
1728 const multivector_type& X,
1729 const Teuchos::RCP<Teuchos::FancyOStream>& err = Teuchos::null,
1730 const Teuchos::RCP<Teuchos::FancyOStream>& dbg = Teuchos::null);
1731
1737 static void
1738 writeDenseFile(const std::string& filename,
1739 const Teuchos::RCP<const multivector_type>& X,
1740 const Teuchos::RCP<Teuchos::FancyOStream>& err = Teuchos::null,
1741 const Teuchos::RCP<Teuchos::FancyOStream>& dbg = Teuchos::null);
1742
1773 static void
1774 writeDense(std::ostream& out,
1775 const multivector_type& X,
1776 const std::string& matrixName,
1777 const std::string& matrixDescription,
1778 const Teuchos::RCP<Teuchos::FancyOStream>& err = Teuchos::null,
1779 const Teuchos::RCP<Teuchos::FancyOStream>& dbg = Teuchos::null);
1780
1781 private:
1787 static std::ofstream openOutFileOnRankZero(
1788 const trcp_tcomm_t& comm,
1789 const std::string& filename, const int rank, const bool safe = true,
1790 const std::ios_base::openmode mode = std::ios_base::out);
1791
1817 static void
1818 writeDenseHeader(std::ostream& out,
1819 const multivector_type& X,
1820 const std::string& matrixName,
1821 const std::string& matrixDescription,
1822 const Teuchos::RCP<Teuchos::FancyOStream>& err = Teuchos::null,
1823 const Teuchos::RCP<Teuchos::FancyOStream>& dbg = Teuchos::null);
1824
1842 static void
1843 writeDenseColumn(std::ostream& out,
1844 const multivector_type& X,
1845 const Teuchos::RCP<Teuchos::FancyOStream>& err = Teuchos::null,
1846 const Teuchos::RCP<Teuchos::FancyOStream>& dbg = Teuchos::null);
1847
1848 public:
1854 static void
1855 writeDense(std::ostream& out,
1856 const Teuchos::RCP<const multivector_type>& X,
1857 const std::string& matrixName,
1858 const std::string& matrixDescription,
1859 const Teuchos::RCP<Teuchos::FancyOStream>& err = Teuchos::null,
1860 const Teuchos::RCP<Teuchos::FancyOStream>& dbg = Teuchos::null);
1861
1867 static void
1868 writeDense(std::ostream& out,
1869 const multivector_type& X,
1870 const Teuchos::RCP<Teuchos::FancyOStream>& err = Teuchos::null,
1871 const Teuchos::RCP<Teuchos::FancyOStream>& dbg = Teuchos::null);
1872
1878 static void
1879 writeDense(std::ostream& out,
1880 const Teuchos::RCP<const multivector_type>& X,
1881 const Teuchos::RCP<Teuchos::FancyOStream>& err = Teuchos::null,
1882 const Teuchos::RCP<Teuchos::FancyOStream>& dbg = Teuchos::null);
1883
1903 static void
1904 writeMap(std::ostream& out, const map_type& map, const bool debug = false);
1905
1914 static void
1915 writeMap(std::ostream& out,
1916 const map_type& map,
1917 const Teuchos::RCP<Teuchos::FancyOStream>& err,
1918 const bool debug = false);
1919
1921 static void
1922 writeMapFile(const std::string& filename,
1923 const map_type& map);
1924
1925 private:
1949 static void
1950 printAsComment(std::ostream& out, const std::string& str);
1951
1952 public:
1971 static void
1972 writeOperator(const std::string& fileName, operator_type const& A);
1973
1994 static void
1995 writeOperator(std::ostream& out, const operator_type& A);
1996
2033 static void
2034 writeOperator(const std::string& fileName,
2035 const operator_type& A,
2036 const Teuchos::ParameterList& params);
2037
2076 static void
2077 writeOperator(std::ostream& out,
2078 const operator_type& A,
2079 const Teuchos::ParameterList& params);
2080
2081 private:
2089 static std::string
2090 writeOperatorImpl(std::ostream& os,
2091 const operator_type& A,
2092 const Teuchos::ParameterList& params);
2093
2094 static global_ordinal_type
2095 writeColumns(std::ostream& os, mv_type const& colsA, size_t const& numCols,
2096 Teuchos::ArrayView<const global_ordinal_type> const& rowGids,
2097 Teuchos::Array<global_ordinal_type> const& colsArray,
2099
2100 public:
2107
2108 static void
2109 writeSparsePerRank(const std::string& filename_prefix,
2110 const std::string& filename_suffix,
2112 const std::string& matrixName,
2113 const std::string& matrixDescription,
2114 const int ranksToWriteAtOnce = 8,
2115 const bool debug = false); // end writeSparsePerRank
2116
2118 template <typename T>
2119 static trcp_tcomm_t getComm(const Teuchos::RCP<T>& obj);
2120
2122 static int getRank(const trcp_tcomm_t& comm);
2123
2124}; // class MatrixMarketWriter
2125
2155namespace MatrixMarket {
2156
2157template <class SparseMatrixType>
2158using Reader = MatrixMarketReader<typename SparseMatrixType::scalar_type,
2159 typename SparseMatrixType::local_ordinal_type,
2160 typename SparseMatrixType::global_ordinal_type,
2161 typename SparseMatrixType::node_type>;
2162
2163template <class SparseMatrixType>
2164using Writer = MatrixMarketWriter<typename SparseMatrixType::scalar_type,
2165 typename SparseMatrixType::local_ordinal_type,
2166 typename SparseMatrixType::global_ordinal_type,
2167 typename SparseMatrixType::node_type>;
2168
2169} // namespace MatrixMarket
2170} // namespace Tpetra
2171
2172#endif // __MatrixMarket_Tpetra_hpp
From a distributed map build a map with all GIDs on the root node.
Declaration of a function that prints strings from each process.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
Sparse matrix that presents a row-oriented interface that lets users read or modify entries.
Node node_type
This class' Kokkos Node type.
GlobalOrdinal global_ordinal_type
The type of each global index in the matrix.
Scalar scalar_type
The type of each entry in the matrix.
Struct that holds views of the contents of a CrsMatrix.
A parallel distribution of indices over processes.
Matrix Market file reader for CrsMatrix and MultiVector.
SparseMatrixType::local_ordinal_type local_ordinal_type
static Teuchos::RCP< sparse_matrix_type > readSparsePerRank(const std::string &filename_prefix, const std::string &filename_suffix, const Teuchos::RCP< const map_type > &rowMap, Teuchos::RCP< const map_type > &colMap, const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const bool callFillComplete=true, const bool tolerant=false, const int ranksToReadAtOnce=8, const bool debug=false)
Read a Tpetra::CrsMatrix from a file per rank setup.
static Teuchos::RCP< sparse_matrix_type > readSparseFile(const std::string &filename, const trcp_tcomm_t &comm, const bool callFillComplete=true, const bool tolerant=false, const bool debug=false)
Read sparse matrix from the given Matrix Market file.
Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > SparseMatrixType
This class' template parameter; a specialization of CrsMatrix.
SparseMatrixType::scalar_type scalar_type
static Teuchos::RCP< multivector_type > readDense(std::istream &in, const trcp_tcomm_t &comm, Teuchos::RCP< const map_type > &map, const bool tolerant=false, const bool debug=false, const bool binary=false)
Read dense matrix (as a MultiVector) from the given Matrix Market input stream.
static Teuchos::RCP< multivector_type > readDenseFile(const std::string &filename, const trcp_tcomm_t &comm, Teuchos::RCP< const map_type > &map, const bool tolerant=false, const bool debug=false, const bool binary=false)
Read dense matrix (as a MultiVector) from the given Matrix Market file.
static std::ifstream openInFileOnRankZero(const trcp_tcomm_t &comm, const std::string &filename, const bool safe=true, std::ios_base::openmode mode=std::ios_base::in)
Open an input file stream safely on rank zero.
static Teuchos::RCP< sparse_graph_type > readSparseGraphFile(const std::string &filename, const trcp_tcomm_t &comm, const bool callFillComplete=true, const bool tolerant=false, const bool debug=false)
Read sparse graph from the given Matrix Market file.
static Teuchos::RCP< sparse_matrix_type > readSparse(std::istream &in, const Teuchos::RCP< const Teuchos::Comm< int > > &pComm, const bool callFillComplete=true, const bool tolerant=false, const bool debug=false)
Read sparse matrix from the given Matrix Market input stream.
static Teuchos::RCP< const map_type > readMapFile(const std::string &filename, const trcp_tcomm_t &comm, const bool tolerant=false, const bool debug=false, const bool binary=false)
Read Map (as a MultiVector) from the given Matrix Market file.
static Teuchos::RCP< vector_type > readVector(std::istream &in, const trcp_tcomm_t &comm, Teuchos::RCP< const map_type > &map, const bool tolerant=false, const bool debug=false)
Read Vector from the given Matrix Market input stream.
Teuchos::RCP< const Teuchos::Comm< int > > trcp_tcomm_t
Type of the MPI communicator.
static Teuchos::RCP< sparse_graph_type > readSparseGraph(std::istream &in, const Teuchos::RCP< const Teuchos::Comm< int > > &pComm, const bool callFillComplete=true, const bool tolerant=false, const bool debug=false)
Read sparse graph from the given Matrix Market input stream.
static Teuchos::RCP< const map_type > readMap(std::istream &in, const trcp_tcomm_t &comm, const bool tolerant=false, const bool debug=false, const bool binary=false)
Read Map (as a MultiVector) from the given input stream.
SparseMatrixType::node_type node_type
The fourth template parameter of CrsMatrix and MultiVector.
CrsGraph< local_ordinal_type, global_ordinal_type, node_type > sparse_graph_type
The CrsGraph specialization associated with SparseMatrixType.
static Teuchos::RCP< vector_type > readVectorFile(const std::string &filename, const trcp_tcomm_t &comm, Teuchos::RCP< const map_type > &map, const bool tolerant=false, const bool debug=false)
Read a Vector from the given Matrix Market file.
MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > multivector_type
The MultiVector specialization associated with SparseMatrixType.
Vector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > vector_type
The Vector specialization associated with SparseMatrixType.
static Teuchos::RCP< const map_type > readMap(std::istream &in, const trcp_tcomm_t &comm, const Teuchos::RCP< Teuchos::FancyOStream > &err, const bool tolerant=false, const bool debug=false, const bool binary=false)
Read Map (as a MultiVector) from the given input stream, with optional debugging output stream.
SparseMatrixType::global_ordinal_type global_ordinal_type
Matrix Market file writer for CrsMatrix and MultiVector.
Teuchos::RCP< const Teuchos::Comm< int > > trcp_tcomm_t
Type of the MPI communicator.
static trcp_tcomm_t getComm(const Teuchos::RCP< T > &obj)
Return obj MPI communicator or Teuchos::null.
static void writeDenseFile(const std::string &filename, const Teuchos::RCP< const multivector_type > &X, const std::string &matrixName, const std::string &matrixDescription, const Teuchos::RCP< Teuchos::FancyOStream > &err=Teuchos::null, const Teuchos::RCP< Teuchos::FancyOStream > &dbg=Teuchos::null)
Print the multivector in Matrix Market format, with matrix name and description.
static void writeSparsePerRank(const std::string &filename_prefix, const std::string &filename_suffix, const sparse_matrix_type &matrix, const std::string &matrixName, const std::string &matrixDescription, const int ranksToWriteAtOnce=8, const bool debug=false)
Write a Tpetra::CrsMatrix to a file per rank.
Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > SparseMatrixType
Template parameter of this class; specialization of CrsMatrix.
static void writeSparseGraph(std::ostream &out, const crs_graph_type &graph, const std::string &graphName, const std::string &graphDescription, const bool debug=false)
Print the sparse graph in Matrix Market format to the given output stream.
static void writeOperator(const std::string &fileName, const operator_type &A, const Teuchos::ParameterList &params)
Write a Tpetra::Operator to a file, with options.
static void writeOperator(const std::string &fileName, operator_type const &A)
Write a Tpetra::Operator to a file.
Map< local_ordinal_type, global_ordinal_type, node_type > map_type
Specialization of Tpetra::Map that matches SparseMatrixType.
static void writeSparseGraphFile(const std::string &filename, const crs_graph_type &graph, const std::string &graphName, const std::string &graphDescription, const bool debug=false)
Print the sparse graph in Matrix Market format to the given file (by filename).
static void writeDenseFile(const std::string &filename, const multivector_type &X, const Teuchos::RCP< Teuchos::FancyOStream > &err=Teuchos::null, const Teuchos::RCP< Teuchos::FancyOStream > &dbg=Teuchos::null)
Print the multivector in Matrix Market format, with no matrix name or description.
MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > multivector_type
Specialization of Tpetra::MultiVector that matches SparseMatrixType.
static void writeSparseFile(const std::string &filename, const sparse_matrix_type &matrix, const std::string &matrixName, const std::string &matrixDescription, const bool debug=false)
Print the sparse matrix in Matrix Market format, with comments.
SparseMatrixType::node_type node_type
The Kokkos Node type; fourth template parameter of Tpetra::CrsMatrix.
static int getRank(const trcp_tcomm_t &comm)
Return MPI rank or 0.
static void writeMap(std::ostream &out, const map_type &map, const bool debug=false)
Print the Map to the given output stream.
SparseMatrixType::global_ordinal_type global_ordinal_type
Type of indices as read from the Matrix Market file.
static void writeDense(std::ostream &out, const multivector_type &X, const std::string &matrixName, const std::string &matrixDescription, const Teuchos::RCP< Teuchos::FancyOStream > &err=Teuchos::null, const Teuchos::RCP< Teuchos::FancyOStream > &dbg=Teuchos::null)
Print the multivector in Matrix Market format, with matrix name and description.
static void writeOperator(std::ostream &out, const operator_type &A)
Write a Tpetra::Operator to an output stream.
static void writeDense(std::ostream &out, const Teuchos::RCP< const multivector_type > &X, const Teuchos::RCP< Teuchos::FancyOStream > &err=Teuchos::null, const Teuchos::RCP< Teuchos::FancyOStream > &dbg=Teuchos::null)
Print the multivector in Matrix Market format, with no matrix name or description.
static void writeOperator(std::ostream &out, const operator_type &A, const Teuchos::ParameterList &params)
Write a Tpetra::Operator to an output stream, with options.
static void writeMap(std::ostream &out, const map_type &map, const Teuchos::RCP< Teuchos::FancyOStream > &err, const bool debug=false)
Print the Map to the given output stream out.
static void writeDense(std::ostream &out, const Teuchos::RCP< const multivector_type > &X, const std::string &matrixName, const std::string &matrixDescription, const Teuchos::RCP< Teuchos::FancyOStream > &err=Teuchos::null, const Teuchos::RCP< Teuchos::FancyOStream > &dbg=Teuchos::null)
Print the multivector in Matrix Market format, with matrix name and or description.
static void writeMapFile(const std::string &filename, const map_type &map)
Write the Map to the given file.
static void writeDenseFile(const std::string &filename, const Teuchos::RCP< const multivector_type > &X, const Teuchos::RCP< Teuchos::FancyOStream > &err=Teuchos::null, const Teuchos::RCP< Teuchos::FancyOStream > &dbg=Teuchos::null)
Print the multivector in Matrix Market format, with no matrix name or description.
SparseMatrixType::local_ordinal_type local_ordinal_type
Type of the local indices of the sparse matrix.
static void writeDense(std::ostream &out, const multivector_type &X, const Teuchos::RCP< Teuchos::FancyOStream > &err=Teuchos::null, const Teuchos::RCP< Teuchos::FancyOStream > &dbg=Teuchos::null)
Print the multivector in Matrix Market format, with no matrix name or description.
static void writeDenseFile(const std::string &filename, const multivector_type &X, const std::string &matrixName, const std::string &matrixDescription, const Teuchos::RCP< Teuchos::FancyOStream > &err=Teuchos::null, const Teuchos::RCP< Teuchos::FancyOStream > &dbg=Teuchos::null)
Print the multivector in Matrix Market format, with matrix name and description.
CrsGraph< local_ordinal_type, global_ordinal_type, node_type > crs_graph_type
Specialization of Tpetra::CrsGraph that matches SparseMatrixType.
SparseMatrixType::scalar_type scalar_type
Type of the entries of the sparse matrix.
static void writeSparse(std::ostream &out, const sparse_matrix_type &matrix, const std::string &matrixName, const std::string &matrixDescription, const bool debug=false)
Print the sparse matrix in Matrix Market format, with comments.
One or more distributed dense vectors.
Abstract interface for operators (e.g., matrices and preconditioners).
A distributed dense vector.
Matrix Market file readers and writers for sparse and dense matrices (as CrsMatrix resp....
Namespace Tpetra contains the class and methods constituting the Tpetra library.