├── .gitignore ├── LDPC_576_432.alist ├── LDPC_576_432.gmat ├── LICENSE ├── README.md ├── generation_matrix.py └── main.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /LDPC_576_432.alist: -------------------------------------------------------------------------------- 1 | 576 144 2 | 4 15 3 | 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 | 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 5 | 24 34 56 88 6 | 1 35 57 89 7 | 2 36 58 90 8 | 3 37 59 91 9 | 4 38 60 92 10 | 5 39 61 93 11 | 6 40 62 94 12 | 7 41 63 95 13 | 8 42 64 96 14 | 9 43 65 73 15 | 10 44 66 74 16 | 11 45 67 75 17 | 12 46 68 76 18 | 13 47 69 77 19 | 14 48 70 78 20 | 15 25 71 79 21 | 16 26 72 80 22 | 17 27 49 81 23 | 18 28 50 82 24 | 19 29 51 83 25 | 20 30 52 84 26 | 21 31 53 85 27 | 22 32 54 86 28 | 23 33 55 87 29 | 16 26 82 130 30 | 17 27 83 131 31 | 18 28 84 132 32 | 19 29 85 133 33 | 20 30 86 134 34 | 21 31 87 135 35 | 22 32 88 136 36 | 23 33 89 137 37 | 24 34 90 138 38 | 1 35 91 139 39 | 2 36 92 140 40 | 3 37 93 141 41 | 4 38 94 142 42 | 5 39 95 143 43 | 6 40 96 144 44 | 7 41 73 121 45 | 8 42 74 122 46 | 9 43 75 123 47 | 10 44 76 124 48 | 11 45 77 125 49 | 12 46 78 126 50 | 13 47 79 127 51 | 14 48 80 128 52 | 15 25 81 129 53 | 1 45 60 138 54 | 2 46 61 139 55 | 3 47 62 140 56 | 4 48 63 141 57 | 5 25 64 142 58 | 6 26 65 143 59 | 7 27 66 144 60 | 8 28 67 121 61 | 9 29 68 122 62 | 10 30 69 123 63 | 11 31 70 124 64 | 12 32 71 125 65 | 13 33 72 126 66 | 14 34 49 127 67 | 15 35 50 128 68 | 16 36 51 129 69 | 17 37 52 130 70 | 18 38 53 131 71 | 19 39 54 132 72 | 20 40 55 133 73 | 21 41 56 134 74 | 22 42 57 135 75 | 23 43 58 136 76 | 24 44 59 137 77 | 2 28 81 123 78 | 3 29 82 124 79 | 4 30 83 125 80 | 5 31 84 126 81 | 6 32 85 127 82 | 7 33 86 128 83 | 8 34 87 129 84 | 9 35 88 130 85 | 10 36 89 131 86 | 11 37 90 132 87 | 12 38 91 133 88 | 13 39 92 134 89 | 14 40 93 135 90 | 15 41 94 136 91 | 16 42 95 137 92 | 17 43 96 138 93 | 18 44 73 139 94 | 19 45 74 140 95 | 20 46 75 141 96 | 21 47 76 142 97 | 22 48 77 143 98 | 23 25 78 144 99 | 24 26 79 121 100 | 1 27 80 122 101 | 70 95 113 140 102 | 71 96 114 141 103 | 72 73 115 142 104 | 49 74 116 143 105 | 50 75 117 144 106 | 51 76 118 121 107 | 52 77 119 122 108 | 53 78 120 123 109 | 54 79 97 124 110 | 55 80 98 125 111 | 56 81 99 126 112 | 57 82 100 127 113 | 58 83 101 128 114 | 59 84 102 129 115 | 60 85 103 130 116 | 61 86 104 131 117 | 62 87 105 132 118 | 63 88 106 133 119 | 64 89 107 134 120 | 65 90 108 135 121 | 66 91 109 136 122 | 67 92 110 137 123 | 68 93 111 138 124 | 69 94 112 139 125 | 26 57 79 108 126 | 27 58 80 109 127 | 28 59 81 110 128 | 29 60 82 111 129 | 30 61 83 112 130 | 31 62 84 113 131 | 32 63 85 114 132 | 33 64 86 115 133 | 34 65 87 116 134 | 35 66 88 117 135 | 36 67 89 118 136 | 37 68 90 119 137 | 38 69 91 120 138 | 39 70 92 97 139 | 40 71 93 98 140 | 41 72 94 99 141 | 42 49 95 100 142 | 43 50 96 101 143 | 44 51 73 102 144 | 45 52 74 103 145 | 46 53 75 104 146 | 47 54 76 105 147 | 48 55 77 106 148 | 25 56 78 107 149 | 30 62 86 108 150 | 31 63 87 109 151 | 32 64 88 110 152 | 33 65 89 111 153 | 34 66 90 112 154 | 35 67 91 113 155 | 36 68 92 114 156 | 37 69 93 115 157 | 38 70 94 116 158 | 39 71 95 117 159 | 40 72 96 118 160 | 41 49 73 119 161 | 42 50 74 120 162 | 43 51 75 97 163 | 44 52 76 98 164 | 45 53 77 99 165 | 46 54 78 100 166 | 47 55 79 101 167 | 48 56 80 102 168 | 25 57 81 103 169 | 26 58 82 104 170 | 27 59 83 105 171 | 28 60 84 106 172 | 29 61 85 107 173 | 18 54 81 101 174 | 19 55 82 102 175 | 20 56 83 103 176 | 21 57 84 104 177 | 22 58 85 105 178 | 23 59 86 106 179 | 24 60 87 107 180 | 1 61 88 108 181 | 2 62 89 109 182 | 3 63 90 110 183 | 4 64 91 111 184 | 5 65 92 112 185 | 6 66 93 113 186 | 7 67 94 114 187 | 8 68 95 115 188 | 9 69 96 116 189 | 10 70 73 117 190 | 11 71 74 118 191 | 12 72 75 119 192 | 13 49 76 120 193 | 14 50 77 97 194 | 15 51 78 98 195 | 16 52 79 99 196 | 17 53 80 100 197 | 8 46 98 144 198 | 9 47 99 121 199 | 10 48 100 122 200 | 11 25 101 123 201 | 12 26 102 124 202 | 13 27 103 125 203 | 14 28 104 126 204 | 15 29 105 127 205 | 16 30 106 128 206 | 17 31 107 129 207 | 18 32 108 130 208 | 19 33 109 131 209 | 20 34 110 132 210 | 21 35 111 133 211 | 22 36 112 134 212 | 23 37 113 135 213 | 24 38 114 136 214 | 1 39 115 137 215 | 2 40 116 138 216 | 3 41 117 139 217 | 4 42 118 140 218 | 5 43 119 141 219 | 6 44 120 142 220 | 7 45 97 143 221 | 54 88 116 135 222 | 55 89 117 136 223 | 56 90 118 137 224 | 57 91 119 138 225 | 58 92 120 139 226 | 59 93 97 140 227 | 60 94 98 141 228 | 61 95 99 142 229 | 62 96 100 143 230 | 63 73 101 144 231 | 64 74 102 121 232 | 65 75 103 122 233 | 66 76 104 123 234 | 67 77 105 124 235 | 68 78 106 125 236 | 69 79 107 126 237 | 70 80 108 127 238 | 71 81 109 128 239 | 72 82 110 129 240 | 49 83 111 130 241 | 50 84 112 131 242 | 51 85 113 132 243 | 52 86 114 133 244 | 53 87 115 134 245 | 4 82 120 131 246 | 5 83 97 132 247 | 6 84 98 133 248 | 7 85 99 134 249 | 8 86 100 135 250 | 9 87 101 136 251 | 10 88 102 137 252 | 11 89 103 138 253 | 12 90 104 139 254 | 13 91 105 140 255 | 14 92 106 141 256 | 15 93 107 142 257 | 16 94 108 143 258 | 17 95 109 144 259 | 18 96 110 121 260 | 19 73 111 122 261 | 20 74 112 123 262 | 21 75 113 124 263 | 22 76 114 125 264 | 23 77 115 126 265 | 24 78 116 127 266 | 1 79 117 128 267 | 2 80 118 129 268 | 3 81 119 130 269 | 26 87 109 141 270 | 27 88 110 142 271 | 28 89 111 143 272 | 29 90 112 144 273 | 30 91 113 121 274 | 31 92 114 122 275 | 32 93 115 123 276 | 33 94 116 124 277 | 34 95 117 125 278 | 35 96 118 126 279 | 36 73 119 127 280 | 37 74 120 128 281 | 38 75 97 129 282 | 39 76 98 130 283 | 40 77 99 131 284 | 41 78 100 132 285 | 42 79 101 133 286 | 43 80 102 134 287 | 44 81 103 135 288 | 45 82 104 136 289 | 46 83 105 137 290 | 47 84 106 138 291 | 48 85 107 139 292 | 25 86 108 140 293 | 16 71 115 128 294 | 17 72 116 129 295 | 18 49 117 130 296 | 19 50 118 131 297 | 20 51 119 132 298 | 21 52 120 133 299 | 22 53 97 134 300 | 23 54 98 135 301 | 24 55 99 136 302 | 1 56 100 137 303 | 2 57 101 138 304 | 3 58 102 139 305 | 4 59 103 140 306 | 5 60 104 141 307 | 6 61 105 142 308 | 7 62 106 143 309 | 8 63 107 144 310 | 9 64 108 121 311 | 10 65 109 122 312 | 11 66 110 123 313 | 12 67 111 124 314 | 13 68 112 125 315 | 14 69 113 126 316 | 15 70 114 127 317 | 16 38 99 132 318 | 17 39 100 133 319 | 18 40 101 134 320 | 19 41 102 135 321 | 20 42 103 136 322 | 21 43 104 137 323 | 22 44 105 138 324 | 23 45 106 139 325 | 24 46 107 140 326 | 1 47 108 141 327 | 2 48 109 142 328 | 3 25 110 143 329 | 4 26 111 144 330 | 5 27 112 121 331 | 6 28 113 122 332 | 7 29 114 123 333 | 8 30 115 124 334 | 9 31 116 125 335 | 10 32 117 126 336 | 11 33 118 127 337 | 12 34 119 128 338 | 13 35 120 129 339 | 14 36 97 130 340 | 15 37 98 131 341 | 24 43 68 110 342 | 1 44 69 111 343 | 2 45 70 112 344 | 3 46 71 113 345 | 4 47 72 114 346 | 5 48 49 115 347 | 6 25 50 116 348 | 7 26 51 117 349 | 8 27 52 118 350 | 9 28 53 119 351 | 10 29 54 120 352 | 11 30 55 97 353 | 12 31 56 98 354 | 13 32 57 99 355 | 14 33 58 100 356 | 15 34 59 101 357 | 16 35 60 102 358 | 17 36 61 103 359 | 18 37 62 104 360 | 19 38 63 105 361 | 20 39 64 106 362 | 21 40 65 107 363 | 22 41 66 108 364 | 23 42 67 109 365 | 23 41 60 116 366 | 24 42 61 117 367 | 1 43 62 118 368 | 2 44 63 119 369 | 3 45 64 120 370 | 4 46 65 97 371 | 5 47 66 98 372 | 6 48 67 99 373 | 7 25 68 100 374 | 8 26 69 101 375 | 9 27 70 102 376 | 10 28 71 103 377 | 11 29 72 104 378 | 12 30 49 105 379 | 13 31 50 106 380 | 14 32 51 107 381 | 15 33 52 108 382 | 16 34 53 109 383 | 17 35 54 110 384 | 18 36 55 111 385 | 19 37 56 112 386 | 20 38 57 113 387 | 21 39 58 114 388 | 22 40 59 115 389 | 42 56 74 139 390 | 43 57 75 140 391 | 44 58 76 141 392 | 45 59 77 142 393 | 46 60 78 143 394 | 47 61 79 144 395 | 48 62 80 121 396 | 25 63 81 122 397 | 26 64 82 123 398 | 27 65 83 124 399 | 28 66 84 125 400 | 29 67 85 126 401 | 30 68 86 127 402 | 31 69 87 128 403 | 32 70 88 129 404 | 33 71 89 130 405 | 34 72 90 131 406 | 35 49 91 132 407 | 36 50 92 133 408 | 37 51 93 134 409 | 38 52 94 135 410 | 39 53 95 136 411 | 40 54 96 137 412 | 41 55 73 138 413 | 14 53 89 139 414 | 15 54 90 140 415 | 16 55 91 141 416 | 17 56 92 142 417 | 18 57 93 143 418 | 19 58 94 144 419 | 20 59 95 121 420 | 21 60 96 122 421 | 22 61 73 123 422 | 23 62 74 124 423 | 24 63 75 125 424 | 1 64 76 126 425 | 2 65 77 127 426 | 3 66 78 128 427 | 4 67 79 129 428 | 5 68 80 130 429 | 6 69 81 131 430 | 7 70 82 132 431 | 8 71 83 133 432 | 9 72 84 134 433 | 10 49 85 135 434 | 11 50 86 136 435 | 12 51 87 137 436 | 13 52 88 138 437 | 13 73 133 438 | 14 74 134 439 | 15 75 135 440 | 16 76 136 441 | 17 77 137 442 | 18 78 138 443 | 19 79 139 444 | 20 80 140 445 | 21 81 141 446 | 22 82 142 447 | 23 83 143 448 | 24 84 144 449 | 1 85 121 450 | 2 86 122 451 | 3 87 123 452 | 4 88 124 453 | 5 89 125 454 | 6 90 126 455 | 7 91 127 456 | 8 92 128 457 | 9 93 129 458 | 10 94 130 459 | 11 95 131 460 | 12 96 132 461 | 1 25 462 | 2 26 463 | 3 27 464 | 4 28 465 | 5 29 466 | 6 30 467 | 7 31 468 | 8 32 469 | 9 33 470 | 10 34 471 | 11 35 472 | 12 36 473 | 13 37 474 | 14 38 475 | 15 39 476 | 16 40 477 | 17 41 478 | 18 42 479 | 19 43 480 | 20 44 481 | 21 45 482 | 22 46 483 | 23 47 484 | 24 48 485 | 25 49 486 | 26 50 487 | 27 51 488 | 28 52 489 | 29 53 490 | 30 54 491 | 31 55 492 | 32 56 493 | 33 57 494 | 34 58 495 | 35 59 496 | 36 60 497 | 37 61 498 | 38 62 499 | 39 63 500 | 40 64 501 | 41 65 502 | 42 66 503 | 43 67 504 | 44 68 505 | 45 69 506 | 46 70 507 | 47 71 508 | 48 72 509 | 49 73 510 | 50 74 511 | 51 75 512 | 52 76 513 | 53 77 514 | 54 78 515 | 55 79 516 | 56 80 517 | 57 81 518 | 58 82 519 | 59 83 520 | 60 84 521 | 61 85 522 | 62 86 523 | 63 87 524 | 64 88 525 | 65 89 526 | 66 90 527 | 67 91 528 | 68 92 529 | 69 93 530 | 70 94 531 | 71 95 532 | 72 96 533 | 73 97 534 | 74 98 535 | 75 99 536 | 76 100 537 | 77 101 538 | 78 102 539 | 79 103 540 | 80 104 541 | 81 105 542 | 82 106 543 | 83 107 544 | 84 108 545 | 85 109 546 | 86 110 547 | 87 111 548 | 88 112 549 | 89 113 550 | 90 114 551 | 91 115 552 | 92 116 553 | 93 117 554 | 94 118 555 | 95 119 556 | 96 120 557 | 97 121 558 | 98 122 559 | 99 123 560 | 100 124 561 | 101 125 562 | 102 126 563 | 103 127 564 | 104 128 565 | 105 129 566 | 106 130 567 | 107 131 568 | 108 132 569 | 109 133 570 | 110 134 571 | 111 135 572 | 112 136 573 | 113 137 574 | 114 138 575 | 115 139 576 | 116 140 577 | 117 141 578 | 118 142 579 | 119 143 580 | 120 144 581 | 2 34 49 96 176 210 262 298 322 338 363 420 445 457 582 | 3 35 50 73 177 211 263 299 323 339 364 421 446 458 583 | 4 36 51 74 178 212 264 300 324 340 365 422 447 459 584 | 5 37 52 75 179 213 241 301 325 341 366 423 448 460 585 | 6 38 53 76 180 214 242 302 326 342 367 424 449 461 586 | 7 39 54 77 181 215 243 303 327 343 368 425 450 462 587 | 8 40 55 78 182 216 244 304 328 344 369 426 451 463 588 | 9 41 56 79 183 193 245 305 329 345 370 427 452 464 589 | 10 42 57 80 184 194 246 306 330 346 371 428 453 465 590 | 11 43 58 81 185 195 247 307 331 347 372 429 454 466 591 | 12 44 59 82 186 196 248 308 332 348 373 430 455 467 592 | 13 45 60 83 187 197 249 309 333 349 374 431 456 468 593 | 14 46 61 84 188 198 250 310 334 350 375 432 433 469 594 | 15 47 62 85 189 199 251 311 335 351 376 409 434 470 595 | 16 48 63 86 190 200 252 312 336 352 377 410 435 471 596 | 17 25 64 87 191 201 253 289 313 353 378 411 436 472 597 | 18 26 65 88 192 202 254 290 314 354 379 412 437 473 598 | 19 27 66 89 169 203 255 291 315 355 380 413 438 474 599 | 20 28 67 90 170 204 256 292 316 356 381 414 439 475 600 | 21 29 68 91 171 205 257 293 317 357 382 415 440 476 601 | 22 30 69 92 172 206 258 294 318 358 383 416 441 477 602 | 23 31 70 93 173 207 259 295 319 359 384 417 442 478 603 | 24 32 71 94 174 208 260 296 320 360 361 418 443 479 604 | 1 33 72 95 175 209 261 297 321 337 362 419 444 480 605 | 16 48 53 94 144 164 196 288 324 343 369 392 457 481 606 | 17 25 54 95 121 165 197 265 325 344 370 393 458 482 607 | 18 26 55 96 122 166 198 266 326 345 371 394 459 483 608 | 19 27 56 73 123 167 199 267 327 346 372 395 460 484 609 | 20 28 57 74 124 168 200 268 328 347 373 396 461 485 610 | 21 29 58 75 125 145 201 269 329 348 374 397 462 486 611 | 22 30 59 76 126 146 202 270 330 349 375 398 463 487 612 | 23 31 60 77 127 147 203 271 331 350 376 399 464 488 613 | 24 32 61 78 128 148 204 272 332 351 377 400 465 489 614 | 1 33 62 79 129 149 205 273 333 352 378 401 466 490 615 | 2 34 63 80 130 150 206 274 334 353 379 402 467 491 616 | 3 35 64 81 131 151 207 275 335 354 380 403 468 492 617 | 4 36 65 82 132 152 208 276 336 355 381 404 469 493 618 | 5 37 66 83 133 153 209 277 313 356 382 405 470 494 619 | 6 38 67 84 134 154 210 278 314 357 383 406 471 495 620 | 7 39 68 85 135 155 211 279 315 358 384 407 472 496 621 | 8 40 69 86 136 156 212 280 316 359 361 408 473 497 622 | 9 41 70 87 137 157 213 281 317 360 362 385 474 498 623 | 10 42 71 88 138 158 214 282 318 337 363 386 475 499 624 | 11 43 72 89 139 159 215 283 319 338 364 387 476 500 625 | 12 44 49 90 140 160 216 284 320 339 365 388 477 501 626 | 13 45 50 91 141 161 193 285 321 340 366 389 478 502 627 | 14 46 51 92 142 162 194 286 322 341 367 390 479 503 628 | 15 47 52 93 143 163 195 287 323 342 368 391 480 504 629 | 18 62 100 137 156 188 236 291 342 374 402 429 481 505 630 | 19 63 101 138 157 189 237 292 343 375 403 430 482 506 631 | 20 64 102 139 158 190 238 293 344 376 404 431 483 507 632 | 21 65 103 140 159 191 239 294 345 377 405 432 484 508 633 | 22 66 104 141 160 192 240 295 346 378 406 409 485 509 634 | 23 67 105 142 161 169 217 296 347 379 407 410 486 510 635 | 24 68 106 143 162 170 218 297 348 380 408 411 487 511 636 | 1 69 107 144 163 171 219 298 349 381 385 412 488 512 637 | 2 70 108 121 164 172 220 299 350 382 386 413 489 513 638 | 3 71 109 122 165 173 221 300 351 383 387 414 490 514 639 | 4 72 110 123 166 174 222 301 352 384 388 415 491 515 640 | 5 49 111 124 167 175 223 302 353 361 389 416 492 516 641 | 6 50 112 125 168 176 224 303 354 362 390 417 493 517 642 | 7 51 113 126 145 177 225 304 355 363 391 418 494 518 643 | 8 52 114 127 146 178 226 305 356 364 392 419 495 519 644 | 9 53 115 128 147 179 227 306 357 365 393 420 496 520 645 | 10 54 116 129 148 180 228 307 358 366 394 421 497 521 646 | 11 55 117 130 149 181 229 308 359 367 395 422 498 522 647 | 12 56 118 131 150 182 230 309 360 368 396 423 499 523 648 | 13 57 119 132 151 183 231 310 337 369 397 424 500 524 649 | 14 58 120 133 152 184 232 311 338 370 398 425 501 525 650 | 15 59 97 134 153 185 233 312 339 371 399 426 502 526 651 | 16 60 98 135 154 186 234 289 340 372 400 427 503 527 652 | 17 61 99 136 155 187 235 290 341 373 401 428 504 528 653 | 10 40 89 99 139 156 185 226 256 275 408 417 433 505 529 654 | 11 41 90 100 140 157 186 227 257 276 385 418 434 506 530 655 | 12 42 91 101 141 158 187 228 258 277 386 419 435 507 531 656 | 13 43 92 102 142 159 188 229 259 278 387 420 436 508 532 657 | 14 44 93 103 143 160 189 230 260 279 388 421 437 509 533 658 | 15 45 94 104 144 161 190 231 261 280 389 422 438 510 534 659 | 16 46 95 105 121 162 191 232 262 281 390 423 439 511 535 660 | 17 47 96 106 122 163 192 233 263 282 391 424 440 512 536 661 | 18 48 73 107 123 164 169 234 264 283 392 425 441 513 537 662 | 19 25 74 108 124 165 170 235 241 284 393 426 442 514 538 663 | 20 26 75 109 125 166 171 236 242 285 394 427 443 515 539 664 | 21 27 76 110 126 167 172 237 243 286 395 428 444 516 540 665 | 22 28 77 111 127 168 173 238 244 287 396 429 445 517 541 666 | 23 29 78 112 128 145 174 239 245 288 397 430 446 518 542 667 | 24 30 79 113 129 146 175 240 246 265 398 431 447 519 543 668 | 1 31 80 114 130 147 176 217 247 266 399 432 448 520 544 669 | 2 32 81 115 131 148 177 218 248 267 400 409 449 521 545 670 | 3 33 82 116 132 149 178 219 249 268 401 410 450 522 546 671 | 4 34 83 117 133 150 179 220 250 269 402 411 451 523 547 672 | 5 35 84 118 134 151 180 221 251 270 403 412 452 524 548 673 | 6 36 85 119 135 152 181 222 252 271 404 413 453 525 549 674 | 7 37 86 120 136 153 182 223 253 272 405 414 454 526 550 675 | 8 38 87 97 137 154 183 224 254 273 406 415 455 527 551 676 | 9 39 88 98 138 155 184 225 255 274 407 416 456 528 552 677 | 105 134 158 189 216 222 242 277 295 335 348 366 529 553 678 | 106 135 159 190 193 223 243 278 296 336 349 367 530 554 679 | 107 136 160 191 194 224 244 279 297 313 350 368 531 555 680 | 108 137 161 192 195 225 245 280 298 314 351 369 532 556 681 | 109 138 162 169 196 226 246 281 299 315 352 370 533 557 682 | 110 139 163 170 197 227 247 282 300 316 353 371 534 558 683 | 111 140 164 171 198 228 248 283 301 317 354 372 535 559 684 | 112 141 165 172 199 229 249 284 302 318 355 373 536 560 685 | 113 142 166 173 200 230 250 285 303 319 356 374 537 561 686 | 114 143 167 174 201 231 251 286 304 320 357 375 538 562 687 | 115 144 168 175 202 232 252 287 305 321 358 376 539 563 688 | 116 121 145 176 203 233 253 288 306 322 359 377 540 564 689 | 117 122 146 177 204 234 254 265 307 323 360 378 541 565 690 | 118 123 147 178 205 235 255 266 308 324 337 379 542 566 691 | 119 124 148 179 206 236 256 267 309 325 338 380 543 567 692 | 120 125 149 180 207 237 257 268 310 326 339 381 544 568 693 | 97 126 150 181 208 238 258 269 311 327 340 382 545 569 694 | 98 127 151 182 209 239 259 270 312 328 341 383 546 570 695 | 99 128 152 183 210 240 260 271 289 329 342 384 547 571 696 | 100 129 153 184 211 217 261 272 290 330 343 361 548 572 697 | 101 130 154 185 212 218 262 273 291 331 344 362 549 573 698 | 102 131 155 186 213 219 263 274 292 332 345 363 550 574 699 | 103 132 156 187 214 220 264 275 293 333 346 364 551 575 700 | 104 133 157 188 215 221 241 276 294 334 347 365 552 576 701 | 40 56 95 102 194 227 255 269 306 326 391 415 445 553 702 | 41 57 96 103 195 228 256 270 307 327 392 416 446 554 703 | 42 58 73 104 196 229 257 271 308 328 393 417 447 555 704 | 43 59 74 105 197 230 258 272 309 329 394 418 448 556 705 | 44 60 75 106 198 231 259 273 310 330 395 419 449 557 706 | 45 61 76 107 199 232 260 274 311 331 396 420 450 558 707 | 46 62 77 108 200 233 261 275 312 332 397 421 451 559 708 | 47 63 78 109 201 234 262 276 289 333 398 422 452 560 709 | 48 64 79 110 202 235 263 277 290 334 399 423 453 561 710 | 25 65 80 111 203 236 264 278 291 335 400 424 454 562 711 | 26 66 81 112 204 237 241 279 292 336 401 425 455 563 712 | 27 67 82 113 205 238 242 280 293 313 402 426 456 564 713 | 28 68 83 114 206 239 243 281 294 314 403 427 433 565 714 | 29 69 84 115 207 240 244 282 295 315 404 428 434 566 715 | 30 70 85 116 208 217 245 283 296 316 405 429 435 567 716 | 31 71 86 117 209 218 246 284 297 317 406 430 436 568 717 | 32 72 87 118 210 219 247 285 298 318 407 431 437 569 718 | 33 49 88 119 211 220 248 286 299 319 408 432 438 570 719 | 34 50 89 120 212 221 249 287 300 320 385 409 439 571 720 | 35 51 90 97 213 222 250 288 301 321 386 410 440 572 721 | 36 52 91 98 214 223 251 265 302 322 387 411 441 573 722 | 37 53 92 99 215 224 252 266 303 323 388 412 442 574 723 | 38 54 93 100 216 225 253 267 304 324 389 413 443 575 724 | 39 55 94 101 193 226 254 268 305 325 390 414 444 576 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A-Model-Driven-Deep-Learning-Method-for-Normalized-Min-Sum-LDPC-Decoding 2 | 3 | *(**Paper Link:** https://ieeexplore.ieee.org/abstract/document/9145237)* 4 | 5 | With the applications of deep learning networks booming in physical layer communication, deep-learning-based 6 | channel decoding methods have become a research hotspot. However, the high complexity hinders the application of deep neural network (DNN) on long code. In this paper, we propose a model-driven deep learning method for normalized min-sum (NMS) low-density parity-check (LDPC) decoding. First, we propose a neural normalized min-sum (NNMS) LDPC decoding network. By unfolding the iterative decoding progress between checking nodes (CNs) and variable nodes (VNs) into a feedforward propagation network, we can make use of the advantages of both model-driven deep learning methods and conventional normalized min-sum (CNMS) LDPC decoding method. Second, considering that the NNMS decoder needs large number of multipliers, we propose a shared neural normalized min-sum (SNNMS) decoding network to reduce the number of correction factors. Experimental results show that the BER performance of the proposed NNMS decoder is 1.5dB better than the conventional LDPC decoder, using fewer iterations. Furthermore, the proposed SNNMS decoder outperforms the proposed NNMS decoder and reduces the computation complexity. 7 | 8 | 9 | This repository contains the code for Nerual Normalized Min Sum Network(NNMS) and Shared Neural Normalized Min Sum (SNNMS). 10 | main.py: you can choose two kinds of neural decoder: NNMS and SNNMS. 11 | Generation_matrix.py: load LDPC_576_432.alist and LDPC_576_432.gamt to generate check matrix H and generator matrix G. 12 | 13 | *If you encounter problems during the use of the code, you can contact us through the following email address* 14 | - *wangq@tju.edu.cn* 15 | - *sf_wang@tju.edu.cn* 16 | -------------------------------------------------------------------------------- /generation_matrix.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import tensorflow as tf 3 | 4 | class Code: 5 | def __init__(self): 6 | self.num_edges = 0 7 | # self.n = n 8 | # self.k = k 9 | 10 | def load_code(H_filename, G_filename): 11 | # parity-check matrix; Tanner graph parameters 12 | # H_filename = format('./LDPC_matrix/LDPC_576_432.alist') 13 | # G_filename = format('./LDPC_matrix/LDPC_576_432.gmat') 14 | 15 | 16 | with open(H_filename) as f: 17 | # get n and m (n-k) from first line 18 | n,m = [int(s) for s in f.readline().split(' ')] 19 | k = n-m 20 | ################################################################################################################# 21 | var_degrees = np.zeros(n).astype(np.int) # degree of each variable node 22 | chk_degrees = np.zeros(m).astype(np.int) # degree of each check node 23 | 24 | # initialize H 25 | H = np.zeros([m,n]).astype(np.int) 26 | max_var_degree, max_chk_degree = [int(s) for s in f.readline().split(' ')] 27 | f.readline() # ignore two lines 28 | f.readline() 29 | 30 | # create H, sparse version of H, and edge index matrices 31 | # (edge index matrices used to calculate source and destination nodes during belief propagation) 32 | var_edges = [[] for _ in range(0,n)] 33 | for i in range(0,n): 34 | row_string = f.readline().split(' ') 35 | var_edges[i] = [(int(s)-1) for s in row_string[:-1]] 36 | var_degrees[i] = len(var_edges[i]) 37 | H[var_edges[i], i] = 1 38 | 39 | chk_edges = [[] for _ in range(0,m)] 40 | for i in range(0,m): 41 | row_string = f.readline().split(' ') 42 | chk_edges[i] = [(int(s)-1) for s in row_string[:-1]] 43 | chk_degrees[i] = len(chk_edges[i]) 44 | 45 | # H = np.loadtxt(H_filename).astype(np.int) 46 | # chk_degrees = np.sum(H, axis=1) # assume each check node has the sum degree 47 | # var_degrees = np.sum(H, axis=0) 48 | ################################################################################################################ 49 | d = [[] for _ in range(0,n)] 50 | edge = 0 51 | for i in range(0,n): 52 | for j in range(0,var_degrees[i]): 53 | d[i].append(edge) 54 | edge += 1 55 | 56 | u = [[] for _ in range(0,m)] 57 | edge = 0 58 | for i in range(0,m): 59 | for j in range(0,chk_degrees[i]): 60 | v = chk_edges[i][j] 61 | for e in range(0,var_degrees[v]): 62 | if (i == var_edges[v][e]): 63 | u[i].append(d[v][e]) 64 | 65 | num_edges = H.sum() 66 | 67 | if G_filename == "": 68 | G = [] 69 | else: 70 | #if "BCH" in H_filename: # dear God please fix this 71 | if "LDPC" in H_filename: # dear God please fix this 72 | G = np.loadtxt(G_filename).astype(np.int) 73 | G = G.transpose() 74 | else: 75 | P = np.loadtxt(G_filename,skiprows=2) 76 | G = np.vstack([P.transpose(), np.eye(k)]).astype(np.int) 77 | 78 | code = Code() 79 | code.H = H 80 | code.G = G 81 | code.var_degrees = var_degrees 82 | code.chk_degrees = chk_degrees 83 | code.num_edges = num_edges 84 | code.u = u 85 | code.d = d 86 | code.n = n 87 | code.m = m 88 | code.k = k 89 | return code 90 | 91 | 92 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # Belief propagation using TensorFlow 2 | # Run as follows: 3 | # python main.py 0 0 5 1 100 10000000000000000 10 LDPC_576_432.alist LDPC_576_432.gmat laskdjhf 0/1 100 SNNMS/NNMS 4 | import numpy as np 5 | import tensorflow as tf 6 | import sys 7 | from tensorflow.python.framework import ops 8 | from generation_matrix import load_code 9 | import os 10 | 11 | DEBUG = False 12 | TRAINING = True 13 | SUM_PRODUCT = False 14 | MIN_SUM = not SUM_PRODUCT 15 | #ALL_ZEROS_CODEWORD_TRAINING = False 16 | ALL_ZEROS_CODEWORD_TRAINING = False 17 | ALL_ZEROS_CODEWORD_TESTING = False 18 | 19 | 20 | NO_SIGMA_SCALING_TRAIN = False 21 | NO_SIGMA_SCALING_TEST = False 22 | # NO_SIGMA_SCALING_TRAIN = True 23 | # NO_SIGMA_SCALING_TEST = True 24 | np.set_printoptions(precision=3) 25 | 26 | print("My piD: " + str(os.getpid())) 27 | 28 | if SUM_PRODUCT: 29 | print("Using Sum-Product algorithm") 30 | if MIN_SUM: 31 | print("Using Min-Sum algorithm") 32 | 33 | if ALL_ZEROS_CODEWORD_TRAINING: 34 | print("Training using only the all-zeros codeword") 35 | else: 36 | print("Training using random codewords (not the all-zeros codeword)") 37 | 38 | if ALL_ZEROS_CODEWORD_TESTING: 39 | print("Testing using only the all-zeros codeword") 40 | else: 41 | print("Testing using random codewords (not the all-zeros codeword)") 42 | 43 | if NO_SIGMA_SCALING_TRAIN: 44 | print("Not scaling train input by 2/sigma") 45 | else: 46 | print("Scaling train input by 2/sigma") 47 | 48 | if NO_SIGMA_SCALING_TEST: 49 | print("Not scaling test input by 2/sigma") 50 | else: 51 | print("Scaling test input by 2/sigma") 52 | # python main.py 0 0 5 1 100 10_000_000_000_000_000 5 LDPC_576_432.alist LDPC_576_432.gmat laskdjhf 1 100 SNNMS 53 | # 1 2 3 4 5 6 7 8 9 10 11 12 13 54 | seed = int(sys.argv[1]) 55 | np.random.seed(seed) 56 | snr_lo = float(sys.argv[2]) 57 | snr_hi = float(sys.argv[3]) 58 | snr_step = float(sys.argv[4]) 59 | min_frame_errors = int(sys.argv[5]) 60 | max_frames = float(sys.argv[6]) 61 | num_iterations = int(sys.argv[7]) 62 | H_filename = sys.argv[8] 63 | G_filename = sys.argv[9] 64 | output_filename = sys.argv[10] 65 | L = float(sys.argv[11]) 66 | steps = int(sys.argv[12]) 67 | provided_decoder_type = sys.argv[13] 68 | 69 | if ALL_ZEROS_CODEWORD_TESTING: G_filename = "" 70 | code = load_code(H_filename, G_filename) 71 | 72 | 73 | H = code.H 74 | G = code.G 75 | var_degrees = code.var_degrees 76 | chk_degrees = code.chk_degrees 77 | num_edges = code.num_edges 78 | u = code.u 79 | d = code.d 80 | n = code.n 81 | m = code.m 82 | k = code.k 83 | 84 | class Decoder: 85 | def __init__(self, decoder_type="RNOMS", random_seed=0, learning_rate = 0.001, relaxed = False): 86 | self.decoder_type = decoder_type 87 | self.random_seed = random_seed 88 | self.learning_rate = learning_rate 89 | self.relaxed = relaxed 90 | 91 | # decoder parameters 92 | batch_size = 120#120 93 | tf_train_dataset = tf.placeholder(tf.float32, shape=(n,batch_size)) 94 | tf_train_labels = tf.placeholder(tf.float32, shape=(n,batch_size))#tf.placeholder(tf.float32, shape=(num_iterations,n,batch_size)) 95 | 96 | #### decoder functions #### 97 | 98 | # compute messages from variable nodes to check nodes 99 | def compute_vc(cv, iteration, soft_input): 100 | weighted_soft_input = soft_input 101 | 102 | edges = [] 103 | for i in range(0, n): 104 | for j in range(0, var_degrees[i]): 105 | edges.append(i) 106 | reordered_soft_input = tf.gather(weighted_soft_input, edges) 107 | 108 | vc = [] 109 | edge_order = [] 110 | #if decoder.decoder_type == "NNMS": 111 | # normalizedsecond = tf.nn.softplus(decoder.B_vc[iteration]) 112 | # cv = tf.multiply(cv, tf.tile(tf.reshape(normalizedsecond, [-1, 1]), [1, batch_size])) 113 | for i in range(0, n): # for each variable node v 114 | for j in range(0, var_degrees[i]): 115 | # edge = d[i][j] 116 | edge_order.append(d[i][j]) 117 | extrinsic_edges = [] 118 | for jj in range(0, var_degrees[i]): 119 | if jj != j: # extrinsic information only 120 | extrinsic_edges.append(d[i][jj]) 121 | # if the list of edges is not empty, add them up 122 | if extrinsic_edges: 123 | temp = tf.gather(cv,extrinsic_edges) 124 | #if decoder.decoder_type == "SNNMS": 125 | # normalizedsecond = tf.nn.softplus(decoder.B_vc[iteration]) 126 | # temp = tf.multiply(temp, tf.tile(tf.reshape(normalizedsecond, [-1, 1]), [1, batch_size])) 127 | temp = tf.reduce_sum(temp,0) 128 | else: 129 | temp = tf.zeros([batch_size]) 130 | if SUM_PRODUCT: temp = tf.cast(temp, tf.float32)#tf.cast(temp, tf.float64) 131 | vc.append(temp) 132 | 133 | vc = tf.stack(vc) 134 | new_order = np.zeros(num_edges).astype(np.int) 135 | new_order[edge_order] = np.array(range(0,num_edges)).astype(np.int) 136 | vc = tf.gather(vc,new_order) 137 | vc = vc + reordered_soft_input 138 | return vc 139 | 140 | # compute messages from check nodes to variable nodes 141 | def compute_cv(vc, iteration): 142 | cv_list = [] 143 | prod_list = [] 144 | min_list = [] 145 | 146 | if SUM_PRODUCT: 147 | vc = tf.clip_by_value(vc, -10, 10) 148 | tanh_vc = tf.tanh(vc / 2.0) 149 | edge_order = [] 150 | for i in range(0, m): # for each check node c 151 | for j in range(0, chk_degrees[i]): 152 | # edge = u[i][j] 153 | edge_order.append(u[i][j]) 154 | extrinsic_edges = [] 155 | for jj in range(0, chk_degrees[i]): 156 | if jj != j: 157 | extrinsic_edges.append(u[i][jj]) 158 | if SUM_PRODUCT: 159 | temp = tf.gather(tanh_vc,extrinsic_edges) 160 | temp = tf.reduce_prod(temp,0) 161 | temp = tf.log((1+temp)/(1-temp)) 162 | cv_list.append(temp) 163 | if MIN_SUM: 164 | temp = tf.gather(vc,extrinsic_edges) 165 | temp1 = tf.reduce_prod(tf.sign(temp),0) 166 | temp2 = tf.reduce_min(tf.abs(temp),0) 167 | prod_list.append(temp1) 168 | min_list.append(temp2) 169 | 170 | if SUM_PRODUCT: 171 | cv = tf.stack(cv_list) 172 | if MIN_SUM: 173 | prods = tf.stack(prod_list) 174 | mins = tf.stack(min_list) 175 | if decoder.decoder_type == "SNNMS": 176 | # offsets = tf.nn.softplus(decoder.B_cv[iteration]) # normalized FNOMS 177 | # mins = tf.nn.relu(mins - tf.tile(tf.reshape(offsets,[-1,1]),[1,batch_size])) 178 | # normalized = tf.nn.softplus(decoder.B_cv[iteration]) # add normalized 179 | normalized = tf.nn.softplus(decoder.B_cv[iteration]) # add normalized softplus---> log(1+exp(x)) 180 | mins = tf.multiply(mins, tf.tile(tf.reshape(normalized, [-1, 1]), [1, batch_size])) 181 | elif decoder.decoder_type == "NNMS": 182 | # offsets = tf.nn.softplus(decoder.B_cv[iteration]) 183 | # mins = tf.nn.relu(mins - tf.tile(tf.reshape(offsets,[-1,1]),[1,batch_size])) 184 | # normalized = tf.nn.softplus(decoder.B_cv[iteration]) 185 | normalized = tf.nn.softplus(decoder.B_cv[iteration]) 186 | mins = tf.multiply(mins, tf.tile(tf.reshape(normalized, [-1, 1]), [1, batch_size])) 187 | cv = prods * mins 188 | 189 | new_order = np.zeros(num_edges).astype(np.int) 190 | new_order[edge_order] = np.array(range(0,num_edges)).astype(np.int) 191 | cv = tf.gather(cv,new_order) 192 | 193 | if decoder.decoder_type == "RNSPA" or decoder.decoder_type == "RNNMS": 194 | cv = cv * tf.tile(tf.reshape(decoder.W_cv,[-1,1]),[1,batch_size]) 195 | elif decoder.decoder_type == "FNSPA" or decoder.decoder_type == "FNNMS": 196 | cv = cv * tf.tile(tf.reshape(decoder.W_cv[iteration],[-1,1]),[1,batch_size]) 197 | return cv 198 | 199 | # combine messages to get posterior LLRs 200 | 201 | 202 | def marginalize(soft_input, iteration, cv): 203 | weighted_soft_input = soft_input 204 | 205 | soft_output = [] 206 | for i in range(0,n): 207 | edges = [] 208 | for e in range(0,var_degrees[i]): 209 | edges.append(d[i][e]) 210 | 211 | temp = tf.gather(cv,edges) 212 | temp = tf.reduce_sum(temp,0) 213 | soft_output.append(temp) 214 | 215 | soft_output = tf.stack(soft_output) 216 | 217 | soft_output = weighted_soft_input + soft_output 218 | return soft_output 219 | 220 | def continue_condition(soft_input, soft_output, iteration, cv, m_t, loss, labels): 221 | condition = (iteration < num_iterations) 222 | return condition 223 | 224 | def belief_propagation_iteration(soft_input, soft_output, iteration, cv, m_t, loss, labels): 225 | # compute vc 226 | vc = compute_vc(cv,iteration,soft_input) 227 | 228 | # filter vc 229 | if decoder.relaxed: 230 | m_t = R * m_t + (1-R) * vc 231 | vc_prime = m_t 232 | else: 233 | vc_prime = vc 234 | 235 | # compute cv 236 | cv = compute_cv(vc_prime,iteration) 237 | 238 | # get output for this iteration 239 | soft_output = marginalize(soft_input, iteration, cv) 240 | iteration += 1 241 | 242 | # L = 0.5 243 | print("L = " + str(L)) 244 | CE_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits=-soft_output, labels=labels)) / num_iterations 245 | MSE_loss = tf.reduce_mean(tf.square(soft_output - labels)) / num_iterations 246 | new_loss = L * CE_loss + (1 - L) * MSE_loss 247 | loss = loss + new_loss 248 | 249 | return soft_input, soft_output, iteration, cv, m_t, loss, labels 250 | 251 | # builds a belief propagation TF graph 252 | def belief_propagation_op(soft_input, labels): 253 | return tf.while_loop( 254 | continue_condition, # iteration < max iteration? 255 | belief_propagation_iteration, # compute messages for this iteration 256 | [ 257 | soft_input, # soft input for this iteration 258 | soft_input, # soft output for this iteration 259 | tf.constant(0,dtype=tf.int32), # iteration number 260 | tf.zeros([num_edges,batch_size],dtype=tf.float32), # cv 261 | tf.zeros([num_edges,batch_size],dtype=tf.float32), # m_t 262 | tf.constant(0.0,dtype=tf.float32), # loss 263 | labels 264 | ] 265 | ) 266 | 267 | #### end decoder functions #### 268 | global_step = tf.Variable(0, trainable=False) 269 | starter_learning_rate = 0.001 270 | learning_rate = starter_learning_rate # provided_decoder_type="normal", "FNNMS", "SNNMS", ... 271 | decoder = Decoder(decoder_type=provided_decoder_type, random_seed=1, learning_rate = learning_rate, relaxed = False) 272 | print("\n\nDecoder type: " + decoder.decoder_type + "\n\n") 273 | if decoder.relaxed: print("relaxed") 274 | else: print("not relaxed") 275 | 276 | if SUM_PRODUCT: 277 | if decoder.decoder_type == "FNSPA": 278 | decoder.W_cv = tf.Variable(tf.truncated_normal([num_iterations, num_edges],dtype=tf.float32,stddev=1.0, seed=decoder.random_seed)) 279 | 280 | if decoder.decoder_type == "RNSPA": 281 | decoder.W_cv = tf.Variable(tf.truncated_normal([num_edges],dtype=tf.float32,stddev=1.0, seed=decoder.random_seed))#tf.Variable(0.0,dtype=tf.float32)# 282 | 283 | if MIN_SUM: 284 | 285 | if decoder.decoder_type == "SNNMS": 286 | # SNNMS 287 | # decoder.B_cv = tf.Variable(tf.truncated_normal([num_iterations, num_edges],dtype=tf.float32,stddev=1.0))#tf.Variable(1.0 + tf.truncated_normal([num_iterations, num_edges],dtype=tf.float32,stddev=1.0))#tf.Variable(1.0 + tf.truncated_normal([num_iterations, num_edges],dtype=tf.float32,stddev=1.0/num_edges)) 288 | # decoder.B_vc = tf.Variable(tf.truncated_normal([num_iterations, num_edges],dtype=tf.float32,stddev=1.0))#tf.Variable(1.0 + tf.truncated_normal([num_iterations, num_edges],dtype=tf.float32,stddev=1.0))#tf.Variable(1.0 + tf.truncated_normal([num_iterations, num_edges],dtype=tf.float32,stddev=1.0/num_edges)) 289 | decoder.B_cv = tf.Variable(tf.truncated_normal([num_iterations],dtype=tf.float32,stddev=1.0)) 290 | decoder.B_vc = tf.Variable(tf.truncated_normal([num_iterations], dtype=tf.float32, stddev=1.0)) 291 | 292 | if decoder.decoder_type == "NNMS": 293 | # NNMS 294 | decoder.B_cv = tf.Variable(tf.truncated_normal([num_iterations, num_edges],dtype=tf.float32,stddev=1.0))#tf.Variable(1.0 + tf.truncated_normal([num_iterations, num_edges],dtype=tf.float32,stddev=1.0))#tf.Variable(1.0 + tf.truncated_normal([num_iterations, num_edges],dtype=tf.float32,stddev=1.0/num_edges)) 295 | decoder.B_vc = tf.Variable(tf.truncated_normal([num_iterations, num_edges],dtype=tf.float32,stddev=1.0))#tf.Variable(1.0 + tf.truncated_normal([num_iterations, num_edges],dtype=tf.float32,stddev=1.0))#tf.Variable(1.0 + tf.truncated_normal([num_iterations, num_edges],dtype=tf.float32,stddev=1.0/num_edges)) 296 | #decoder.B_cv = tf.Variable(tf.truncated_normal([num_iterations],dtype=tf.float32,stddev=1.0)) 297 | #decoder.B_vc = tf.Variable(tf.truncated_normal([num_iterations], dtype=tf.float32, stddev=1.0)) 298 | 299 | if decoder.relaxed: 300 | decoder.relaxation_factors = tf.Variable(0.0,dtype=tf.float32) 301 | R = tf.sigmoid(decoder.relaxation_factors) 302 | # print "single learned relaxation factor" 303 | 304 | # decoder.relaxation_factors = tf.Variable(tf.truncated_normal([num_edges],dtype=tf.float32,stddev=1.0)) 305 | # R = tf.tile(tf.reshape(tf.sigmoid(decoder.relaxation_factors),[-1,1]),[1,batch_size]) 306 | # print "multiple relaxation factors" 307 | 308 | #gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=1) 309 | config = tf.ConfigProto( 310 | device_count = {'CPU': 2,'GPU': 0} 311 | ) 312 | with tf.Session(config=config) as session: #tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) as session: 313 | # simulate each SNR 314 | SNRs = np.arange(snr_lo, snr_hi+snr_step, snr_step) 315 | if (batch_size % len(SNRs)) != 0: 316 | print("********************") 317 | print("********************") 318 | print("error: batch size must divide by the number of SNRs to train on") 319 | print("********************") 320 | print("********************") 321 | BERs = [] 322 | SERs = [] 323 | FERs = [] 324 | 325 | print("\nBuilding the decoder graph...") 326 | belief_propagation = belief_propagation_op(soft_input=tf_train_dataset, labels=tf_train_labels) 327 | if TRAINING: 328 | training_loss = belief_propagation[5]#tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits=belief_propagation[1], labels=tf_train_labels)) 329 | loss = training_loss 330 | print("Learning rate: " + str(starter_learning_rate)) 331 | optimizer = tf.train.AdamOptimizer(learning_rate=decoder.learning_rate).minimize(loss,global_step=global_step) 332 | print("Done.\n") 333 | init = tf.global_variables_initializer() 334 | 335 | if ALL_ZEROS_CODEWORD_TRAINING: 336 | codewords = np.zeros([n,batch_size]) 337 | codewords_repeated = np.zeros([num_iterations,n,batch_size]) # repeat for each iteration (multiloss) 338 | BPSK_codewords = np.ones([n,batch_size]) 339 | soft_input = np.zeros_like(BPSK_codewords) 340 | channel_information = np.zeros_like(BPSK_codewords) 341 | 342 | covariance_matrix = np.eye(n) 343 | eta = 0.99 344 | for i in range(0,n): 345 | for j in range(0,n): 346 | covariance_matrix[i,j] = eta**np.abs(i-j) 347 | 348 | session.run(init) 349 | 350 | if TRAINING: 351 | # steps = 10001 352 | print("***********************") 353 | print("Training decoder using " + str(steps) + " minibatches...") 354 | print("***********************") 355 | 356 | step = 0 357 | while step < steps: 358 | # generate random codewords 359 | if not ALL_ZEROS_CODEWORD_TRAINING: 360 | # generate message 361 | messages = np.random.randint(0,2,[k,batch_size]) 362 | 363 | # encode message 364 | codewords = np.dot(G, messages) % 2 365 | #codewords_repeated = np.tile(x,(num_iterations,1,1)).shape 366 | 367 | # modulate codeword 368 | BPSK_codewords = (0.5 - codewords.astype(np.float32)) * 2.0 369 | 370 | soft_input = np.zeros_like(BPSK_codewords) 371 | channel_information = np.zeros_like(BPSK_codewords) 372 | else: 373 | codewords = np.zeros([n,batch_size]) 374 | #codewords_repeated = np.zeros([num_iterations,n,batch_size]) # repeat for each iteration (multiloss) 375 | BPSK_codewords = np.ones([n,batch_size]) 376 | soft_input = np.zeros_like(BPSK_codewords) 377 | channel_information = np.zeros_like(BPSK_codewords) 378 | 379 | # create minibatch with codewords from multiple SNRs 380 | 381 | for i in range(0,len(SNRs)): 382 | 383 | 384 | 385 | sigma = np.sqrt(1. / (2 * (np.float(k)/np.float(n)) * 10**(SNRs[i]/10))) 386 | noise = sigma * np.random.randn(n,batch_size//len(SNRs)) 387 | # noise = sigma * np.random.randn(n, batch_size) 388 | start_idx = batch_size*i//len(SNRs) 389 | end_idx = batch_size*(i+1)//len(SNRs) 390 | channel_information[:,start_idx:end_idx] = BPSK_codewords[:, start_idx:end_idx] + noise 391 | # Whether to use channel estimation as initialization of input 392 | if NO_SIGMA_SCALING_TRAIN: 393 | soft_input[:,start_idx:end_idx] = channel_information[:, start_idx:end_idx] 394 | else: 395 | soft_input[:,start_idx:end_idx] = 2.0*channel_information[:, start_idx:end_idx]/(sigma*sigma) 396 | 397 | 398 | # feed minibatch into BP and run SGD 399 | batch_data = soft_input 400 | batch_labels = codewords #codewords #codewords_repeated 401 | feed_dict = {tf_train_dataset : batch_data, tf_train_labels : batch_labels} 402 | [_] = session.run([optimizer], feed_dict=feed_dict) #,bp_output,syndrome_output,belief_propagation, soft_syndromes 403 | 404 | if decoder.relaxed and TRAINING: 405 | print(session.run(R)) 406 | 407 | if step % 10 == 0: 408 | print(str(step) + " minibatches completed") 409 | 410 | step += 1 411 | 412 | print("Trained decoder on " + str(step) + " minibatches.\n") 413 | 414 | # testing phase 415 | print("***********************") 416 | print("Testing decoder...") 417 | print("***********************") 418 | for SNR in SNRs: 419 | # simulate this SNR 420 | sigma = np.sqrt(1. / (2 * (np.float(k)/np.float(n)) * 10**(SNR/10))) 421 | frame_count = 0 422 | bit_errors = 0 423 | frame_errors = 0 424 | frame_errors_with_HDD = 0 425 | symbol_errors = 0 426 | FE = 0 427 | 428 | # simulate frames 429 | while ((FE < min_frame_errors) or (frame_count < 100000)) and (frame_count < max_frames): 430 | frame_count += batch_size # use different batch size for test phase? 431 | 432 | if not ALL_ZEROS_CODEWORD_TESTING: 433 | # generate message 434 | messages = np.random.randint(0,2,[batch_size,k]) 435 | 436 | # encode message 437 | codewords = np.dot(G, messages.transpose()) % 2 438 | 439 | # modulate codeword 440 | BPSK_codewords = (0.5 - codewords.astype(np.float32)) * 2.0 441 | 442 | # add Gaussian noise to codeword 443 | noise = sigma * np.random.randn(BPSK_codewords.shape[0],BPSK_codewords.shape[1]) 444 | 445 | channel_information = BPSK_codewords + noise 446 | 447 | 448 | # convert channel information to LLR format 449 | if NO_SIGMA_SCALING_TEST: 450 | soft_input = channel_information 451 | else: 452 | soft_input = 2.0*channel_information/(sigma*sigma) 453 | 454 | # run belief propagation 455 | batch_data = soft_input 456 | feed_dict = {tf_train_dataset : batch_data, tf_train_labels : codewords} 457 | soft_outputs = session.run([belief_propagation], feed_dict=feed_dict) 458 | soft_output = np.array(soft_outputs[0][1]) 459 | recovered_codewords = (soft_output < 0).astype(int) 460 | 461 | # update bit error count and frame error count 462 | errors = codewords != recovered_codewords 463 | bit_errors += errors.sum() 464 | frame_errors += (errors.sum(0) > 0).sum() 465 | 466 | FE = frame_errors 467 | 468 | # summarize this SNR: 469 | print("SNR: " + str(SNR)) 470 | print("frame count: " + str(frame_count)) 471 | 472 | bit_count = frame_count * n 473 | BER = np.float(bit_errors) / np.float(bit_count) 474 | BERs.append(BER) 475 | print("bit errors: " + str(bit_errors)) 476 | print("BER: " + str(BER)) 477 | 478 | FER = np.float(frame_errors) / np.float(frame_count) 479 | FERs.append(FER) 480 | print("FER: " + str(FER)) 481 | print("") 482 | 483 | # print summary 484 | print("BERs:") 485 | print(BERs) 486 | print("FERs:") 487 | print(FERs) 488 | 489 | --------------------------------------------------------------------------------