UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1/*
2 * =====================================================================================
3 *
4 * Filename: matrix-generator.c
5 *
6 * Description:
7 *
8 * Version: 1.0
9 * Created: 04/30/2012 04:49:14 PM
10 * Revision: none
11 * Compiler: gcc
12 *
13 * Author: Milan Kabat (), kabat@ics.muni.cz
14 * Organization:
15 *
16 * =====================================================================================
17 */
18#include <stdlib.h>
19#include <unistd.h>
20#include <time.h>
21#include <stdio.h>
22#include <string.h>
23
24#include "matrix-generator.h"
25
26using namespace std;
27
28void usage()
29{
30 fprintf(stdout, "\nOptions:\n");
31 fprintf(stdout, "\t'a'\tUse algorithm from RFC 5170\n");
32 fprintf(stdout, "\t'c'\tNumber of 1's per column\n");
33 fprintf(stdout, "\t'f'\tOutput filename\n");
34 fprintf(stdout, "\t'k'\tParameter 'K' of LDGM coding\n");
35 fprintf(stdout, "\t'm'\tParameter 'M' of LDGM coding\n");
36 fprintf(stdout, "\t'r'\tGenerate matrix by random\n");
37 fprintf(stdout, "\t's'\tPseudo-random number generator seed\n");
38
39 fprintf(stdout, "\n");
40}
41
42int main (int argc, char* argv[])
43{
44 extern int optopt;
45 extern char* optarg;
46 int c;
47
48 int k = 0;
49 int m = 0;
50 int seed = 0;
51 int column_weight = 0;
52
53 int random = 0;
54 int rfc = 0;
55 char fname[32];
56
57
58 while ( ( c = getopt ( argc, argv, "ac:f:hk:m:rs:")) != -1 ) {
59 switch(c) {
60 case 'a':
61 if(random)
62 {
63 fprintf (stderr, "Only one of the options 'a' 'r' can be chosen.\n" );
64 return EXIT_FAILURE;
65 }
66 rfc = 1;
67 break;
68 case 'c':
69 column_weight = atoi ( optarg );
70 break;
71 case 'f':
72 sprintf(fname, "%s", optarg );
73 break;
74 case 'h':
75 usage();
76 return EXIT_SUCCESS;
77 case 'k':
78 k = atoi ( optarg );
79 break;
80 case 'm':
81 m = atoi ( optarg );
82 break;
83 case 'r':
84 if(rfc)
85 {
86 fprintf (stderr, "Only one of the options 'a' 'r' can be chosen.\n" );
87 return EXIT_FAILURE;
88 }
89 random = 1;
90 break;
91 case 's':
92 seed = atoi ( optarg );
93 break;
94 case '?':
95 if ( optopt == 'c' || optopt == 'k' || optopt == 'm' )
96 fprintf ( stderr, "Option -%c requires an argument.\n", optopt);
97 else
98 fprintf ( stderr, "Unknown option character '\\x%x'.\n", optopt);
99
100 return 1;
101 default:
102 abort();
103 }
104 }
105
106 if ( ! ( k > 0 && m > 0 && column_weight > 0 && (random > 0 || rfc > 0) ) )
107 {
108 usage();
109 return EXIT_FAILURE;
110 }
111
112 return generate_ldgm_matrix(fname, k, m, column_weight, seed, 0);
113}
114
void usage()
Definition main.cpp:28
int generate_ldgm_matrix(char *fname, unsigned int k, unsigned int m, unsigned int column_weight, unsigned int seed, unsigned int extend_rows)