-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.c
666 lines (605 loc) · 22.8 KB
/
model.c
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef unsigned int uint;
/* Function estimating the value of 'X' depending on the parameters. */
typedef void X_fct(double *X_mean, uint r, uint n, uint d, uint w, uint t,
uint S, double *rho_table);
/* Function modeling the sampling of a position. */
typedef void S_fct(double *pGarray, double *pBarray, uint n, uint d, uint t);
int max(int a, int b) { return a > b ? a : b; }
int min3(int a, int b, int c) {
return a < b ? (a < c ? a : c) : (b < c ? b : c);
}
/* $lnbino(n, t) = \ln\binom{n}{t}$ */
double lnbino(uint n, uint t) {
if ((t == 0) || (n == t))
return 0.0;
else
return lgamma(n + 1) - lgamma(t + 1) - lgamma(n - t + 1);
}
double xlny(double x, double y) {
if (x == 0.)
return 0.;
else
return x * log(y);
}
/* Logarithm of the probability mass function of a binomial distribution:
* $lnbinomial(n, k, p, q)) = \ln(\binom{n}{k} p^k q^{n-k})$ */
double lnbinomialpmf(int n, int k, double p, double q) {
return lnbino(n, k) + xlny(k, p) + xlny(n - k, q);
}
/* $E_log(n, w, t, i) = \ln(\binom\binom{w}{i} {n - w}{t - i} / \binom{n}{t})$
*/
double E_log(uint n, uint w, uint t, uint i) {
return lnbino(w, i) + lnbino(n - w, t - i) - lnbino(n, t);
}
/* X_avg = sum((l - 1) * E_l, l odd) */
double X_avg(uint r, uint n, uint w, uint t) {
uint i;
double x;
/* E_log(n, w, t, i) decreases fast when 'i' varies.
* For $i = 10$ it is very likely to be negligible. */
for (x = 0, i = 1; (i <= w) && (i <= t); i += 2) {
x += (i - 1) * exp(E_log(n, w, t, i));
}
return x * r;
}
/* Probability for a bit of the syndrome to be zero, knowing the syndrome
* weight 'S' and 'X' */
double counters_C0(uint n, uint d, uint w, uint S, uint t, double x) {
return ((w - 1) * S - x) / (n - t) / d;
}
/* Probability for a bit of the syndrome to be non-zero, knowing the syndrome
* weight 'S' and 'X' */
double counters_C1(uint n, uint d, uint w, uint S, uint t, double x) {
return (S + x) / t / d;
}
uint compute_threshold(uint r, uint n, uint d, uint w, uint S, uint t) {
double p, q;
double x = X_avg(r, n, w, t);
p = counters_C0(n, d, w, S, t, x);
q = counters_C1(n, d, w, S, t, x);
uint threshold;
if (q == 1.0 || p == 1.0 || p > q) {
threshold = d;
}
else {
threshold = d + 1;
double diff = 0.;
do {
threshold--;
diff = (-exp(lnbinomialpmf(d, threshold, p, 1. - p)) * (n - t) +
exp(lnbinomialpmf(d, threshold, q, 1. - q)) * t);
} while (diff >= 0. && threshold > (d + 1) / 2);
threshold = threshold < d ? (threshold + 1) : d;
}
return threshold;
}
/* The "locking" probability is the probability that no position among the 'n'
* possible ones has a counter over the threshold.
* The algorithm would then be "locked" and loop infinitely, leading to a
* decoding failure. */
void lock(double *pGarray, double *pBarray, uint n, uint d, uint t, uint T,
long double *p_lock) {
long double pGlessT = 0.l;
long double pBlessT = 0.l;
for (uint x = 0; x < T; ++x) {
pGlessT += pGarray[x];
pBlessT += pBarray[x];
}
*p_lock = powl(pGlessT, n - t) * powl(pBlessT, t);
}
/* Fill *parray using a binomial probability mass function:
* parray[i] = P[X = i]
* where X follows a binomial distribution of parameters 'd' and 'p'. */
void binomial(double p, uint d, double *parray) {
if (p >= 1) {
for (uint x = 0; x < d; ++x) {
parray[x] = 0.;
}
parray[d] = 1.;
}
else if (p <= 0) {
for (uint x = 1; x <= d; ++x) {
parray[x] = 0.;
}
parray[0] = 1.;
}
else {
double q = 1. - p;
for (uint x = 0; x <= d; ++x)
parray[x] = exp(lnbinomialpmf(d, x, p, q));
}
}
/* <- n ->
* <- w ->
* .-----------------------------------.
* |1...............1|0...............0| <- row of the parity check matrix
* '-----------------------------------'
*
* .-----------------------------------.
* |1......1|0......0|1......1|0......0| <- error vector
* '-----------------------------------'
* <- i -> <- t-i ->
*
* $rho_table[i] = \binom{w}{i} \binom{n - w}{t - i} / \binom{n}{t}$
*
* rho_table[i] is the probability that among all the positions in an equation
* (a row of the parity check matrix) there are exactly 'i' errors.
*
* We assume that every row is chosen uniformly among the vectors of length 'n'
* and Hamming weight 'w', and that the error vector is chosen uniformly among
* the vectors of length 'n' and Hamming weight 't'.
*/
void rho(uint n, uint w, uint t, double *rho_table) {
long double sum = 1.l;
long double term = 1.l;
rho_table[0] = 1.;
for (uint i = 1; i <= w; ++i) {
term *= (w - i + 1) * (t - i + 1);
term /= i * (n - w - t + i);
rho_table[i] = term;
sum += term;
}
for (uint i = 0; i <= w; ++i) {
rho_table[i] /= sum;
}
}
long double sum_powers(long double p, uint K) {
long double ret = 1.l;
for (uint k = 0; k < K - 1; ++k)
ret = 1.l + p * ret;
return ret;
}
/* Assume that we chose 'T' as the threshold and knowing that the "good"
* positions have counters distributed following *pGarray and the "bad"
* positions' counters follow *pBarray.
*
* Modify *pGarray and *pBarray so that they contains the transition
* probability i.e.
* pBarray[i] = P[a position whose counter is 'i' is flipped and the position
* is an error];
* pGarray[i] = P[a position whose counter is 'i' is flipped and the position
* is not an error].
*
* p_flip is the probability of flipping a position.
* p_noflip is the probability of not flipping any position.
*/
void transitions(uint d, uint T, double *pGarray, double *pBarray,
long double *p_flip, long double *p_noflip) {
*p_flip = 0.l;
*p_noflip = 0.l;
for (uint x = 0; x < T; ++x) {
*p_noflip += pGarray[x] + pBarray[x];
pGarray[x] = 0.;
pBarray[x] = 0.;
}
for (uint x = T; x <= d; ++x) {
*p_flip += pGarray[x] + pBarray[x];
}
*p_flip = *p_flip / (*p_flip + *p_noflip);
*p_noflip = *p_noflip / (*p_flip + *p_noflip);
}
/* An unverified equation has an odd number of errors.
*
* Let us consider two quantities:
* - the syndrome weight,
* - and the sum of the counters of the errors.
*
* Say an equation has 'l' errors where 'l' is odd:
* - it contributes to the syndrome by 1,
* - it contributes to the sum of the counters of the errors by 'l'.
* We call 'X' the difference between these two quantities.
*
* $X = (\sum_{l odd} (l - 1) * P[an equation has exactly l errors])
* /(\sum_{l odd} P[an equation has exactly l errors])$ */
void compute_X(uint n, uint w, uint t, double *X_mean, double *rho_table) {
double term;
long double den;
den = 0.l;
*X_mean = 0.;
for (uint l = 1; l <= w; l += 2) {
term = (l - 1) * rho_table[l];
*X_mean += term;
den += rho_table[l];
}
*X_mean = *X_mean / den;
}
/* Condition the distributions *pGarray and *pBarray to only the possible
* counter values given 't' and 'S'. */
char condition_possible_counters(uint n, uint d, uint t, uint S,
double *pGarray, double *pBarray) {
long double denomG, denomB;
denomG = 0.l;
denomB = 0.l;
/* For a "good" position (i.e. not an error) we have the following
* inequations:
* 0 <= sigma <= S
* 0 <= S + d - 2 * sigma <= d * (t + 1)
*/
uint iminG = max(0, ((int)S - (int)(d * t)) / 2);
uint imaxG = min3(d, (S + d) / 2, S);
/* For a "bad" position (i.e. an error) we have the following inequations:
* 0 <= sigma <= S
* 0 <= S + d - 2 * sigma <= d * (t - 1)
*/
uint iminB = max(0, ((int)S - (int)d * ((int)t - 2)) / 2);
uint imaxB = min3(d, (S + d) / 2, S);
for (uint i = iminG; i <= imaxG; ++i) {
denomG += pGarray[i];
}
for (uint i = iminB; i <= imaxB; ++i) {
denomB += pBarray[i];
}
if (denomG == 0. || denomB == 0.) {
return 0;
}
for (uint i = 0; i <= d; ++i) {
if (i >= iminG && i <= imaxG)
pGarray[i] /= denomG;
else
pGarray[i] = 0.;
}
for (uint i = 0; i <= d; ++i) {
if (i >= iminB && i <= imaxB)
pBarray[i] /= denomB;
else
pBarray[i] = 0.;
}
return 1;
}
/* Fill the array **dfr with decoding failure rates of an MDPC code:
* dfr[t][S] = P[decoding a syndrome of weight 'S' corresponding to an error
* vector of weight 't' fails].
*
* The MDPC code considered has parameters 'r', 'n', 'd', 'w'.
* Any state with t <= t_pass is considered to be sucessful for any syndrome
* weight. Any state with t >= t_fail is considered a failure for any syndrome
* weight.
*
* The decoding algorithm considered is the "step-by-step" decoder where the
* position are sampled according to *sample_fct. The model for 'X' is given by
* *x_fct.
*/
void fill_dfr_inf(uint r, uint n, uint d, uint w, uint t_pass, uint t_fail,
double (*dfr)[d * t_fail + 1], X_fct *x_fct,
S_fct *sample_fct) {
long double(*p_lock)[d * t_fail + 1];
long double(*p_flip)[d * t_fail + 1];
long double(*p_noflip)[d * t_fail + 1];
double *(*pGarray)[d * t_fail + 1];
double *(*pBarray)[d * t_fail + 1];
char(*reachable)[d * t_fail + 1];
uint(*threshold)[d * t_fail + 1];
p_lock = malloc((d * t_fail + 1) * t_fail * sizeof(long double));
p_flip = malloc((d * t_fail + 1) * t_fail * sizeof(long double));
p_noflip = malloc((d * t_fail + 1) * t_fail * sizeof(long double));
pGarray = malloc((d * t_fail + 1) * t_fail * sizeof(double *));
pBarray = malloc((d * t_fail + 1) * t_fail * sizeof(double *));
reachable = calloc((d * t_fail + 1) * t_fail, sizeof(char));
threshold = malloc((d * t_fail + 1) * t_fail * sizeof(uint));
#pragma omp parallel for
for (uint S = 1; S <= r; ++S) {
if (S > d * t_fail)
continue;
for (uint t = t_pass + 1; t < t_fail; ++t) {
/* We know that the syndrome weight has the same parity as the
* product d * t and that it cannot exceed d * t. We therefore
* skip any other possibility. */
if ((d * t % 2) != (S % 2) || S > d * t)
continue;
uint T2 = compute_threshold(r, n, d, w, S, t);
threshold[t][S] = T2;
double *rho_table = malloc((w + 1) * sizeof(double));
double X;
(*x_fct)(&X, r, n, d, w, t, S, rho_table);
free(rho_table);
double c0, c1;
/* These arrays contain the probabilities for the counters, they
* successively are used for:
* - the distributions of the counters given the error weight 't'
* and the syndrome weight 'S';
* - the distributions of the picked counters;
* - the distributions of the flipped counters.
*
* B is for "bad" positions (i.e. errors)
* G is for "good" positions */
pBarray[t][S] = malloc((d + 1) * sizeof(double));
pGarray[t][S] = malloc((d + 1) * sizeof(double));
/* First, compute the counter distributions:
* pBarray[i] = P[sigma = i knowing that the position is an error]
* pGarray[i] = P[sigma = i knowing that the position is not an
* error] where sigma is the counter of a position (the number of
* unverified equations it is involved in).
*
* We assume they follow a binomial distributions of parameters:
* - d and c0 for "good" positions;
* - d and c1 for "bad" positions.
* */
c0 = ((w - 1) * S - X) / (d * (n - t));
c1 = (S + X) / (d * t);
binomial(c1, d, pBarray[t][S]);
binomial(c0, d, pGarray[t][S]);
dfr[t][S] = 1.;
/* Some counters are not possible given 't' and 'S' (for example
* when only one error is left, its only counter value possible is
* 'd').
*
* This function conditions the probability knowing the only
* possible values possible). If no counter value is possible, we
* skip this state. */
if (!condition_possible_counters(n, d, t, S, pGarray[t][S],
pBarray[t][S])) {
free(pBarray[t][S]);
free(pGarray[t][S]);
continue;
}
else {
reachable[t][S] = 1;
}
/* Compute the "locking" probability (i.e. the probability that no
* position has a counter over the threshold). */
lock(pGarray[t][S], pBarray[t][S], n, d, t, threshold[t][S],
&p_lock[t][S]);
/* Compute the counters probabilities after the sampling method. */
(*sample_fct)(pGarray[t][S], pBarray[t][S], n, d, t);
/* Finally consider the threshold.
* Compute the probability of flipping a position depending on the
* fact that it is an error or not and on its counter value. The
* total probability of flipping a position is 'p_flip'. The
* probability to flip no position is 'p_noflip'. */
transitions(d, threshold[t][S], pGarray[t][S], pBarray[t][S],
&p_flip[t][S], &p_noflip[t][S]);
}
}
/* Consider any state with a zero syndrome weight and a nonzero error
* weight to be a failure. */
for (uint t = t_pass + 1; t < t_fail; ++t) {
if ((d * t % 2) != 0)
continue;
dfr[t][0] = 1.;
}
for (uint S = 1; S <= d * t_fail; ++S) {
#pragma omp parallel for
for (uint t = max(t_pass + 1, S / d); t < t_fail; ++t) {
if (!reachable[t][S])
continue;
double *pGarray_current = pGarray[t][S];
double *pBarray_current = pBarray[t][S];
long double p_lock_current = p_lock[t][S];
long double p_flip_current = p_flip[t][S];
long double p_noflip_current = p_noflip[t][S];
long double dfr_current;
int flip = 0;
/* Probabilities over 1 can arise given rounding errors and
* other imprecisions, we change them into 1 to avoid
* propagation of these computation errors. */
if (p_noflip_current < 1.) {
dfr_current = 0.l;
uint T = threshold[t][S];
for (int Sigma = T; Sigma <= d; ++Sigma) {
if (pGarray_current[Sigma] != 0.) {
flip |= 1;
if (t + 1 < t_fail)
dfr_current += pGarray_current[Sigma] *
dfr[t + 1][S + d - 2 * Sigma];
else {
/* Assume this transition leads to a failure. */
if (pGarray_current[Sigma] != 0.)
dfr_current += pGarray_current[Sigma];
}
}
if (pBarray_current[Sigma] != 0.) {
flip |= 1;
if (t - 1 > t_pass) {
dfr_current += pBarray_current[Sigma] *
dfr[t - 1][S + d - 2 * Sigma];
}
}
}
}
if (!flip)
dfr[t][S] = 1.;
else {
/* We suppose that the algorithm can perform an infinite number
* of iterations until it finds a postion to flip. */
dfr[t][S] = p_lock_current + (1.l - p_lock_current) *
(dfr_current / p_flip_current);
dfr[t][S] = (dfr[t][S] > 1.) ? 1. : dfr[t][S];
}
}
}
for (uint S = 1; S <= d * t_fail; ++S) {
#pragma omp parallel for
for (uint t = t_pass + 1; t < t_fail; ++t) {
if (reachable[t][S]) {
free(pGarray[t][S]);
free(pBarray[t][S]);
}
}
}
free(p_lock);
free(p_flip);
free(p_noflip);
free(pGarray);
free(pBarray);
free(reachable);
free(threshold);
}
/* Assume 'X' is always 0.
* This is a quite pessimistic hypothesis. */
void noX(double *X, uint r, uint n, uint d, uint w, uint t, uint S,
double *rho_table) {
*X = 0.;
}
/* Assume 'X' depends only on the Hamming weight of the error vector 't'. */
void Xt(double *X, uint r, uint n, uint d, uint w, uint t, uint S,
double *rho_table) {
rho(n, w, t, rho_table);
compute_X(n, w, t, X, rho_table);
*X *= r;
}
/* Assume 'X' depends on the Hamming weight of the error vector 't' and the
* weight of the syndrome 'S'. */
void XSt(double *X, uint r, uint n, uint d, uint w, uint t, uint S,
double *rho_table) {
rho(n, w, t, rho_table);
compute_X(n, w, t, X, rho_table);
*X *= S;
}
/* Assume positions are sampled uniformly.
*
* Modify *pGarray and *pBarray so that they follow:
* pBarray[i] = P[a position whose counter is 'i' is picked and the position is
* an error];
* pGarray[i] = P[a position whose counter is 'i' is picked and the position is
* not an error]. */
void uniform(double *pGarray, double *pBarray, uint n, uint d, uint t) {
for (uint x = 0; x <= d; ++x) {
pGarray[x] *= (double)(n - t) / n;
pBarray[x] *= (double)t / n;
}
}
/* Assume positions are chosen by first picking a random unverified equation
* then picking a random postion in this equation.
*
* Modify *pGarray and *pBarray so that they follow:
* pBarray[i] = P[a position whose counter is 'i' is picked and the position is
* an error];
* pGarray[i] = P[a position whose counter is 'i' is picked and the position is
* not an error]. */
void single(double *pGarray, double *pBarray, uint n, uint d, uint t) {
long double total = 0.l;
for (uint x = 0; x <= d; ++x) {
pGarray[x] *= x * (n - t);
pBarray[x] *= x * t;
total += pGarray[x] + pBarray[x];
}
if (total > 0.) {
for (uint x = 0; x <= d; ++x) {
pGarray[x] /= total;
pBarray[x] /= total;
}
}
}
/* Assume positions are chosen by first picking two random unverified equations
* then picking a random postion in this two equations.
*
* Modify *pGarray and *pBarray so that they follow:
* pBarray[i] = P[a position whose counter is 'i' is picked and the position is
* an error];
* pGarray[i] = P[a position whose counter is 'i' is picked and the position is
* not an error]. */
void pair(double *pGarray, double *pBarray, uint n, uint d, uint t) {
long double total = 0.l;
for (uint x = 0; x <= d; ++x) {
pGarray[x] *= x * (x - 1) * (n - t);
pBarray[x] *= x * (x - 1) * t;
total += pGarray[x] + pBarray[x];
}
if (total > 0.) {
for (uint x = 0; x <= d; ++x) {
pGarray[x] /= total;
pBarray[x] /= total;
}
}
}
/* Assume positions are chosen by first picking three random unverified
* equations then picking a random postion in this three equations.
*
* Modify *pGarray and *pBarray so that they follow:
* pBarray[i] = P[a position whose counter is 'i' is picked and the position is
* an error];
* pGarray[i] = P[a position whose counter is 'i' is picked and the position is
* not an error]. */
void triple(double *pGarray, double *pBarray, uint n, uint d, uint t) {
long double total = 0.l;
for (uint x = 0; x <= d; ++x) {
pGarray[x] *= x * (x - 1) * (x - 2) * (n - t);
pBarray[x] *= x * (x - 1) * (x - 2) * t;
total += pGarray[x] + pBarray[x];
}
if (total > 0.) {
for (uint x = 0; x <= d; ++x) {
pGarray[x] /= total;
pBarray[x] /= total;
}
}
}
void print_help(char *arg0) {
printf(
"Usage: %s r d t_pass t_fail [noX|XSt|Xt] [uniform|single|pair|triple]\n"
"\n"
"Arguments:\n"
" r - Block length of the QC-MDPC code\n"
" d - Block weight of the QC-MDPC code\n"
" t_pass - Threshold value; decoder is assumed to always succeed below this\n"
" t_fail - Threshold value; decoder is assumed to always fail above this\n"
" [noX|XSt|Xt] - Counters modelling choices:\n"
" noX: assume X is always 0\n"
" XSt: approximate X depending on S and t\n"
" Xt: only consider t\n"
" [uniform|single|pair|triple]\n"
" - Position choosing strategies:\n"
" uniform: choose a position uniformly at random\n"
" single: choose a random position involved in a random unverified equation\n"
" pair: choose a random position involved in two random unverified equations\n"
" triple: choose a random position involved in three random unverified equations\n"
"\n"
"Example: %s 12323 71 5 150 XSt single\n",
arg0, arg0);
exit(1);
}
int main(int argc, char *argv[]) {
if (argc <= 6) {
print_help(argv[0]);
}
uint r = atoi(argv[1]);
uint n = 2 * r;
uint d = atoi(argv[2]);
uint w = 2 * d;
uint t_pass = atoi(argv[3]);
uint t_fail = atoi(argv[4]);
X_fct *x_fct = NULL;
S_fct *sample_fct = NULL;
if (!strcmp(argv[5], "noX")) {
x_fct = noX;
}
else if (!strcmp(argv[5], "XSt")) {
x_fct = XSt;
}
else if (!strcmp(argv[5], "Xt")) {
x_fct = Xt;
}
else {
print_help(argv[0]);
}
if (!strcmp(argv[6], "uniform")) {
sample_fct = uniform;
}
else if (!strcmp(argv[6], "single")) {
sample_fct = single;
}
else if (!strcmp(argv[6], "pair")) {
sample_fct = pair;
}
else if (!strcmp(argv[6], "triple")) {
sample_fct = triple;
}
else {
print_help(argv[0]);
}
double(*dfr)[d * t_fail + 1] =
malloc((d * t_fail + 1) * t_fail * sizeof(double));
fill_dfr_inf(r, n, d, w, t_pass, t_fail, dfr, x_fct, sample_fct);
for (uint t = t_pass + 1; t < t_fail; ++t) {
for (uint S = (d * t) % 2; S <= d * t && S <= r; S += 2) {
printf("%d %d %.50g\n", t, S, dfr[t][S]);
}
}
free(dfr);
exit(EXIT_SUCCESS);
}