summaryrefslogtreecommitdiff
path: root/lab-windows/fec_experiments.ipynb
blob: 348119b00470ea6c4d907e9dab65d66f4bde2038 (plain)
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
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib\n",
    "from matplotlib import pyplot as plt\n",
    "import pyldpc\n",
    "import scipy.sparse"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib widget"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "metadata": {},
   "outputs": [],
   "source": [
    "H, G = pyldpc.make_ldpc(384, 6, 8, systematic=False, seed=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(384, 101)"
      ]
     },
     "execution_count": 116,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n, k = G.shape\n",
    "G.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "af5e3d32d4e7491ea2dfdceceef0b346",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots(figsize=(9, 6))\n",
    "fig.tight_layout()\n",
    "ax.matshow(H)\n",
    "None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "metadata": {},
   "outputs": [],
   "source": [
    "import ctypes\n",
    "lib = ctypes.CDLL('../controller/fw/ldpc_decoder_test.so')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "metadata": {},
   "outputs": [],
   "source": [
    "np.set_printoptions(linewidth=180, threshold=1000, edgeitems=20)\n",
    "#bits_indices, bits, _ = scipy.sparse.find(H)\n",
    "#np.all(bits_indices == np.repeat(range(288), 8))\n",
    "bits_indices, bits, _ = scipy.sparse.find(H.T)\n",
    "#p.bincount(bits_indices)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 120,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bits_indices, bits, _ = scipy.sparse.find(H)\n",
    "l =  [                                                                                                                                                                                                                                                                                 0,    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\n",
    "    ,   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\n",
    "    ,   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\n",
    "    ,   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\n",
    "    ,  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\n",
    "    ,  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\n",
    "    ,  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\n",
    "    ,  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\n",
    "    ,  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\n",
    "    ,  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\n",
    "    ,  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\n",
    "    ,  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\n",
    "    ,   33,   34,   52,   55,  232,  251,  252,  287,   42,   49,   78,  115,  234,  247,  265,  375,   61,   93,  106,  121,  198,  223,  243,  285,   43,  168,  173,  254,  255,  333,  339,  359\n",
    "    ,   32,  146,  148,  184,  269,  328,  340,  365,   36,  159,  189,  245,  272,  286,  324,  382,    3,   50,   70,   97,  170,  274,  299,  329,   39,   46,   77,   85,  235,  271,  281,  320\n",
    "    ,   14,   24,   69,  113,  203,  237,  298,  369,   53,   54,   66,  163,  200,  225,  256,  357,   88,  151,  211,  263,  267,  311,  316,  370,   10,   91,  100,  192,  293,  295,  315,  368\n",
    "    ,   73,   90,  116,  129,  150,  233,  290,  350,   63,  158,  193,  209,  219,  226,  248,  325,  124,  127,  133,  214,  246,  318,  355,  381,    1,  101,  135,  141,  253,  279,  312,  341\n",
    "    ,   83,   95,  111,  145,  191,  283,  306,  331,   15,   38,  105,  139,  164,  179,  230,  304,   48,   60,  123,  132,  220,  303,  336,  346,   23,   41,   45,   94,  176,  221,  222,  240\n",
    "    ,   62,   96,  130,  194,  208,  210,  335,  360,   21,   79,  112,  125,  153,  297,  363,  383,    7,   47,  154,  261,  291,  305,  334,  349,    2,  138,  167,  212,  216,  257,  284,  342\n",
    "    ,   76,  122,  162,  239,  353,  366,  377,  380,   13,   72,  103,  228,  288,  300,  310,  338,    0,  110,  149,  190,  207,  217,  275,  374,   27,   67,   81,   84,  114,  131,  177,  280\n",
    "    ,   51,  107,  128,  156,  181,  202,  249,  302,   25,   31,   59,   64,  136,  152,  186,  236,   18,   74,  137,  197,  204,  337,  354,  372,    4,   56,  108,  126,  174,  187,  188,  378\n",
    "    ,   57,  118,  140,  196,  264,  292,  309,  322,   65,   87,  144,  183,  268,  273,  317,  356,    8,   17,  169,  180,  199,  301,  326,  373,   44,   68,   80,   82,  143,  201,  266,  347\n",
    "    ,    9,  242,  250,  258,  319,  332,  344,  371,   12,   20,   92,  104,  117,  142,  276,  277,    6,   28,   86,  102,  119,  160,  182,  238,   30,  109,  134,  171,  227,  229,  278,  367\n",
    "    ,   37,   40,  175,  224,  241,  289,  321,  379,    5,   99,  260,  282,  313,  330,  352,  358,  157,  172,  195,  262,  307,  323,  351,  361,   19,   26,   35,   58,   75,  166,  314,  345\n",
    "    ,   22,   89,  244,  294,  296,  343,  348,  376,   29,   71,  147,  165,  178,  259,  270,  327,   11,   16,   98,  155,  206,  215,  362,  364,  120,  161,  185,  205,  213,  218,  231,  308\n",
    "    ,   48,   50,  100,  261,  297,  325,  363,  378,   13,   25,   36,   42,   96,  101,  234,  258,   19,   52,   67,   83,  162,  187,  270,  352,    7,   16,  188,  207,  321,  330,  367,  374\n",
    "    ,   60,   91,   93,  128,  190,  218,  287,  295,    5,   58,   75,  108,  170,  172,  298,  346,   51,   88,  121,  130,  139,  255,  267,  373,   18,   21,  157,  168,  174,  265,  345,  383\n",
    "    ,   76,   97,  120,  137,  158,  210,  248,  353,    3,   43,  136,  194,  245,  273,  293,  313,   64,   79,  113,  142,  191,  232,  253,  306,   55,  219,  246,  268,  281,  294,  314,  343\n",
    "    ,    0,   34,   89,  154,  201,  290,  307,  377,  112,  138,  198,  264,  302,  308,  342,  362,   61,   86,  127,  148,  247,  286,  349,  365,   39,  118,  141,  181,  223,  291,  315,  355\n",
    "    ,  125,  180,  282,  303,  316,  326,  332,  335,    1,   32,  104,  105,  178,  189,  348,  361,   45,   78,   92,  155,  185,  300,  357,  380,   29,   40,   46,  147,  160,  225,  241,  372\n",
    "    ,    2,   14,   99,  156,  214,  235,  256,  278,    9,   28,   74,  238,  257,  284,  299,  323,   70,   98,  114,  119,  151,  285,  296,  360,   41,  129,  150,  215,  224,  277,  329,  368\n",
    "    ,   57,   95,  126,  134,  221,  280,  310,  317,   11,   30,  102,  230,  269,  275,  288,  318,   15,   65,   82,  182,  212,  266,  309,  358,  107,  111,  115,  240,  243,  251,  272,  305\n",
    "    ,   87,   90,  204,  244,  320,  334,  336,  337,   23,   33,   59,   85,  109,  149,  283,  381,  131,  165,  192,  196,  211,  236,  259,  312,   31,  117,  153,  164,  199,  213,  222,  319\n",
    "    ,   54,   69,   94,  161,  186,  249,  304,  356,    6,    8,  106,  122,  177,  205,  217,  344,   17,   62,   66,  123,  197,  226,  339,  371,   44,  145,  206,  237,  239,  289,  322,  379\n",
    "    ,   71,  143,  163,  167,  176,  200,  331,  351,   72,  132,  140,  171,  179,  193,  254,  354,   12,   77,  103,  159,  202,  252,  366,  376,   37,  173,  203,  220,  229,  231,  311,  333\n",
    "    ,   68,  208,  216,  233,  260,  271,  327,  350,   49,   84,  166,  169,  262,  274,  338,  340,   81,  135,  144,  263,  324,  359,  364,  375,   10,   22,   63,   80,  227,  228,  292,  328\n",
    "    ,  110,  124,  146,  152,  175,  341,  369,  370,    4,   20,   26,   35,  116,  183,  195,  301,   24,   56,   73,  133,  184,  209,  279,  382,   27,   38,   47,   53,  242,  250,  276,  347\n",
    "    ,   16,   82,  142,  210,  217,  268,  344,  370,   10,   12,  124,  126,  201,  325,  336,  353,   47,   73,   92,   95,  107,  212,  240,  312,   33,  102,  132,  164,  221,  254,  296,  314\n",
    "    ,   30,   49,   56,   58,   61,   67,  140,  260,   41,   60,   76,   89,  218,  279,  302,  338,   20,   62,   79,  113,  186,  213,  331,  355,   25,   28,   29,  108,  153,  169,  297,  364\n",
    "    ,   18,   75,  117,  120,  133,  287,  326,  329,   86,  137,  149,  162,  200,  249,  309,  351,   26,  163,  178,  245,  284,  361,  371,  380,   65,   72,  216,  219,  258,  294,  304,  333\n",
    "    ,    8,  193,  197,  225,  241,  270,  319,  324,   81,   83,  100,  111,  122,  155,  228,  278,  182,  189,  196,  263,  275,  327,  337,  360,    6,   15,   35,   53,  203,  237,  308,  379\n",
    "    ,   36,  166,  204,  252,  256,  282,  365,  373,   19,   66,  106,  114,  139,  161,  188,  247,   97,  165,  211,  224,  310,  354,  362,  382,   63,   78,   94,   99,  317,  339,  342,  376\n",
    "    ,   23,   51,  105,  143,  261,  289,  292,  330,   45,  148,  152,  171,  208,  238,  242,  303,   17,   91,  110,  231,  255,  271,  299,  372,   27,   87,   90,  129,  134,  236,  301,  352\n",
    "    ,   40,  160,  180,  192,  229,  243,  273,  320,    9,   42,  115,  127,  157,  285,  349,  368,   68,   84,  170,  177,  232,  307,  321,  369,    3,   11,   57,  125,  147,  172,  283,  291\n",
    "    ,    7,  190,  222,  227,  295,  348,  350,  359,   43,   69,   98,  101,  128,  207,  277,  293,   31,   55,  104,  119,  130,  158,  341,  375,   13,   85,  135,  226,  305,  318,  358,  366\n",
    "    ,   22,   34,  183,  187,  199,  215,  311,  378,   32,   70,  112,  154,  205,  230,  266,  322,   54,  202,  248,  272,  290,  323,  343,  345,    0,   88,  150,  173,  233,  234,  269,  334\n",
    "    ,  141,  146,  206,  220,  253,  281,  332,  381,   21,  138,  144,  174,  179,  194,  262,  298,   38,   71,   93,  156,  168,  181,  214,  239,   48,   50,   77,  264,  288,  328,  356,  357\n",
    "    ,   96,  167,  184,  267,  280,  300,  347,  363,   14,   44,   80,  103,  145,  209,  335,  367,    2,    5,   74,  109,  121,  136,  151,  276,  131,  191,  195,  223,  286,  316,  377,  383\n",
    "    ,    4,   39,  159,  235,  274,  306,  313,  346,    1,   24,   46,   52,   64,  123,  250,  259,   37,   59,  175,  185,  198,  251,  257,  340,  116,  118,  176,  244,  246,  265,  315,  374\n",
    "    ,   26,   74,  124,  155,  189,  219,  374,  381,    4,   38,  103,  139,  199,  293,  319,  350,   75,   77,  158,  161,  181,  208,  261,  284,   39,  109,  122,  175,  234,  265,  271,  340\n",
    "    ,    2,  130,  275,  277,  312,  333,  342,  362,   13,   31,   95,  209,  249,  289,  298,  375,   47,  125,  131,  164,  226,  252,  353,  356,   21,  159,  166,  324,  330,  339,  368,  383\n",
    "    ,   10,   37,   89,  197,  220,  223,  300,  366,    0,   12,   78,  111,  112,  154,  311,  377,   86,  129,  140,  141,  191,  204,  254,  297,    3,   42,   61,  126,  185,  257,  269,  371\n",
    "    ,   35,   43,  157,  210,  215,  251,  347,  367,   17,  177,  180,  193,  213,  263,  363,  372,   57,  104,  203,  227,  236,  253,  262,  344,   64,   72,   82,  135,  136,  239,  320,  348\n",
    "    ,    1,  116,  218,  240,  288,  334,  357,  364,   20,   49,   97,  121,  182,  256,  294,  309,   79,  102,  113,  118,  137,  152,  195,  343,   23,   30,   48,  128,  216,  291,  313,  335\n",
    "    ,   58,   63,  127,  169,  228,  264,  328,  369,   62,   70,  106,  144,  153,  198,  201,  255,   56,  107,  148,  162,  179,  212,  290,  351,   54,   59,   88,   92,  143,  282,  303,  365\n",
    "    ,   99,  123,  165,  200,  222,  296,  302,  349,   15,   36,   50,   94,  160,  167,  230,  370,   73,  120,  138,  194,  231,  246,  259,  379,    9,   25,  146,  224,  260,  301,  359,  376\n",
    "    ,  100,  183,  186,  238,  248,  258,  331,  352,  114,  117,  184,  188,  221,  268,  327,  378,  115,  192,  205,  214,  242,  325,  332,  382,   71,   84,   98,  174,  206,  235,  314,  317\n",
    "    ,   19,   65,  101,  172,  196,  270,  316,  318,   28,   67,  119,  173,  202,  306,  341,  354,    7,   27,  247,  280,  285,  292,  321,  329,   60,   80,   93,  304,  310,  323,  336,  345\n",
    "    ,   14,   52,   90,  132,  156,  276,  358,  380,   40,   91,  110,  171,  217,  233,  278,  281,   11,   66,  108,  149,  176,  241,  244,  283,   18,   32,   45,   87,  207,  245,  267,  307\n",
    "    ,   22,   55,  142,  170,  187,  229,  308,  337,    6,   46,  134,  150,  178,  211,  250,  279,   16,  133,  266,  286,  315,  326,  338,  361,   24,   68,   76,   81,  225,  243,  295,  322\n",
    "    ,    8,   41,   53,   69,   83,   96,  190,  237,   44,   51,  232,  272,  273,  287,  346,  355,    5,   29,   33,  147,  163,  274,  299,  360,   34,   85,  105,  145,  151,  168,  305,  373\n",
    "    ,  126,  143,  197,  211,  267,  318,  326,  362,   26,  124,  200,  232,  265,  270,  298,  319,    5,   45,   48,  169,  203,  286,  351,  381,   24,   44,  123,  137,  156,  273,  283,  307\n",
    "    ,   18,  108,  199,  234,  262,  275,  314,  375,    4,   37,   68,   75,  164,  264,  291,  295,   94,  183,  207,  221,  271,  289,  293,  354,  121,  131,  161,  166,  188,  259,  284,  327\n",
    "    ,   10,   90,  127,  147,  244,  316,  328,  358,   11,   23,  122,  220,  288,  304,  325,  366,   63,   70,  101,  106,  146,  168,  195,  370,   52,  182,  218,  249,  330,  332,  333,  368\n",
    "    ,   74,   97,  102,  239,  290,  308,  340,  373,   20,  110,  145,  163,  229,  246,  251,  331,   84,  136,  149,  213,  258,  301,  360,  365,   51,  114,  174,  238,  276,  348,  352,  383\n",
    "    ,   13,   27,   30,   92,  187,  302,  338,  341,   62,   79,   80,  186,  230,  278,  294,  324,    9,   67,  180,  269,  285,  312,  343,  372,    7,   14,   83,   89,  160,  178,  287,  364\n",
    "    ,   47,   56,   78,  107,  128,  177,  228,  250,   46,  100,  243,  252,  255,  282,  299,  345,   25,   28,   72,  162,  245,  257,  317,  382,   32,   36,   69,  115,  237,  342,  347,  355\n",
    "    ,  105,  154,  179,  184,  268,  277,  346,  350,    6,   15,   55,  111,  113,  225,  297,  320,   21,   85,   86,  109,  261,  305,  344,  349,   22,  112,  125,  181,  216,  233,  281,  311\n",
    "    ,   35,   38,   43,   82,  219,  263,  322,  380,   53,   57,   81,  117,  185,  247,  323,  367,   65,   66,  150,  165,  170,  235,  300,  357,    3,   29,  116,  144,  176,  196,  274,  306\n",
    "    ,    2,   95,   98,  120,  141,  158,  193,  315,   64,   91,   99,  142,  248,  256,  279,  361,   60,  130,  167,  210,  236,  253,  254,  339,   59,   77,  129,  191,  202,  223,  296,  310\n",
    "    ,    1,   16,   40,  140,  173,  209,  280,  353,   58,   73,   87,   96,  134,  208,  212,  313,   12,   42,   93,  119,  135,  272,  303,  329,   34,  118,  148,  189,  214,  222,  321,  337\n",
    "    ,   54,   71,   88,  241,  356,  374,  376,  378,   39,   76,  157,  192,  205,  231,  266,  335,    8,  153,  155,  194,  204,  206,  359,  377,   17,   49,   61,  103,  133,  151,  336,  379\n",
    "    ,   19,  172,  175,  190,  198,  201,  217,  227,    0,   31,   41,  104,  152,  159,  171,  309,   33,  132,  240,  242,  260,  292,  334,  369,   50,  138,  139,  215,  224,  226,  363,  371\n",
    "\n",
    "]\n",
    "np.all(bits == l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bits_indices, bits, _ = scipy.sparse.find(H.T)\n",
    "l =  [\n",
    "       0,   74,  108,  179,  201,  285,    0,   63,  113,  189,  208,  276,    0,   71,  116,  186,  196,  272,    0,   54,  105,  171,  203,  271,    0,   79,  141,  188,  193,  245,    0,   89\n",
    "    ,  101,  186,  238,  242,    0,   86,  129,  159,  233,  265,    0,   70,   99,  172,  226,  259,    1,   82,  129,  156,  236,  282,    1,   84,  117,  169,  219,  258,    1,   59,  139,  145\n",
    "    ,  200,  248,    1,   94,  121,  171,  230,  249,    1,   85,  134,  145,  201,  278,    1,   73,   97,  175,  197,  256,    1,   56,  116,  185,  228,  259,    1,   65,  122,  159,  217,  265\n",
    "    ,    2,   94,   99,  144,  234,  276,    2,   82,  130,  166,  205,  283,    2,   78,  103,  152,  231,  244,    2,   91,   98,  161,  224,  284,    2,   85,  141,  150,  209,  253,    2,   69\n",
    "    ,  103,  181,  199,  266,    2,   92,  139,  176,  232,  267,    2,   67,  125,  164,  211,  249,    3,   56,  142,  189,  235,  243,    3,   77,   97,  151,  219,  262,    3,   91,  141,  154\n",
    "    ,  192,  241,    3,   75,  143,  167,  226,  256,    3,   86,  117,  151,  225,  262,    3,   93,  115,  151,  238,  271,    3,   87,  121,  148,  211,  256,    3,   77,  127,  174,  197,  285\n",
    "    ,    4,   52,  113,  177,  231,  263,    4,   48,  125,  147,  238,  286,    4,   48,  108,  176,  239,  279,    4,   91,  141,  159,  204,  268,    4,   53,   97,  160,  217,  263,    4,   88\n",
    "    ,  135,  190,  200,  245,    4,   65,  143,  182,  193,  268,    4,   55,  111,  188,  195,  281,    5,   88,  115,  168,  229,  276,    5,   67,  119,  149,  236,  285,    5,   49,   97,  169\n",
    "    ,  203,  278,    5,   51,  105,  173,  204,  268,    5,   83,  131,  185,  237,  243,    5,   67,  114,  165,  231,  242,    5,   55,  115,  189,  233,  261,    5,   70,  143,  146,  198,  260\n",
    "    ,    6,   66,   96,  183,  211,  242,    6,   49,  137,  148,  209,  283,    6,   54,   96,  183,  217,  287,    6,   76,  102,  164,  237,  255,    6,   48,   98,  189,  228,  251,    6,   57\n",
    "    ,  143,  159,  236,  269,    6,   57,  128,  178,  215,  280,    6,   48,  107,  174,  232,  265,    7,   79,  142,  148,  214,  260,    7,   80,  120,  171,  206,  269,    7,   91,  101,  148\n",
    "    ,  212,  277,    7,   77,  125,  190,  215,  275,    7,   66,  100,  149,  227,  274,    7,   50,  110,  148,  203,  283,    7,   68,  130,  150,  213,  257,    7,   61,  139,  163,  212,  250\n",
    "    ,    8,   77,  106,  189,  207,  273,    8,   81,  122,  155,  224,  270,    8,   57,  130,  161,  230,  270,    8,   75,   98,  148,  225,  258,    8,   83,  136,  170,  235,  245,    8,   56\n",
    "    ,  128,  173,  236,  263,    8,   54,  118,  177,  213,  250,    8,   93,  132,  182,  223,  280,    9,   73,  133,  155,  207,  262,    9,   60,  142,  146,  218,  277,    9,   78,  117,  186\n",
    "    ,  192,  252,    9,   91,  101,  152,  194,  245,    9,   72,  104,  149,  235,  281,    9,   55,  134,  183,  194,  275,    9,   49,  114,  163,  201,  260,    9,   69,  106,  150,  210,  257\n",
    "    ,   10,   83,  139,  185,  227,  257,   10,   75,  138,  157,  235,  269,   10,   83,  122,  144,  207,  268,   10,   64,   98,  157,  236,  259,   10,   75,  137,  170,  223,  254,   10,   55\n",
    "    ,  125,  175,  239,  266,   10,   86,  110,  153,  202,  266,   10,   81,  124,  167,  231,  277,   11,   58,  102,  179,  215,  280,   11,   92,  108,  149,  200,  259,   11,   60,  124,  167\n",
    "    ,  228,  248,   11,   59,  100,  166,  229,  273,   11,   85,  114,  146,  215,  256,   11,   50,  100,  182,  227,  278,   11,   67,  128,  163,  217,  246,   11,   64,  120,  146,  197,  272\n",
    "    ,   12,   68,   97,  184,  236,  277,   12,   54,  104,  162,  209,  252,   12,   94,  118,  173,  223,  272,   12,   89,  116,  163,  216,  273,   12,   59,   96,  157,  220,  261,   12,   63\n",
    "    ,   97,  173,  224,  250,   12,   86,  121,  147,  210,  252,   12,   73,  134,  185,  193,  283,   13,   85,  113,  174,  206,  285,   13,   65,  113,  164,  239,  264,   13,   50,  129,  161\n",
    "    ,  213,  250,   13,   76,  123,  146,  214,  260,   13,   79,  101,  151,  230,  244,   13,   87,  125,  186,  195,  266,   13,   74,  140,  166,  229,  253,   13,   64,  123,  157,  201,  265\n",
    "    ,   14,   69,  109,  177,  201,  267,   14,   56,  106,  150,  210,  265,   14,   75,  118,  161,  221,  255,   14,   49,  123,  169,  222,  263,   14,   60,  141,  191,  208,  271,   14,   85\n",
    "    ,  127,  152,  221,  269,   14,   80,  111,  191,  210,  279,   14,   86,  118,  174,  225,  278,   15,   95,  104,  152,  218,  272,   15,   50,  102,  186,  209,  247,   15,   72,  129,  157\n",
    "    ,  195,  249,   15,   66,  130,  189,  216,  243,   15,   62,  140,  145,  192,  241,   15,   69,  112,  171,  198,  267,   15,   79,  120,  145,  203,  240,   15,   62,  110,  169,  212,  248\n",
    "    ,   16,   76,  100,  173,  211,  260,   16,   60,  119,  167,  202,  275,   16,   68,  102,  174,  196,  274,   16,   75,  126,  187,  198,  247,   16,   66,  133,  147,  228,  286,   16,   62\n",
    "    ,  142,  152,  234,  283,   16,   87,  120,  167,  233,  277,   16,   63,  138,  175,  207,  278,   17,   77,  105,  186,  207,  254,   17,   78,  104,  153,  210,  243,   17,   71,  109,  181\n",
    "    ,  218,  287,   17,   65,  102,  161,  193,  287,   17,   80,  133,  148,  202,  276,   17,   63,  111,  180,  202,  272,   17,   85,  106,  144,  232,  273,   17,   83,  132,  164,  215,  240\n",
    "    ,   18,   81,  138,  181,  213,  271,   18,   64,  131,  185,  239,  253,   18,   52,  140,  180,  219,  250,   18,   93,  115,  171,  238,  248,   18,   52,  110,  165,  214,  279,   18,   74\n",
    "    ,  125,  153,  230,  254,   18,   60,  119,  179,  233,  270,   18,   58,  118,  186,  239,  283,   19,   77,  140,  165,  210,  285,   19,   69,  127,  151,  213,  282,   19,   70,  108,  177\n",
    "    ,  201,  264,   19,   94,  114,  157,  192,  282,   19,   76,  116,  182,  228,  243,   19,   90,  103,  169,  204,  281,   19,   61,  104,  174,  194,  272,   19,   53,  134,  188,  199,  285\n",
    "    ,   20,   86,  115,  168,  217,  259,   20,   95,  128,  161,  194,  247,   20,   72,   98,  153,  214,  262,   20,   57,  132,  154,  238,  253,   20,   65,  127,  147,  198,  245,   20,   93\n",
    "    ,  126,  162,  216,  270,   20,   91,  137,  160,  199,  247,   20,   71,  132,  184,  217,  274,   21,   51,  103,  182,  239,  250,   21,   82,  137,  151,  212,  242,   21,   54,  101,  170\n",
    "    ,  232,  270,   21,   87,  133,  165,  229,  285,   21,   90,  101,  171,  224,  284,   21,   51,  135,  179,  225,  276,   21,   79,  103,  181,  223,  255,   21,   88,  140,  190,  195,  284\n",
    "    ,   22,   67,  132,  191,  230,  271,   22,   75,  129,  170,  205,  260,   22,   93,  113,  154,  233,  259,   22,   65,  133,  181,  214,  264,   22,   82,  112,  168,  205,  258,   22,   76\n",
    "    ,  111,  182,  194,  267,   22,   86,  122,  158,  209,  251,   22,   81,  141,  176,  220,  246,   23,   52,  142,  184,  221,  264,   23,   95,  114,  190,  203,  269,   23,   77,  128,  150\n",
    "    ,  220,  257,   23,   79,   98,  176,  232,  256,   23,   79,   99,  161,  221,  247,   23,   53,  113,  158,  192,  279,   23,   74,  100,  172,  236,  284,   23,   64,  106,  187,  202,  275\n",
    "    ,   24,   59,  126,  168,  222,  281,   24,   61,  133,  156,  205,  272,   24,   68,  105,  181,  218,  282,   24,   90,  141,  187,  210,  250,   24,   80,  126,  158,  224,  271,   24,   78\n",
    "    ,  130,  156,  200,  240,   24,   50,  109,  190,  213,  284,   24,   82,  127,  176,  193,  244,   25,   57,  132,  153,  216,  241,   25,   83,  108,  145,  213,  284,   25,   76,  134,  178\n",
    "    ,  225,  275,   25,   56,  135,  159,  206,  242,   25,   78,  124,  160,  202,  282,   25,   95,  129,  177,  222,  281,   25,   94,  131,  180,  223,  282,   25,   74,   99,  173,  231,  246\n",
    "    ,   26,   68,  136,  165,  194,  277,   26,   61,  142,  185,  197,  276,   26,   68,  104,  144,  204,  274,   26,   58,  126,  162,  233,  240,   26,   71,  122,  146,  214,  277,   26,   95\n",
    "    ,  127,  150,  205,  254,   26,   62,  116,  182,  222,  279,   26,   94,  119,  176,  204,  287,   27,   71,  136,  155,  211,  267,   27,   74,  129,  144,  229,  284,   27,   95,  100,  149\n",
    "    ,  208,  251,   27,   61,  107,  155,  192,  268,   27,   66,  135,  180,  200,  249,   27,   67,  120,  147,  221,  246,   27,   67,  127,  172,  216,  279,   27,   50,  111,  187,  200,  275\n",
    "    ,   28,   88,  119,  162,  219,  287,   28,   57,  115,  156,  235,  265,   28,   61,  130,  175,  198,  287,   28,   87,  139,  172,  206,  284,   28,   73,  139,  157,  212,  260,   28,   87\n",
    "    ,  135,  168,  232,  253,   28,   65,  121,  177,  217,  257,   28,   95,  135,  166,  218,  281,   29,   48,  106,  170,  237,  241,   29,   60,  136,  179,  229,  267,   29,   49,   97,  179\n",
    "    ,  195,  244,   29,   55,  116,  188,  223,  270,   29,   77,  126,  167,  206,  274,   29,   56,  131,  159,  236,  263,   29,   86,  117,  165,  220,  255,   29,   72,  131,  182,  207,  252\n",
    "    ,   30,   67,  123,  146,  208,  286,   30,   88,  115,  156,  230,  280,   30,   84,  143,  165,  222,  286,   30,   50,  123,  168,  235,  261,   30,   92,  124,  191,  230,  248,   30,   53\n",
    "    ,  105,  154,  231,  262,   30,   62,  107,  191,  218,  253,   30,   49,  110,  161,  226,  269,   31,   61,  104,  178,  220,  273,   31,   76,  128,  153,  197,  251,   31,   84,  143,  189\n",
    "    ,  233,  260,   31,   48,  123,  190,  204,  253,   31,   48,  134,  160,  198,  261,   31,   63,  106,  180,  206,  274,   31,   51,  133,  147,  202,  274,   31,   51,  102,  166,  213,  261\n",
    "    ,   32,   57,  116,  160,  209,  273,   32,   71,  117,  190,  203,  262,   32,   84,   97,  155,  220,  254,   32,   93,  126,  189,  218,  247,   32,   89,  136,  148,  219,  286,   32,   70\n",
    "    ,   96,  164,  194,  266,   32,   90,  137,  181,  206,  244,   32,   58,  138,  158,  205,  268,   33,   80,  109,  183,  212,  245,   33,   49,  103,  191,  195,  241,   33,   83,  122,  177\n",
    "    ,  234,  281,   33,   58,  102,  184,  231,  240,   33,   81,  107,  144,  221,  264,   33,   52,  121,  179,  203,  258,   33,   93,   98,  156,  224,  241,   33,   55,  136,  166,  195,  246\n",
    "    ,   34,   53,  123,  178,  237,  278,   34,   81,  105,  168,  237,  243,   34,   54,  137,  188,  238,  271,   34,   74,  121,  158,  196,  244,   34,   85,  143,  186,  228,  255,   34,   85\n",
    "    ,  119,  173,  196,  264,   34,   87,  116,  157,  229,  257,   34,   63,  142,  149,  233,  273,   35,   75,  120,  184,  226,  276,   35,   55,  107,  180,  229,  267,   35,   89,  112,  160\n",
    "    ,  215,  261,   35,   64,  125,  171,  230,  243,   35,   71,  117,  154,  194,  247,   35,   50,  118,  169,  226,  258,   35,   53,  110,  187,  234,  242,   35,   48,  100,  152,  237,  259\n",
    "    ,   36,   73,  121,  183,  208,  249,   36,   88,  131,  164,  197,  246,   36,   60,  108,  178,  214,  252,   36,   70,  111,  171,  211,  245,   36,   80,  139,  164,  226,  286,   36,   59\n",
    "    ,  105,  173,  193,  246,   36,   92,  107,  155,  209,  257,   36,   59,  100,  172,  235,  245,   37,   92,  118,  147,  216,  275,   37,   69,   96,  151,  202,  265,   37,   56,  101,  181\n",
    "    ,  197,  241,   37,   54,  117,  166,  238,  261,   37,   73,  114,  184,  200,  270,   37,   82,  141,  167,  219,  254,   37,   76,  109,  149,  216,  256,   37,   66,  112,  165,  215,  278\n",
    "    ,   38,   65,  128,  155,  227,  249,   38,   70,  123,  175,  239,  266,   38,   64,  106,  188,  225,  271,   38,   90,  108,  170,  231,  243,   38,   95,  109,  159,  232,  252,   38,   80\n",
    "    ,  122,  153,  209,  285,   38,   73,  120,  162,  227,  275,   38,   58,  135,  176,  201,  267,   39,   63,  126,  146,  196,  258,   39,   89,  105,  188,  211,  277,   39,   91,  107,  147\n",
    "    ,  223,  244,   39,   59,  111,  191,  234,  272,   39,   58,  112,  187,  224,  248,   39,   81,  120,  163,  223,  262,   39,   62,  121,  175,  224,  240,   39,   84,  127,  156,  193,  241\n",
    "    ,   40,   55,  124,  168,  207,  265,   40,   88,   99,  170,  226,  279,   40,   80,  131,  177,  235,  268,   40,   90,  117,  178,  227,  269,   40,   53,  138,  156,  199,  257,   40,   61\n",
    "    ,   96,  145,  222,  249,   40,   82,  112,  152,  234,  240,   40,   93,  136,  158,  221,  247,   41,   52,  139,  183,  212,  248,   41,   54,  119,  152,  226,  278,   41,   89,   99,  164\n",
    "    ,  199,  251,   41,   64,  132,  150,  220,  253,   41,   84,  112,  180,  222,  251,   41,   51,  135,  155,  196,  251,   41,   70,  124,  179,  208,  286,   41,   68,  112,  185,  211,  281\n",
    "    ,   42,   66,  124,  145,  227,  283,   42,   78,  124,  158,  232,  279,   42,   73,  137,  149,  234,  256,   42,   51,  130,  163,  199,  274,   42,   52,  137,  190,  195,  252,   42,   63\n",
    "    ,  140,  174,  225,  256,   42,   71,  109,  163,  196,  263,   42,   92,  107,  178,  210,  258,   43,   84,  129,  144,  206,  266,   43,   91,  103,  178,  227,  261,   43,   66,  101,  188\n",
    "    ,  237,  264,   43,   83,  143,  184,  204,  263,   43,   92,  113,  172,  207,  255,   43,   70,  110,  169,  216,  266,   43,   60,  136,  172,  193,  264,   43,   90,  132,  153,  214,  242\n",
    "    ,   44,   89,   98,  167,  220,  255,   44,   72,  104,  145,  198,  276,   44,   78,  133,  162,  225,  246,   44,   62,  111,  150,  237,  263,   44,   81,  128,  183,  198,  280,   44,   57\n",
    "    ,  114,  183,  208,  270,   44,   89,  122,  175,  228,  248,   44,   51,  138,  172,  219,  282,   45,   68,  118,  158,  238,  254,   45,   90,  113,  154,  234,  273,   45,   94,  109,  162\n",
    "    ,  196,  240,   45,   69,   96,  184,  205,  287,   45,   94,  138,  151,  208,  259,   45,   52,  110,  160,  215,  254,   45,   72,  134,  175,  200,  249,   45,   87,   99,  185,  204,  269\n",
    "    ,   46,   59,  119,  169,  199,  251,   46,   56,  140,  170,  212,  286,   46,   58,  140,  144,  217,  250,   46,   84,  130,  154,  203,  287,   46,   78,  115,  166,  205,  258,   46,   82\n",
    "    ,  102,  160,  239,  252,   46,   74,   99,  191,  192,  280,   46,   49,  138,  174,  197,  244,   47,   92,  134,  163,  219,  280,   47,   72,  108,  187,  201,  282,   47,   79,   96,  176\n",
    "    ,  221,  280,   47,   88,  131,  159,  218,  283,   47,   72,  114,  154,  228,  268,   47,   62,  125,  180,  192,  242,   47,   53,  142,  162,  222,  262,   47,   69,  103,  187,  199,  255\n",
    "\n",
    "]\n",
    "np.all(bits == l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(288, 384)"
      ]
     },
     "execution_count": 122,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "H.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2304"
      ]
     },
     "execution_count": 123,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sum(H)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "110592"
      ]
     },
     "execution_count": 124,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(H.flatten())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 125,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "6 * 384 == 8*288"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,\n",
       "       6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,\n",
       "       6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,\n",
       "       6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,\n",
       "       6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,\n",
       "       6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,\n",
       "       6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6])"
      ]
     },
     "execution_count": 126,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sum(H, axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,\n",
       "       8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,\n",
       "       8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,\n",
       "       8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,\n",
       "       8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,\n",
       "       8, 8, 8])"
      ]
     },
     "execution_count": 127,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sum(H, axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "7612cc62e7f34f70a0a93ed84b88fe79",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fc70960cac0>"
      ]
     },
     "execution_count": 128,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_data = np.random.randint(0, 2, k)\n",
    "\n",
    "d = np.dot(G, test_data) % 2\n",
    "x = (-1) ** d\n",
    "\n",
    "fig, ax = plt.subplots(figsize=(9, 3))\n",
    "ax.matshow(x.reshape((-1, 64)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((384,), (101,))"
      ]
     },
     "execution_count": 129,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x.shape, test_data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 130,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.all(np.equal(pyldpc.get_message(G, pyldpc.decode(H, x, 3)), test_data))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "labenv",
   "language": "python",
   "name": "labenv"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}