14#ifdef HAVE_XPETRA_EPETRA
16#include "Epetra_MpiComm.h"
20#if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT)
21#include <EpetraExt_MatrixMatrix.h>
22#include <EpetraExt_RowMatrixOut.h>
23#include <EpetraExt_MultiVectorOut.h>
24#include <EpetraExt_CrsMatrixIn.h>
25#include <EpetraExt_MultiVectorIn.h>
26#include <EpetraExt_BlockMapIn.h>
29#include <EpetraExt_BlockMapOut.h>
32#ifdef HAVE_XPETRA_TPETRA
33#include <MatrixMarket_Tpetra.hpp>
34#include <Tpetra_RowMatrixTransposer.hpp>
35#include <TpetraExt_MatrixMatrix.hpp>
36#include <Xpetra_TpetraMultiVector.hpp>
37#include <Xpetra_TpetraCrsGraph.hpp>
38#include <Xpetra_TpetraCrsMatrix.hpp>
39#include <Xpetra_TpetraBlockCrsMatrix.hpp>
40#include "Tpetra_Util.hpp"
43#ifdef HAVE_XPETRA_EPETRA
47#include "Xpetra_Matrix.hpp"
48#include "Xpetra_MatrixMatrix.hpp"
50#include "Xpetra_CrsMatrixWrap.hpp"
51#include "Xpetra_BlockedCrsMatrix.hpp"
53#include "Xpetra_Map.hpp"
54#include "Xpetra_StridedMap.hpp"
55#include "Xpetra_StridedMapFactory.hpp"
56#include "Xpetra_MapExtractor.hpp"
57#include "Xpetra_MatrixFactory.hpp"
59#include <Teuchos_MatrixMarket_Raw_Writer.hpp>
60#include <Teuchos_MatrixMarket_Raw_Reader.hpp>
65#ifdef HAVE_XPETRA_EPETRA
66template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
69 if (xeMap == Teuchos::null)
70 throw Exceptions::BadCast(
"Utils::Map2EpetraMap : Cast from Xpetra::Map to Xpetra::EpetraMap failed");
71 return xeMap->getEpetra_Map();
75#ifdef HAVE_XPETRA_TPETRA
76template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
79 if (tmp_TMap == Teuchos::null)
80 throw Exceptions::BadCast(
"Utils::Map2TpetraMap : Cast from Xpetra::Map to Xpetra::TpetraMap failed");
81 return tmp_TMap->getTpetra_Map();
85template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
88#if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT)
90 if (tmp_EMap != Teuchos::null) {
91 int rv = EpetraExt::BlockMapToMatrixMarketFile(fileName.c_str(), tmp_EMap->getEpetra_Map());
98#ifdef HAVE_XPETRA_TPETRA
100 Teuchos::rcp_dynamic_cast<const Xpetra::TpetraMap<LocalOrdinal, GlobalOrdinal, Node>>(tmp_Map);
101 if (tmp_TMap != Teuchos::null) {
103 Tpetra::MatrixMarket::Writer<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>::writeMapFile(fileName, *TMap);
111template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
113 std::string mapfile =
"map_" + fileName;
114 Write(mapfile, *(vec.
getMap()));
117#if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT)
119 if (tmp_EVec != Teuchos::null) {
120 int rv = EpetraExt::MultiVectorToMatrixMarketFile(fileName.c_str(), *(tmp_EVec->getEpetra_MultiVector()));
127#ifdef HAVE_XPETRA_TPETRA
129 Teuchos::rcp_dynamic_cast<const Xpetra::TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(tmp_Vec);
130 if (tmp_TVec != Teuchos::null) {
132 Tpetra::MatrixMarket::Writer<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>::writeDenseFile(fileName, TVec);
137 throw Exceptions::BadCast(
"Could not cast to EpetraMultiVector or TpetraMultiVector in multivector writing");
140template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
142 std::string mapfile =
"map_" + fileName;
143 Write(mapfile, *(vec.
getMap()));
146#ifdef HAVE_XPETRA_TPETRA
148 Teuchos::rcp_dynamic_cast<const Xpetra::TpetraMultiVector<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node>>(tmp_Vec);
149 if (tmp_TVec != Teuchos::null) {
151 Tpetra::MatrixMarket::Writer<Tpetra::CrsMatrix<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node>>::writeDenseFile(fileName, TVec);
156 throw Exceptions::RuntimeError(
"Xpetra cannot write MV<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node> when the underlying library is Epetra.");
159 throw Exceptions::BadCast(
"Could not cast to EpetraMultiVector or TpetraMultiVector in multivector writing");
162template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
164 std::string mapfile =
"map_" + fileName;
165 Write(mapfile, *(vec.
getMap()));
168#ifdef HAVE_XPETRA_TPETRA
170 Teuchos::rcp_dynamic_cast<const Xpetra::TpetraMultiVector<GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node>>(tmp_Vec);
171 if (tmp_TVec != Teuchos::null) {
173 Tpetra::MatrixMarket::Writer<Tpetra::CrsMatrix<GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node>>::writeDenseFile(fileName, TVec);
178 throw Exceptions::RuntimeError(
"Xpetra cannot write MV<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node> when the underlying library is Epetra.");
181 throw Exceptions::BadCast(
"Could not cast to EpetraMultiVector or TpetraMultiVector in multivector writing");
184template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
186 Write(
"rowmap_" + fileName, *(Op.
getRowMap()));
192 Write(
"colmap_" + fileName, *(Op.
getColMap()));
197#if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT)
199 if (tmp_ECrsMtx != Teuchos::null) {
201 int rv = EpetraExt::RowMatrixToMatrixMarketFile(fileName.c_str(), *A);
208#ifdef HAVE_XPETRA_TPETRA
210 Teuchos::rcp_dynamic_cast<const Xpetra::TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(tmp_CrsMtx);
211 if (tmp_TCrsMtx != Teuchos::null) {
213 Tpetra::MatrixMarket::Writer<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>::writeSparseFile(fileName, A);
217 Teuchos::rcp_dynamic_cast<const Xpetra::TpetraBlockCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(tmp_CrsMtx);
218 if (tmp_BlockCrs != Teuchos::null) {
219 std::ofstream outstream(fileName, std::ofstream::out);
227 throw Exceptions::BadCast(
"Could not cast to EpetraCrsMatrix or TpetraCrsMatrix in matrix writing");
230template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
240 tmp_CrsMtx->getAllValues(rowptr_RCP, colind_RCP, vals_RCP);
248 for (LocalOrdinal j = 0; j < rowptr.
size(); j++)
249 rowptr2[j] = rowptr[j];
252 writer.
writeFile(fileName +
"." + std::to_string(Op.
getRowMap()->getComm()->getSize()) +
"." + std::to_string(Op.
getRowMap()->getComm()->getRank()),
253 rowptr2, colind, vals,
257template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
260 for (
size_t row = 0; row < Op.
Rows(); ++row) {
261 for (
size_t col = 0; col < Op.
Cols(); ++col) {
263 if (m != Teuchos::null) {
265 "Sub block matrix (" << row <<
"," << col <<
") is not of type CrsMatrixWrap.");
275 for (
size_t row = 0; row < rangeMapExtractor->NumMaps(); ++row) {
277 Write(
"subRangeMap_" + fileName +
toString(row) +
".m", *map);
279 Write(
"fullRangeMap_" + fileName +
".m", *(rangeMapExtractor->getFullMap()));
281 for (
size_t col = 0; col < domainMapExtractor->NumMaps(); ++col) {
283 Write(
"subDomainMap_" + fileName +
toString(col) +
".m", *map);
285 Write(
"fullDomainMap_" + fileName +
".m", *(domainMapExtractor->getFullMap()));
288template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
290 if (binary ==
false) {
293#if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT)
296 int rv = EpetraExt::MatrixMarketFileToCrsMatrix(fileName.c_str(), *epcomm, eA);
303 Convert_Epetra_CrsMatrix_ToXpetra_CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node>(tmpA);
309#ifdef HAVE_XPETRA_TPETRA
310 typedef Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> sparse_matrix_type;
312 typedef Tpetra::MatrixMarket::Reader<sparse_matrix_type> reader_type;
314 bool callFillComplete =
true;
334 std::ifstream ifs(fileName.c_str(), std::ios::binary);
337 ifs.read(
reinterpret_cast<char*
>(&m),
sizeof(m));
338 ifs.read(
reinterpret_cast<char*
>(&n),
sizeof(n));
339 ifs.read(
reinterpret_cast<char*
>(&nnz),
sizeof(nnz));
341 int myRank = comm->getRank();
343 GlobalOrdinal indexBase = 0;
353 for (
int i = 0; i < m; i++) {
355 ifs.read(
reinterpret_cast<char*
>(&row),
sizeof(row));
356 ifs.read(
reinterpret_cast<char*
>(&rownnz),
sizeof(rownnz));
357 numEntriesPerRow[row] = rownnz;
358 for (
int j = 0; j < rownnz; j++) {
360 ifs.read(
reinterpret_cast<char*
>(&index),
sizeof(index));
362 for (
int j = 0; j < rownnz; j++) {
364 ifs.read(
reinterpret_cast<char*
>(&value),
sizeof(value));
371 ifs.seekg(0, ifs.beg);
373 ifs.read(
reinterpret_cast<char*
>(&junk),
sizeof(junk));
374 ifs.read(
reinterpret_cast<char*
>(&junk),
sizeof(junk));
375 ifs.read(
reinterpret_cast<char*
>(&junk),
sizeof(junk));
376 for (
int i = 0; i < m; i++) {
378 ifs.read(
reinterpret_cast<char*
>(&row),
sizeof(row));
379 ifs.read(
reinterpret_cast<char*
>(&rownnz),
sizeof(rownnz));
382 for (
int j = 0; j < rownnz; j++) {
384 ifs.read(
reinterpret_cast<char*
>(&index),
sizeof(index));
385 inds[j] = Teuchos::as<GlobalOrdinal>(index);
387 for (
int j = 0; j < rownnz; j++) {
389 ifs.read(
reinterpret_cast<char*
>(&value),
sizeof(value));
390 vals[j] = Teuchos::as<Scalar>(value);
392 A->insertGlobalValues(row, inds, vals);
400 A->fillComplete(domainMap, rangeMap);
408template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
415 const bool callFillComplete,
425 if (binary ==
false) {
427#if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT)
434 if (colMap.is_null()) {
435 rv = EpetraExt::MatrixMarketFileToCrsMatrix(filename.c_str(), epetraRowMap, epetraRangeMap, epetraDomainMap, eA);
438 const Epetra_Map& epetraColMap = Map2EpetraMap(*colMap);
439 rv = EpetraExt::MatrixMarketFileToCrsMatrix(filename.c_str(), epetraRowMap, epetraColMap, epetraRangeMap, epetraDomainMap, eA);
447 Convert_Epetra_CrsMatrix_ToXpetra_CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node>(tmpA);
454#ifdef HAVE_XPETRA_TPETRA
455 typedef Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> sparse_matrix_type;
456 typedef Tpetra::MatrixMarket::Reader<sparse_matrix_type> reader_type;
457 typedef Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
460 RCP<const map_type> tpetraColMap = (colMap.is_null() ? Teuchos::null : Map2TpetraMap(*colMap));
461 const RCP<const map_type> tpetraRangeMap = (rangeMap.is_null() ? tpetraRowMap : Map2TpetraMap(*rangeMap));
462 const RCP<const map_type> tpetraDomainMap = (domainMap.is_null() ? tpetraRowMap : Map2TpetraMap(*domainMap));
464 RCP<sparse_matrix_type> tA = reader_type::readSparseFile(filename, tpetraRowMap, tpetraColMap, tpetraDomainMap, tpetraRangeMap,
465 callFillComplete, tolerant, debug);
482 auto tempA = Read(filename, lib, rowMap->getComm(), binary);
487 if (callFillComplete)
488 A->fillComplete(domainMap, rangeMap);
496template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
502 const bool callFillComplete,
516 std::string rankFilename = filename +
"." + std::to_string(rowMap->getComm()->getSize()) +
"." + std::to_string(rowMap->getComm()->getRank());
519 if (binary ==
false) {
521 params->set(
"Parse tolerantly", tolerant);
522 params->set(
"Debug mode", debug);
524 LocalOrdinal numRows = rowMap->getLocalNumElements();
525 LocalOrdinal numCols = colMap->getLocalNumElements();
532 reader.
readFile(rowptr2_RCP, colind2_RCP, vals2_RCP,
536 RCP<crs_type> ACrs = Teuchos::rcp_dynamic_cast<crs_wrap_type>(A)->getCrsMatrix();
541 ACrs->allocateAllValues(colind2_RCP.
size(), rowptr_RCP, colind_RCP, vals_RCP);
544 colind_RCP = colind2_RCP;
545 vals_RCP = vals2_RCP;
547 ACrs->setAllValues(rowptr_RCP, colind_RCP, vals_RCP);
550 std::ifstream ifs = std::ifstream(rankFilename.c_str(), std::ios::binary);
554 ifs.read(
reinterpret_cast<char*
>(&m),
sizeof(m));
555 ifs.read(
reinterpret_cast<char*
>(&n),
sizeof(n));
556 ifs.read(
reinterpret_cast<char*
>(&nnz),
sizeof(nnz));
564 RCP<crs_type> ACrs = Teuchos::rcp_dynamic_cast<crs_wrap_type>(A)->getCrsMatrix();
566 ACrs->allocateAllValues(nnz, rowptrRCP, indicesRCP, valuesRCP);
575 for (
int i = 0; i < m; i++) {
577 ifs.read(
reinterpret_cast<char*
>(&row),
sizeof(row));
578 ifs.read(
reinterpret_cast<char*
>(&rownnz),
sizeof(rownnz));
580 rowptr[row + 1] += rownnz;
581 ifs.seekg(
sizeof(
int) * rownnz +
sizeof(
double) * rownnz, ifs.cur);
583 for (
int i = 0; i < m; i++)
584 rowptr[i + 1] += rowptr[i];
588 ifs.seekg(
sizeof(
int) * 3, ifs.beg);
591 for (
int i = 0; i < m; i++) {
593 ifs.read(
reinterpret_cast<char*
>(&row),
sizeof(row));
594 ifs.read(
reinterpret_cast<char*
>(&rownnz),
sizeof(rownnz));
595 size_t ptr = rowptr[row];
596 for (
int j = 0; j < rownnz; j++) {
598 ifs.read(
reinterpret_cast<char*
>(&index),
sizeof(index));
599 indices[ptr] = Teuchos::as<LocalOrdinal>(index);
601 sorted = sorted & (indices[ptr - 1] < indices[ptr]);
605 for (
int j = 0; j < rownnz; j++) {
607 ifs.read(
reinterpret_cast<char*
>(&value),
sizeof(value));
608 values[ptr] = Teuchos::as<Scalar>(value);
611 rowptr[row] += rownnz;
613 for (
int i = m; i > 0; i--)
614 rowptr[i] = rowptr[i - 1];
617#ifdef HAVE_XPETRA_TPETRA
619 for (LocalOrdinal lclRow = 0; lclRow < m; lclRow++) {
620 size_t rowBegin = rowptr[lclRow];
621 size_t rowEnd = rowptr[lclRow + 1];
622 Tpetra::sort2(&indices[rowBegin], &indices[rowEnd], &values[rowBegin]);
629 ACrs->setAllValues(rowptrRCP, indicesRCP, valuesRCP);
632 if (callFillComplete)
633 A->fillComplete(domainMap, rangeMap);
637template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
647#ifdef HAVE_XPETRA_TPETRA
648 typedef Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> sparse_matrix_type;
649 typedef Tpetra::MatrixMarket::Reader<sparse_matrix_type> reader_type;
650 typedef Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
651 typedef Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> multivector_type;
654 RCP<multivector_type> TMV = reader_type::readDenseFile(fileName, map->getComm(), temp,
false,
false, binary);
667template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
674#ifdef HAVE_XPETRA_TPETRA
675 typedef Tpetra::CrsMatrix<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node> sparse_matrix_type;
676 typedef Tpetra::MatrixMarket::Reader<sparse_matrix_type> reader_type;
677 typedef Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
678 typedef Tpetra::MultiVector<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node> multivector_type;
681 RCP<multivector_type> TMV = reader_type::readDenseFile(fileName, map->getComm(), temp,
false,
false, binary);
694template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
702#ifdef HAVE_XPETRA_TPETRA
703 typedef Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> sparse_matrix_type;
704 typedef Tpetra::MatrixMarket::Reader<sparse_matrix_type> reader_type;
721template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
723 size_t numBlocks = 2;
725 std::vector<RCP<const Map>> rangeMapVec;
726 for (
size_t row = 0; row < numBlocks; ++row) {
728 rangeMapVec.push_back(map);
730 RCP<const Map> fullRangeMap = ReadMap(
"fullRangeMap_" + fileName +
".m", lib, comm);
732 std::vector<RCP<const Map>> domainMapVec;
733 for (
size_t col = 0; col < numBlocks; ++col) {
735 domainMapVec.push_back(map);
737 RCP<const Map> fullDomainMap = ReadMap(
"fullDomainMap_" + fileName +
".m", lib, comm);
753 bool bRangeUseThyraStyleNumbering =
false;
764 bool bDomainUseThyraStyleNumbering =
false;
777 for (
size_t row = 0; row < numBlocks; ++row) {
778 for (
size_t col = 0; col < numBlocks; ++col) {
784 bOp->setMatrix(row, col, mat);
793template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
796 std::ostringstream buf;
void resize(const size_type n, const T &val=T())
void assign(size_type n, const T &val)
void resize(size_type new_size, const value_type &x=value_type())
bool readFile(ArrayRCP< Ordinal > &rowptr, ArrayRCP< Ordinal > &colind, ArrayRCP< Scalar > &values, Ordinal &numRows, Ordinal &numCols, const std::string &filename)
void writeFile(const std::string &filename, const ArrayView< const OrdinalType > &rowptr, const ArrayView< const OrdinalType > &colind, const ArrayView< const ScalarType > &values, const OrdinalType numRows, const OrdinalType numCols)
virtual size_t Cols() const
number of column blocks
Teuchos::RCP< Matrix > getMatrix(size_t r, size_t c) const
return block (r,c)
virtual size_t Rows() const
number of row blocks
RCP< const MapExtractor > getRangeMapExtractor() const
Returns map extractor class for range map.
RCP< const MapExtractor > getDomainMapExtractor() const
Returns map extractor for domain map.
Concrete implementation of Xpetra::Matrix.
RCP< CrsMatrix > getCrsMatrix() const
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const =0
The Map describing the parallel distribution of this object.
Exception indicating invalid cast attempted.
Exception throws to report errors in the internal logical of the program.
static void Write(const std::string &fileName, const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const bool &writeAllMaps=false)
Save matrix to file in Matrix Market format.
static Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Read(const std::string &fileName, Xpetra::UnderlyingLib lib, const RCP< const Teuchos::Comm< int > > &comm, bool binary=false)
Read matrix from file in Matrix Market or binary format.
static RCP< const Map > ReadMap(const std::string &fileName, Xpetra::UnderlyingLib lib, const RCP< const Teuchos::Comm< int > > &comm, const bool binary=false)
static RCP< MultiVector > ReadMultiVector(const std::string &fileName, const RCP< const Map > &map, const bool binary=false)
Read a MultiVector from file in Matrix Matrix or binary format.
static const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > Map2TpetraMap(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map)
Helper utility to pull out the underlying Tpetra objects from an Xpetra object.
static void Write(const std::string &fileName, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &M)
Read/Write methods.
static RCP< const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > ReadBlockedCrsMatrix(const std::string &fileName, Xpetra::UnderlyingLib lib, const RCP< const Teuchos::Comm< int > > &comm)
Read block matrix from one file per block in Matrix Market format.
static Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > ReadLocal(const std::string &filename, const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > rowMap, RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > colMap, const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > domainMap=Teuchos::null, const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > rangeMap=Teuchos::null, const bool callFillComplete=true, const bool binary=false, const bool tolerant=false, const bool debug=false)
Read matrix from local files in Matrix Market or binary format.
static void WriteBlockedCrsMatrix(const std::string &fileName, const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const bool &writeAllMaps=false)
Save block matrix to one file per block in Matrix Market format.
static void WriteGOMV(const std::string &fileName, const Xpetra::MultiVector< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &vec)
Save multivector with Scalar=GlobalOrdinal to file in Matrix Market format.
static const Epetra_Map & Map2EpetraMap(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map)
Helper utility to pull out the underlying Epetra objects from an Xpetra object.
static void WriteLocal(const std::string &fileName, const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op)
Save local parts of matrix to files in Matrix Market format.
static RCP< Xpetra::MultiVector< LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node > > ReadMultiVectorLO(const std::string &fileName, const RCP< const Map > &map, const bool binary=false)
Read a MultiVector with Scalar=LocalOrdinal from file in Matrix Matrix or binary format.
static void WriteLOMV(const std::string &fileName, const Xpetra::MultiVector< LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &vec)
Save multivector with Scalar=LocalOrdinal to file in Matrix Market format.
static std::string toString(const T &what)
Little helper function to convert non-string types to strings.
static RCP< Import< LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &source, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying the number of non-zeros for all rows.
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=Xpetra::GloballyDistributed)
Map constructor with Xpetra-defined contiguous uniform distribution.
static RCP< Matrix > Build(const RCP< const Map > &rowMap)
Xpetra-specific matrix class.
virtual const RCP< const Map > & getRowMap() const
Returns the Map that describes the row distribution in this matrix.
virtual const RCP< const Map > & getColMap() const
Returns the Map that describes the column distribution in this matrix. This might be null until fillC...
virtual const Teuchos::RCP< const map_type > getDomainMap() const =0
The Map associated with the domain of this operator, which must be compatible with X....
virtual const Teuchos::RCP< const map_type > getRangeMap() const =0
The Map associated with the range of this operator, which must be compatible with Y....
#define TEUCHOS_ASSERT(assertion_test)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
std::string toString(const T &t)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)
std::string toString(Xpetra::UnderlyingLib lib)
Convert a Xpetra::UnderlyingLib to a std::string.