rheolef  6.5
mm_io.cc
Go to the documentation of this file.
1 
2 # include "rheolef/diststream.h"
3 # include <sstream>
4 
5 using namespace std;
6 namespace rheolef {
7 
8 void
10 {
11  if (!ips.do_load()) return; // when my_proc is not the io_proc
12  istream& is = ips.is();
13  bool already_have_a_spec_line = false;
14  do {
15  char c;
16  is >> std::ws >> c;
17  if (c != '%') {
18  check_macro (isdigit(c), "mm read: not in matrix market format");
19  is.unget();
20  return;
21  }
22  is >> std::ws >> c;
23  bool have_a_spec_line = (c == '%');
24  std::string line;
25  getline (is, line);
26  if (have_a_spec_line && ! already_have_a_spec_line) {
27  std::stringstream spec (line);
28  std::string head, matrix, type, valued, symmetry;
29  // see http://math.nist.gov/MatrixMarket/formats.html
30  // and http://math.nist.gov/MatrixMarket/reports/MMformat.ps.gz , page 7
31  spec >> head >> matrix >> type >> valued >> symmetry;
32  check_macro (head == "MatrixMarket", "mm read: expect `%%MatrixMarket', get `"<<head<<"'");
33  check_macro (matrix == "matrix", "mm read: unsupported `"<<matrix <<"' extension: only \"matrix\" format yet supported");
34  check_macro (type == "coordinate", "mm read: unsupported `"<<type <<"': only \"coordinate\" format yet supported");
35  check_macro (valued == "real", "mm read: unsupported `"<<valued <<"': only \"real\" values yet supported");
36  check_macro (symmetry == "general", "mm read: unsupported `"<<symmetry<<"': only \"general\" format yet supported");
37  already_have_a_spec_line = true;
38  }
39  } while (true);
40 }
41 
42 } // namespace rheolef
43