-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
95 lines (86 loc) · 2.61 KB
/
Copy pathmain.cpp
File metadata and controls
95 lines (86 loc) · 2.61 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "Matrix.h"
#include <unistd.h>
#include <vector>
#include <string>
#include "MultiViewCoClust.h"
int main(int argc, char **argv) {
int c;
int nrow;
int n_iter;
int min_num_row_cluster = 2;
int random_partition = 0;
char *configFile = NULL;
char *outputFile = NULL;
opterr = 0;
srand(time(NULL));
if (argc == 1) {
std::cout << "command -r nrow -n n_iter -i configFile -o outputFile [-p] "
"[-k min_num_row_cluster]"
<< std::endl;
return 1;
}
// parse arguments
while ((c = getopt(argc, argv, "pr:i:o:n:k:")) != -1) switch (c) {
case 'p':
random_partition = 1;
break;
case 'r':
nrow = atoi(optarg);
break;
case 'i':
configFile = optarg;
break;
case 'o':
outputFile = optarg;
break;
case 'n':
n_iter = atoi(optarg);
break;
case 'k':
min_num_row_cluster = atoi(optarg);
break;
case '?':
std::cout << "command -r nrow -n n_iter -i configFile -o outputFile "
"[-p] [-k min_num_row_cluster]"
<< std::endl;
return 1;
default:
std::cout << "command -r nrow -n n_iter -i configFile -o outputFile "
"[-p] [-k min_num_row_cluster]"
<< std::endl;
return 1;
}
if (nrow == 0 || n_iter == 0) {
std::cout << "command -r nrow -n n_iter -i configFile -o outputFile [-p] "
"[-k min_num_row_cluster]"
<< std::endl;
return 1;
}
// read the input files
std::vector<std::string> feature_space;
std::vector<int> col_feature_space;
std::ifstream in(configFile);
std::string file;
int n_col = 0;
while (in >> n_col) {
in >> file;
feature_space.push_back(file);
col_feature_space.push_back(n_col);
}
// create view matrices
std::vector<Matrix> matrix_list;
for (int i = 0; i < feature_space.size(); ++i) {
Matrix a(nrow, col_feature_space[i], feature_space[i].c_str());
matrix_list.push_back(a);
}
std::string outputName = outputFile;
// parameters of the constructor are:
// * the matrices list,
// * the minimum number of clusters to create on rows,
// * the prefix for the output file names.
MultiViewCoClust *b =
new MultiViewCoClust(matrix_list, min_num_row_cluster, outputName);
b->buildCoClu(random_partition, n_iter);
delete b;
return 0;
}