10#ifndef TPETRA_DETAILS_READTRIPLES_HPP
11#define TPETRA_DETAILS_READTRIPLES_HPP
22#include "TpetraCore_config.h"
23#include "Tpetra_Details_PackTriples.hpp"
24#include "KokkosKernels_ArithTraits.hpp"
25#include "Teuchos_MatrixMarket_generic.hpp"
26#include "Teuchos_CommHelpers.hpp"
78template <
class OrdinalType,
class RealType>
80 OrdinalType& rowIndex,
81 OrdinalType& colIndex,
84 const std::size_t lineNumber,
85 const bool tolerant) {
86 using ::Teuchos::MatrixMarket::readRealData;
88 RealType the_realPart, the_imagPart;
89 if (!readRealData(istr, rowIndex, colIndex, the_realPart, lineNumber, tolerant)) {
93 std::ostringstream os;
94 os <<
"Failed to read pattern data and/or real value from line "
95 << lineNumber <<
" of input";
96 throw std::invalid_argument(os.str());
103 std::ostringstream os;
104 os <<
"No more data after real value on line "
105 << lineNumber <<
" of input";
106 throw std::invalid_argument(os.str());
109 istr >> the_imagPart;
114 std::ostringstream os;
115 os <<
"Failed to get imaginary value from line "
116 << lineNumber <<
" of input";
117 throw std::invalid_argument(os.str());
120 realPart = the_realPart;
121 imagPart = the_imagPart;
136 const bool isComplex = ::KokkosKernels::ArithTraits<SC>::is_complex>
159 readLine(std::function<
int(
const GO,
const GO,
const SC&)> processTriple,
160 const std::string& line,
161 const std::size_t lineNumber,
162 const bool tolerant =
false,
163 std::ostream* errStrm = NULL,
164 const bool debug =
false);
174template <
class SC,
class GO>
197 readLine(std::function<
int(
const GO,
const GO,
const SC&)> processTriple,
198 const std::string& line,
199 const std::size_t lineNumber,
200 const bool tolerant =
false,
201 std::ostream* errStrm = NULL,
202 const bool debug =
false) {
203 using ::Teuchos::MatrixMarket::checkCommentLine;
204 typedef typename ::KokkosKernels::ArithTraits<SC>::mag_type real_type;
208 real_type realPart, imagPart;
209 std::istringstream istr(line);
216 lineNumber, tolerant);
217 }
catch (std::exception& e) {
219 if (errStrm != NULL) {
220 std::ostringstream os;
221 os <<
"readLine: readComplexData threw an exception: " << e.what()
223 *errStrm << os.str();
237 processTriple(rowInd, colInd, SC(realPart, imagPart));
238 if (errCode != 0 && errStrm != NULL) {
239 std::ostringstream os;
240 os <<
"readLine: processTriple returned " << errCode <<
" != 0."
242 *errStrm << os.str();
258template <
class SC,
class GO>
281 readLine(std::function<
int(
const GO,
const GO,
const SC&)> processTriple,
282 const std::string& line,
283 const std::size_t lineNumber,
284 const bool tolerant =
false,
285 std::ostream* errStrm = NULL,
286 const bool debug =
false) {
288 using ::Teuchos::MatrixMarket::checkCommentLine;
289 using ::Teuchos::MatrixMarket::readRealData;
293 std::istringstream istr(line);
296 success = readRealData(istr, rowInd, colInd, val,
297 lineNumber, tolerant);
298 }
catch (std::exception& e) {
300 if (errStrm != NULL) {
301 std::ostringstream os;
302 os <<
"readLine: readRealData threw an exception: " << e.what()
304 *errStrm << os.str();
309 if (debug && errStrm != NULL) {
310 std::ostringstream os;
311 os <<
"readLine: Got entry: row=" << rowInd <<
", col=" << colInd
312 <<
", val=" << val << std::endl;
313 *errStrm << os.str();
316 const int errCode = processTriple(rowInd, colInd, val);
317 if (errCode != 0 && errStrm != NULL) {
318 std::ostringstream os;
319 os <<
"readLine: processTriple returned " << errCode <<
" != 0."
321 *errStrm << os.str();
355template <
class SC,
class GO>
356int readLine(std::function<
int(
const GO,
const GO,
const SC&)> processTriple,
357 const std::string& line,
358 const std::size_t lineNumber,
359 const bool tolerant =
false,
360 std::ostream* errStrm = NULL,
361 const bool debug =
false) {
363 tolerant, errStrm, debug);
396template <
class SC,
class GO>
398 std::size_t& curLineNum,
399 std::size_t& numTriplesRead,
400 std::function<
int(
const GO,
const GO,
const SC&)> processTriple,
401 const std::size_t maxNumTriplesToRead,
402 const bool tolerant =
false,
403 std::ostream* errStrm = NULL,
404 const bool debug =
false) {
407 using Teuchos::MatrixMarket::checkCommentLine;
410 if (inputStream.eof()) {
412 }
else if (inputStream.fail()) {
413 if (errStrm != NULL) {
414 *errStrm <<
"Input stream reports a failure (not the same as "
422 std::vector<size_t> badLineNumbers;
425 bool inputStreamCanStillBeRead = std::getline(inputStream, line).good();
427 while (inputStreamCanStillBeRead && numTriplesRead < maxNumTriplesToRead) {
435 const bool isCommentLine =
436 checkCommentLine(line, start, size, curLineNum, tolerant);
439 inputStreamCanStillBeRead = std::getline(inputStream, line).good();
443 const std::string theLine = line.substr(start, size);
446 const int curErrCode =
447 readLine(processTriple, theLine, curLineNum, tolerant, errStrm, debug);
448 if (curErrCode != 0) {
449 errCode = curErrCode;
450 badLineNumbers.push_back(curLineNum);
454 if (numTriplesRead < maxNumTriplesToRead) {
455 inputStreamCanStillBeRead = std::getline(inputStream, line).good();
460 if (errCode != 0 && errStrm != NULL) {
461 const size_t numBadLines = badLineNumbers.size();
462 *errStrm <<
"Encountered " << numBadLines <<
" bad line"
463 << (numBadLines != size_t(1) ?
"s" :
"")
465 for (
size_t k = 0; k < numBadLines; ++k) {
466 *errStrm << badLineNumbers[k];
467 if (k + 1 < numBadLines) {
471 *errStrm <<
"]" << endl;
473 if (!inputStream.eof() && inputStream.fail()) {
477 if (errStrm != NULL) {
478 *errStrm <<
"The input stream is not at end-of-file, "
479 "but is in a bad state."
512template <
class SC,
class GO>
514 std::size_t& curLineNum,
515 std::size_t& numEntRead,
516 ::Teuchos::ArrayRCP<int>& sizeBuf,
517 ::Teuchos::ArrayRCP<char>& msgBuf,
518 std::vector<GO>& rowInds,
519 std::vector<GO>& colInds,
520 std::vector<SC>& vals,
521 const std::size_t maxNumEntPerMsg,
523 const ::Teuchos::Comm<int>& comm,
524 const bool tolerant =
false,
525 std::ostream* errStrm = NULL,
526 const bool debug =
false) {
528 using ::Teuchos::isend;
534 using ::KokkosKernels::ArithTraits;
537 constexpr int sizeTag = 42;
538 constexpr int msgTag = 43;
548 auto processTriple = [&rowInds, &colInds, &vals](
const GO rowInd,
const GO colInd,
const SC& val) {
550 rowInds.push_back(rowInd);
551 colInds.push_back(colInd);
560 processTriple, maxNumEntPerMsg, tolerant,
562 if (debug && errStrm != NULL) {
563 std::ostringstream os;
564 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
565 <<
", GO=" <<
typeid(GO).name() <<
": "
566 <<
"readAndSendOneBatchOfTriples: readTriples read "
567 << numEntRead <<
" matrix entries, and returned errCode="
568 << errCode <<
"." << std::endl;
569 *errStrm << os.str();
571 if (numEntRead != rowInds.size() ||
572 numEntRead != colInds.size() ||
573 numEntRead != vals.size()) {
574 if (errStrm != NULL) {
575 *errStrm <<
"readTriples size results are not consistent. "
576 <<
"numEntRead = " << numEntRead
577 <<
", rowInds.size() = " << rowInds.size()
578 <<
", colInds.size() = " << colInds.size()
579 <<
", and vals.size() = " << vals.size() <<
"."
593 if (numEntRead == 0 || errCode != 0) {
599 if (debug && errStrm != NULL) {
600 std::ostringstream os;
601 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
602 <<
", GO=" <<
typeid(GO).name() <<
": "
603 <<
"Post send (size=0, errCode=" << errCode <<
") "
604 <<
"to " << destRank <<
" with tag " << sizeTag << endl;
605 *errStrm << os.str();
607 send(sizeBuf.getRawPtr(), 1, destRank, sizeTag, comm);
610 const int numEnt =
static_cast<int>(numEntRead);
617 if (countSize <= 0 && errCode == 0) {
624 if (debug && errStrm != NULL) {
625 std::ostringstream os;
626 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
627 <<
", GO=" <<
typeid(GO).name() <<
": "
628 <<
"Post send (size=0, error case) to " << destRank
629 <<
" with tag " << sizeTag << endl;
630 *errStrm << os.str();
632 send(sizeBuf.getRawPtr(), 1, destRank, sizeTag, comm);
640 if (debug && errStrm != NULL) {
641 std::ostringstream os;
642 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
643 <<
", GO=" <<
typeid(GO).name() <<
": "
644 <<
"Post send (size=0, error case) to " << destRank
645 <<
" with tag " << sizeTag << endl;
646 *errStrm << os.str();
648 send(sizeBuf.getRawPtr(), 1, destRank, sizeTag, comm);
653 const int outBufSize = countSize + triplesSize;
654 sizeBuf[0] = outBufSize;
655 if (debug && errStrm != NULL) {
656 std::ostringstream os;
657 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
658 <<
", GO=" <<
typeid(GO).name() <<
": "
659 <<
"Post isend (size=" << sizeBuf[0] <<
") to " << destRank
660 <<
" with tag " << sizeTag << endl;
661 *errStrm << os.str();
663 auto sizeReq = isend<int, int>(sizeBuf, destRank, sizeTag, comm);
665 msgBuf.resize(outBufSize);
666 char* outBuf = msgBuf.getRawPtr();
670 int outBufCurPos = 0;
672 outBufCurPos, comm, errStrm);
675 vals.data(), numEnt, outBuf,
676 outBufSize, outBufCurPos, comm,
679 if (debug && errStrm != NULL) {
680 std::ostringstream os;
681 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
682 <<
", GO=" <<
typeid(GO).name() <<
": "
683 <<
"Post isend (packed data) to " << destRank
684 <<
" with tag " << msgTag << endl;
685 *errStrm << os.str();
687 auto msgReq = isend<int, char>(msgBuf, destRank, msgTag, comm);
693 if (debug && errStrm != NULL) {
694 std::ostringstream os;
695 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
696 <<
", GO=" <<
typeid(GO).name() <<
": "
697 <<
"Wait on isend (size)" << endl;
698 *errStrm << os.str();
701 if (debug && errStrm != NULL) {
702 std::ostringstream os;
703 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
704 <<
", GO=" <<
typeid(GO).name() <<
": "
705 <<
"Wait on isend (packed data)" << endl;
706 *errStrm << os.str();
756template <
class SC,
class GO,
class CommRequestPtr>
758 std::vector<GO>& colInds,
759 std::vector<SC>& vals,
761 ::Teuchos::ArrayRCP<int>& sizeBuf,
762 ::Teuchos::ArrayRCP<char>& msgBuf,
763 CommRequestPtr& sizeReq,
765 const ::Teuchos::Comm<int>& comm,
766 const bool tolerant =
false,
767 std::ostream* errStrm = NULL,
768 const bool debug =
false) {
769 using ::KokkosKernels::ArithTraits;
776 constexpr int msgTag = 43;
781 if (debug && errStrm != NULL) {
782 std::ostringstream os;
783 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
784 <<
", GO=" <<
typeid(GO).name() <<
": "
785 <<
"Wait on irecv (size)" << std::endl;
786 *errStrm << os.str();
789 sizeReq = CommRequestPtr(NULL);
790 const int inBufSize = sizeBuf[0];
791 if (debug && errStrm != NULL) {
792 std::ostringstream os;
793 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
794 <<
", GO=" <<
typeid(GO).name() <<
": "
795 <<
"Received size: sizeBuf[0]=" << sizeBuf[0] << std::endl;
796 *errStrm << os.str();
799 if (inBufSize == 0) {
805 msgBuf.resize(inBufSize);
806 char* inBuf = msgBuf.getRawPtr();
808 if (debug && errStrm != NULL) {
809 std::ostringstream os;
810 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
811 <<
", GO=" <<
typeid(GO).name() <<
": "
812 <<
"Post irecv (packed data) "
813 <<
"from " << srcRank
814 <<
" with tag " << msgTag << std::endl;
815 *errStrm << os.str();
817 auto msgReq = ::Teuchos::ireceive(msgBuf, srcRank, msgTag, comm);
818 if (debug && errStrm != NULL) {
819 std::ostringstream os;
820 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
821 <<
", GO=" <<
typeid(GO).name() <<
": "
822 <<
"Wait on irecv (packed data)" << std::endl;
823 *errStrm << os.str();
829 numEnt, comm, errStrm);
831 rowInds.resize(numEnt);
832 colInds.resize(numEnt);
835 rowInds.data(), colInds.data(),
836 vals.data(), numEnt, comm, errStrm);
883template <
class SC,
class GO>
885 std::size_t& curLineNum,
886 std::size_t& totalNumEntRead,
887 std::function<
int(
const GO,
const GO,
const SC&)> processTriple,
888 const std::size_t maxNumEntPerMsg,
889 const ::Teuchos::Comm<int>& comm,
890 const bool tolerant =
false,
891 std::ostream* errStrm = NULL,
892 const bool debug =
false) {
893 using KokkosKernels::ArithTraits;
897 constexpr int srcRank = 0;
900 constexpr int sizeTag = 42;
902 const int myRank = comm.getRank();
903 const int numProcs = comm.getSize();
906 ::Teuchos::ArrayRCP<int> sizeBuf(1);
907 ::Teuchos::ArrayRCP<char> msgBuf;
911 std::vector<GO> rowInds;
912 std::vector<GO> colInds;
913 std::vector<SC> vals;
914 rowInds.reserve(maxNumEntPerMsg);
915 colInds.reserve(maxNumEntPerMsg);
916 vals.reserve(maxNumEntPerMsg);
919 if (myRank == srcRank) {
923 bool lastMessageWasLegitZero =
false;
925 !inputStream.eof() && errCode == 0;
926 destRank = (destRank + 1) % numProcs) {
927 size_t curNumEntRead = 0;
928 if (destRank == srcRank) {
932 const int readErrCode =
934 processTriple, maxNumEntPerMsg, tolerant,
936 if (debug && errStrm != NULL) {
937 std::ostringstream os;
938 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
939 <<
", GO=" <<
typeid(GO).name() <<
": "
940 <<
"(dest=src) readTriples returned curNumEntRead="
941 << curNumEntRead <<
", errCode=" << readErrCode << endl;
942 *errStrm << os.str();
944 errCode = (readErrCode != 0) ? readErrCode : errCode;
946 if (
false && debug && errStrm != NULL) {
947 std::ostringstream os;
948 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
949 <<
", GO=" <<
typeid(GO).name() <<
": "
950 <<
"Calling readAndSend... with destRank=" << destRank << endl;
951 *errStrm << os.str();
954 const int readAndSendErrCode =
958 rowInds, colInds, vals,
959 maxNumEntPerMsg, destRank,
960 comm, tolerant, errStrm,
962 totalNumEntRead += curNumEntRead;
963 if (debug && errStrm != NULL) {
964 std::ostringstream os;
965 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
966 <<
", GO=" <<
typeid(GO).name() <<
": "
967 <<
"readAndSend... with destRank=" << destRank
968 <<
" returned curNumEntRead=" << curNumEntRead
969 <<
", errCode=" << readAndSendErrCode << endl;
970 *errStrm << os.str();
972 errCode = (readAndSendErrCode != 0) ? readAndSendErrCode : errCode;
973 if (readAndSendErrCode == 0 && curNumEntRead == 0) {
974 lastMessageWasLegitZero =
true;
975 if (debug && errStrm != NULL) {
976 std::ostringstream os;
977 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
978 <<
", GO=" <<
typeid(GO).name() <<
": "
979 <<
"Last send to " << destRank <<
" with tag " << sizeTag
980 <<
" was legit zero, counts as termination" << endl;
981 *errStrm << os.str();
993 destRank = (destRank - 1) % numProcs;
995 destRank = destRank + numProcs;
998 const int startRank = lastMessageWasLegitZero ? (destRank + 1) : destRank;
999 for (
int outRank = startRank; outRank < numProcs; ++outRank) {
1000 if (outRank != srcRank) {
1001 if (debug && errStrm != NULL) {
1002 std::ostringstream os;
1003 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
1004 <<
", GO=" <<
typeid(GO).name() <<
": "
1005 <<
"Post send (size, termination msg) to " << outRank
1006 <<
" with tag " << sizeTag <<
"(was last message legit zero? "
1007 << (lastMessageWasLegitZero ?
"true" :
"false") <<
")" << endl;
1008 *errStrm << os.str();
1011 ::Teuchos::send(sizeBuf.getRawPtr(), 1, outRank, sizeTag, comm);
1019 if (debug && errStrm != NULL) {
1020 std::ostringstream os;
1021 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
1022 <<
", GO=" <<
typeid(GO).name() <<
": "
1023 <<
"Post irecv (size) from " << srcRank
1024 <<
" with tag " << sizeTag << std::endl;
1025 *errStrm << os.str();
1027 auto sizeReq = ::Teuchos::ireceive(sizeBuf, srcRank, sizeTag, comm);
1030 const int recvErrCode =
1032 msgBuf, sizeReq, srcRank, comm, tolerant,
1034 if (debug && errStrm != NULL) {
1035 std::ostringstream os;
1036 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
1037 <<
", GO=" <<
typeid(GO).name() <<
": "
1038 <<
"recvOneBatchOfTriples returned numEnt=" << numEnt
1039 <<
", errCode=" << recvErrCode << endl;
1040 *errStrm << os.str();
1042 errCode = (recvErrCode != 0) ? recvErrCode : errCode;
1044 if (numEnt !=
static_cast<int>(rowInds.size()) ||
1045 numEnt !=
static_cast<int>(colInds.size()) ||
1046 numEnt !=
static_cast<int>(vals.size())) {
1047 errCode = (errCode == 0) ? -1 : errCode;
1048 if (errStrm != NULL) {
1049 *errStrm <<
"recvOneBatchOfTriples produced inconsistent data sizes. "
1050 <<
"numEnt = " << numEnt
1051 <<
", rowInds.size() = " << rowInds.size()
1052 <<
", colInds.size() = " << colInds.size()
1053 <<
", vals.size() = " << vals.size() <<
"."
1064 for (
int k = 0; k < numEnt && errCode == 0; ++k) {
1065 const int curErrCode = processTriple(rowInds[k], colInds[k], vals[k]);
1066 errCode = (curErrCode == 0) ? errCode : curErrCode;
1071 if (debug && errStrm != NULL) {
1072 std::ostringstream os;
1073 os <<
"Proc " << comm.getRank() <<
", SC=" <<
typeid(SC).name()
1074 <<
", GO=" <<
typeid(GO).name() <<
": "
1075 <<
"Done with send/recv loop" << endl;
1076 *errStrm << os.str();
1080 using ::Teuchos::outArg;
1081 using ::Teuchos::REDUCE_BOR;
1082 using ::Teuchos::reduceAll;
1083 const int lclErrCode = errCode;
1084 reduceAll<int, int>(comm, REDUCE_BOR, lclErrCode, outArg(errCode));
bool readComplexData(std::istream &istr, OrdinalType &rowIndex, OrdinalType &colIndex, RealType &realPart, RealType &imagPart, const std::size_t lineNumber, const bool tolerant)
Read "<rowIndex> <colIndex> <realPart> <imagPart>" from a line.
int readTriples(std::istream &inputStream, std::size_t &curLineNum, std::size_t &numTriplesRead, std::function< int(const GO, const GO, const SC &)> processTriple, const std::size_t maxNumTriplesToRead, const bool tolerant=false, std::ostream *errStrm=NULL, const bool debug=false)
Read at most numTriplesToRead triples from the given Matrix Market input stream, and pass along any r...
int recvOneBatchOfTriples(std::vector< GO > &rowInds, std::vector< GO > &colInds, std::vector< SC > &vals, int &numEnt, ::Teuchos::ArrayRCP< int > &sizeBuf, ::Teuchos::ArrayRCP< char > &msgBuf, CommRequestPtr &sizeReq, const int srcRank, const ::Teuchos::Comm< int > &comm, const bool tolerant=false, std::ostream *errStrm=NULL, const bool debug=false)
Read at most maxNumEntPerMsg sparse matrix entries from the input stream, and send them to the proces...
int readAndSendOneBatchOfTriples(std::istream &inputStream, std::size_t &curLineNum, std::size_t &numEntRead, ::Teuchos::ArrayRCP< int > &sizeBuf, ::Teuchos::ArrayRCP< char > &msgBuf, std::vector< GO > &rowInds, std::vector< GO > &colInds, std::vector< SC > &vals, const std::size_t maxNumEntPerMsg, const int destRank, const ::Teuchos::Comm< int > &comm, const bool tolerant=false, std::ostream *errStrm=NULL, const bool debug=false)
Read at most maxNumEntPerMsg sparse matrix entries from the input stream, and send them to the proces...
int readLine(std::function< int(const GO, const GO, const SC &)> processTriple, const std::string &line, const std::size_t lineNumber, const bool tolerant=false, std::ostream *errStrm=NULL, const bool debug=false)
Take a line from the Matrix Market file or input stream, and process the sparse matrix entry in that ...
Nonmember function that computes a residual Computes R = B - A * X.
int packTriplesCount(const int, char[], const int, int &, const ::Teuchos::Comm< int > &, std::ostream *errStrm)
Pack the count (number) of matrix triples.
int countPackTriplesCount(const ::Teuchos::Comm< int > &, int &size, std::ostream *errStrm)
Compute the buffer size required by packTriples for packing the number of matrix entries ("triples").
int packTriples(const OrdinalType[], const OrdinalType[], const ScalarType[], const int, char[], const int, int &, const ::Teuchos::Comm< int > &, std::ostream *errStrm=NULL)
Pack matrix entries ("triples" (i, j, A(i,j))) into the given output buffer.
int unpackTriplesCount(const char[], const int, int &, int &, const ::Teuchos::Comm< int > &, std::ostream *errStrm)
Unpack just the count of triples from the given input buffer.
int unpackTriples(const char[], const int, int &, OrdinalType[], OrdinalType[], ScalarType[], const int, const ::Teuchos::Comm< int > &, std::ostream *errStrm=NULL)
Unpack matrix entries ("triples" (i, j, A(i,j))) from the given input buffer.
int readAndDealOutTriples(std::istream &inputStream, std::size_t &curLineNum, std::size_t &totalNumEntRead, std::function< int(const GO, const GO, const SC &)> processTriple, const std::size_t maxNumEntPerMsg, const ::Teuchos::Comm< int > &comm, const bool tolerant=false, std::ostream *errStrm=NULL, const bool debug=false)
On Process 0 in the given communicator, read sparse matrix entries (in chunks of at most maxNumEntPer...
int countPackTriples(const int numEnt, const ::Teuchos::Comm< int > &comm, int &size, std::ostream *errStrm=NULL)
Compute the buffer size required by packTriples for packing numEnt number of (i,j,...
Namespace Tpetra contains the class and methods constituting the Tpetra library.
static int readLine(std::function< int(const GO, const GO, const SC &)> processTriple, const std::string &line, const std::size_t lineNumber, const bool tolerant=false, std::ostream *errStrm=NULL, const bool debug=false)
Take a line from the Matrix Market file or input stream, and process the sparse matrix entry in that ...
static int readLine(std::function< int(const GO, const GO, const SC &)> processTriple, const std::string &line, const std::size_t lineNumber, const bool tolerant=false, std::ostream *errStrm=NULL, const bool debug=false)
Take a line from the Matrix Market file or input stream, and process the sparse matrix entry in that ...
Implementation of the readLine stand-alone function in this namespace (see below).
static int readLine(std::function< int(const GO, const GO, const SC &)> processTriple, const std::string &line, const std::size_t lineNumber, const bool tolerant=false, std::ostream *errStrm=NULL, const bool debug=false)
Take a line from the Matrix Market file or input stream, and process the sparse matrix entry in that ...