57 int my_proc = comm.MyPID();
59 int 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);
72 getline(*infile, line);
73 }
while(line[0] ==
'%');
77 int numrows, numcols, nnz;
78 std::istringstream isstr(line);
79 isstr >> numrows >> numcols >> nnz;
83 throw std::runtime_error(
"Failed to parse matrix-market header.");
87 num_global_rows = numrows;
88 nnz_per_row = nnz/numrows;
91 comm.Broadcast(&num_global_rows, 1, 0);
92 comm.Broadcast(&nnz_per_row, 1, 0);
94 const int indexBase = 0;
95 Epetra_Map rowmap(num_global_rows, indexBase, comm);
99 Teuchos::Array<int> col;
100 Teuchos::Array<double> coef;
103 int g_row=-1, last_row=-1;
106 while(!infile->eof()) {
107 getline(*infile, line);
108 std::istringstream isstr(line);
109 isstr >> irow >> icol >> val;
111 if (isstr.fail())
continue;
112 if (!rowmap.MyGID(irow-1))
continue;
115 if (g_row != last_row) {
116 if (col.size() > 0) {
123 col.push_back(icol-1);
127 if (col.size() > 0) {
140 int my_proc = comm.MyPID();
142 int num_global_rows = 0;
144 std::ifstream* infile = NULL;
146 infile =
new std::ifstream(mm_file.c_str());
147 if (infile == NULL || !*infile) {
148 throw std::runtime_error(
"Failed to open file "+mm_file);
155 getline(*infile, line);
156 }
while(line[0] ==
'%');
160 int numrows, numcols;
161 std::istringstream isstr(line);
162 isstr >> numrows >> numcols;
166 throw std::runtime_error(
"Failed to parse matrix-market header.");
169 num_global_rows = numrows;
172 comm.Broadcast(&num_global_rows, 1, 0);
174 const int indexBase = 0;
175 Epetra_Map rowmap(num_global_rows, indexBase, comm);
184 std::ifstream& in = *infile;
185 while(!infile->eof()) {
187 std::istringstream isstr(line);
190 if (isstr.fail())
continue;