-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_mat.cpp
39 lines (35 loc) · 1.23 KB
/
read_mat.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <fstream>
#include <vector>
#include <iostream>
#include <tuple>
#include "read_mat.hpp"
using std::vector, std::string;
int main(int argc, char* argv[]) {
vector<string> colNames, rowNames;
vector<vector<bool>> matrix;
tuple<vector<string>, vector<string>, vector<vector<bool>>> ret;
if (argc < 2) {
string s("Apple Bat Cat\nA 0 4 0\nB 1 1 0");
std::istringstream ss(s);
ret = parseMatFile(ss);
} else {
std::ifstream matFile(argv[1]);
ret = parseMatFile(matFile);
}
if (std::get<0>(ret).size())
std::tie(colNames, rowNames, matrix) = ret;
else
std::exit(1);
std::cout << "number of cols: " << colNames.size();
std::cout << "\nnumber of rows: " << rowNames.size() << '\n';
// printWithDelim(colNames.cbegin(), colNames.cend(), ' ', std::cout);
// std::cout << '\n';
// printWithDelim(rowNames.cbegin(), rowNames.cend(), ' ', std::cout);
// std::cout << '\n';
// std::for_each(matrix.cbegin(), matrix.cend() - 1,
// [](vector<bool> row){
// printWithDelim(row.cbegin(), row.cend(), ' ', std::cout);
// std::cout << '\n';});
// std::for_each(matrix.back().cbegin(), matrix.back().cend() - 1, [](bool s){std::cout << s << ' ';});
// std::cout << matrix.back().back();
}