This program refuses to take foom as input, yet if I were to put "matrix.txt" into the function instead of foom, it would work fine.
#include <fstream>
#include <iterator>
#include <sstream>
#include <vector>
#include <string> // needed?
using namespace std;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
Mat readMatrix(string foom){
Mat x;
ifstream in(foom);
if (in) {
for (string line; getline(in, line);) {
istringstream iss(line);
x.push_back(Vec());
copy(istream_iterator<double>(iss),
istream_iterator<double>(),
back_inserter(x.back()));
}
}
return x;
}