-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerm.cpp
More file actions
51 lines (48 loc) · 1.16 KB
/
Copy pathPerm.cpp
File metadata and controls
51 lines (48 loc) · 1.16 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
# include "Perm.h"
// A constructor
Rperm :: Rperm()
{
N = 0;
generator.seed(system_clock :: now().time_since_epoch().count());
}
// A function that generates a random permutation
void Rperm :: generate(int n, Timer &t1)
{
g.clear();
for(int i = 1; i < n + 1; i++)
{
g.push_back(i);
t1.time(1);
}
}
// A function that generates permutation test case files
void Rperm :: setCase(string &s, int T, int t, int n, int sz, string &folder_name)
{
int pt = FileOp :: printT(t);
cout << "Generating perm test files: " << '\n';
for(int i = 0; i < T; i++)
{
FileOp :: setFile(folder_name, s, i, fout);
vector <int> times = numOp :: giveRints(t, n, sz);
N = times.size();
if(pt)
fout << N << '\n';
int tcnt = 0;
for(int j = 0; j < N; j++)
tcnt += times[j];
Timer t1(2 * tcnt);
for(int j = 0; j < N; j++)
{
fout << times[j] << '\n';
generate(times[j], t1);
shuffle(g.begin(), g.end(), default_random_engine(system_clock :: now().time_since_epoch().count()));
for(int k = 0; k < (int)g.size(); k++)
{
fout << g[k] << " \n"[k == (int)g.size() - 1];
t1.time(1);
}
}
fout.close();
}
cout << "perm generation completed." << '\n';
}