46 #include "Teuchos_CommHelpers.hpp"
47 #include "Epetra_Comm.h"
48 #include "Epetra_Map.h"
49 #include "Epetra_CrsMatrix.h"
50 #include "Epetra_Vector.h"
51 #include "Trilinos_Util.h"
57 int my_proc = comm.
MyPID();
59 long long num_global_rows = 0;
62 std::ifstream* infile = NULL;
63 infile =
new std::ifstream(mm_file.c_str());
64 if (infile == NULL || !*infile) {
65 throw std::runtime_error(
"Failed to open file "+mm_file);
68 std::ifstream& in = *infile;
75 }
while(line[0] ==
'%');
79 int numrows, numcols, nnz;
80 std::istringstream isstr(line);
81 isstr >> numrows >> numcols >> nnz;
85 throw std::runtime_error(
"Failed to parse matrix-market header.");
89 num_global_rows = numrows;
90 nnz_per_row = nnz/numrows;
96 const int indexBase = 0;
97 Epetra_Map rowmap(num_global_rows, indexBase, comm);
105 int g_row=-1, last_row=-1;
110 std::istringstream isstr(line);
111 isstr >> irow >> icol >> val;
113 if (isstr.fail())
continue;
114 if (!rowmap.
MyGID(irow-1))
continue;
117 if (g_row != last_row) {
118 if (col.
size() > 0) {
129 if (col.
size() > 0) {
143 int my_proc = comm.
MyPID();
145 long long num_global_rows = 0;
147 std::ifstream* infile = NULL;
149 infile =
new std::ifstream(mm_file.c_str());
150 if (infile == NULL || !*infile) {
151 throw std::runtime_error(
"Failed to open file "+mm_file);
154 std::ifstream& in = *infile;
161 }
while(line[0] ==
'%');
165 int numrows, numcols;
166 std::istringstream isstr(line);
167 isstr >> numrows >> numcols;
171 throw std::runtime_error(
"Failed to parse matrix-market header.");
174 num_global_rows = numrows;
179 const int indexBase = 0;
180 Epetra_Map rowmap(num_global_rows, indexBase, comm);
189 std::ifstream& in = *infile;
192 std::istringstream isstr(line);
195 if (isstr.fail())
continue;
197 b->ReplaceGlobalValue(irow++, icol, val);
213 Trilinos_Util_ReadHb2Epetra64(const_cast<char*>(hb_file.c_str()), Comm, Map,
void read_matrix_hb(const std::string &hb_file, const Epetra_Comm &Comm, Epetra_CrsMatrix *&A, Epetra_Vector *&b)
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
virtual int MyPID() const =0
int FillComplete(bool OptimizeDataStorage=true)
bool MyGID(int GID_in) const
virtual int Broadcast(double *MyVals, int Count, int Root) const =0
void push_back(const value_type &x)
Epetra_Vector * read_vector_mm(const std::string &mm_file, const Epetra_Comm &comm)
Epetra_CrsMatrix * read_matrix_mm(const std::string &mm_file, const Epetra_Comm &comm)