You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.5 KiB
46 lines
1.5 KiB
#!/usr/bin/env python3 |
|
"""Offline search for LDPC construction seeds, one per lift size. |
|
|
|
For each Z, builds --tries candidate codes and keeps the one whose minimum |
|
weight over all codewords generated by 1 or 2 information bits is largest |
|
(ties: fewer patterns at that weight, then lowest seed). Prints a |
|
SEED_TABLE literal to paste into fec.py. |
|
|
|
./tools/ldpc_search.py --tries 32 |
|
""" |
|
import argparse, os, sys, time |
|
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) |
|
from fec import QCLDPC, Z_SET, low_weight_profile |
|
|
|
|
|
def main(): |
|
ap = argparse.ArgumentParser() |
|
ap.add_argument("--tries", type=int, default=32) |
|
ap.add_argument("--z", type=int, nargs="*", default=list(Z_SET)) |
|
a = ap.parse_args() |
|
|
|
table = {} |
|
t0 = time.time() |
|
for Z in a.z: |
|
best = None |
|
for seed in range(a.tries): |
|
try: |
|
c = QCLDPC(Z, seed=seed) |
|
except RuntimeError: |
|
continue |
|
m, n = low_weight_profile(c) |
|
key = (-m, n, seed) |
|
if best is None or key < best[0]: |
|
best = (key, seed, m) |
|
table[Z] = best[1] |
|
print(f"Z={Z:3d}: seed {best[1]:3d} min weight {best[2]}", file=sys.stderr, flush=True) |
|
print(f"# search: {a.tries} tries per Z, {time.time() - t0:.0f} s", file=sys.stderr) |
|
print("SEED_TABLE = {") |
|
items = list(table.items()) |
|
for i in range(0, len(items), 6): |
|
print(" " + " ".join(f"{z}: {s}," for z, s in items[i:i + 6])) |
|
print("}") |
|
|
|
|
|
if __name__ == "__main__": |
|
main()
|
|
|