Skip to content
Snippets Groups Projects
Commit 8a76bcac authored by Mark Jenkinson's avatar Mark Jenkinson
Browse files

Changed read_ascii_matrix to make it _much_ quicker for large matrices of unknown size

parent dc82b7a9
No related branches found
No related tags found
No related merge requests found
......@@ -141,8 +141,6 @@ namespace MISCMATHS {
ReturnMatrix read_ascii_matrix(ifstream& fs)
{
Matrix mat;
int rcount=0, cmax=0;
double val;
string cline;
......@@ -159,9 +157,8 @@ namespace MISCMATHS {
}
}
cmax--;
RowVector newrow(cmax);
do {
do {
getline(fs,cline);
cline += " "; // force extra entry in parsing
istrstream ss(cline.c_str());
......@@ -169,20 +166,13 @@ namespace MISCMATHS {
ss >> cc;
if (!isnum(cc)) break; // stop processing when non-numeric line found
rcount++; // add new row to matrix
newrow = 0.0;
int ccount = 1;
do {
val = atof(cc.c_str());
if (ccount<=cmax) newrow(ccount++) = val;
ss >> cc;
} while (!ss.eof());
if (rcount>1) mat = mat & newrow;
else mat = newrow;
} while (!fs.eof());
} while (!fs.eof());
mat.Release();
return mat;
// now know the size of matrix
fs.clear();
fs.seekg(0,ios::beg);
return read_ascii_matrix(fs,rcount,cmax);
}
#define BINFLAG 42
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment