-
Notifications
You must be signed in to change notification settings - Fork 1
/
extendedpeeling.cpp
97 lines (72 loc) · 2.17 KB
/
extendedpeeling.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
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
96
97
#include <iostream>
#include <fstream>
#include <getopt.h>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <ctime>
#include <algorithm>
//#include <omp.h>
#include "getopt_pp.h"
#include "graph.h"
#include "dists.h"
#include "utils.h"
//#include "sse_mathfun.h"
using namespace std;
using namespace GetOpt;
static void usage() {
cerr << "Usage: gldpc -n <codelength> [-d <leftdegree>] -D <rightdegree> "<<endl;
//./simcodes -c st -n 10 -s 128 -d 4 -m 5
//./simcodes -c ex -n 14 -s 256 -d 4 --md1 7 --md2 15 -I 20 -g
exit(EXIT_FAILURE);
}
int main(int argc, char* argv[]) {
int n = 512;
int d=2,D=8;
double ov=0.01;
bool quiet = false;
string gname = "";
unsigned long int rseed = static_cast<unsigned long int>(std::time(0));
GetOpt_pp ops(argc, argv);
if (ops >> OptionPresent('h', "help") || argc == 1)
usage();
//required args
try {
ops.exceptions(std::ios::failbit | std::ios::eofbit);
ops
>> Option('n',"nvar", n) ;
//>> Option('d', "d1", d1);
//>> Option('m', "md1", md1);
} catch (const GetOptEx& e) {
std::cerr << "Invalid options or format\n";
usage();
}
//optional args
try {
ops.exceptions(std::ios::failbit);
ops
>> Option('d', d)
>> Option('D', D)
// >> Option('p', channelparam)
>> Option('o', "overhead", ov, 0.01)
>> Option('w', "output", gname, "")
>> Option('x', "seed", rseed, rseed);
} catch (const GetOptEx& e) {
std::cerr << e.what();
std::cerr << "Invalid options or format\n";
usage();
}
quiet = ops >> OptionPresent('q', "quiet");
if(!quiet)
cout<<"Random seed is "<<rseed<<endl;
setrandseed(rseed);
//return 0;
BipartiteGraph graph((1+ov)*n,n);
//graph.makeRandomSimpleRegular(10,10);
RobustSoliton sol();
sol.Sample(graph);
if (gname!="")
graph.writeSMAT(gname);
cout<<"rank="<<graph.rank()<<endl;
}