Browse code

Correct the parsing in mtx files

This patch makes sure that MatrixElement is handling all of the
string parsing in the input data files. Previously, MtxParser was
doing this separetly and passing a float value. This by-passed the
error checking in MatrixElement and caused some errors to be
missed.

Tom Sherman authored on 22/07/2019 20:46:20
Showing 2 changed files

... ...
@@ -11,11 +11,6 @@ static bool containsNumber(const std::string &s)
11 11
     return !s.empty() && s.find_first_not_of("0123456789.-") == std::string::npos;
12 12
 }
13 13
 
14
-MatrixElement::MatrixElement(unsigned r, unsigned c, float v) // NOLINT
15
-    :
16
-row(r), col(c), value(v)
17
-{}
18
-
19 14
 MatrixElement::MatrixElement(unsigned r, unsigned c, const std::string &s) // NOLINT
20 15
     :
21 16
 row(r), col(c), value(0.f)
... ...
@@ -54,7 +54,7 @@ MatrixElement MtxParser::getNext()
54 54
 {
55 55
     unsigned row = 0;
56 56
     unsigned col = 0;
57
-    float val = 0.f;
57
+    std::string val;
58 58
     mFile >> row;
59 59
     mFile >> col;
60 60
     mFile >> val;