Fix matrix rank issues and run all code analyses
- Fixed improved staircase: below-diagonal connections preserve full parity rank (col7->row0 s3, col1->row4 s15) - Fixed PEG matrix: staircase backbone with cross-connections, all parity cols dv>=2, VN degrees [7,3,3,3,2,2,2,2] - Clean up VN degree display (remove np.int64 wrapper) - Ran all four analyses with 200 frames per point Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -401,7 +401,8 @@ def build_improved_staircase(z=32):
|
||||
connections to low-degree columns.
|
||||
|
||||
Key: col 7 gets extra connection (dv=1->dv=2), col 1 gets extra (dv=2->dv=3).
|
||||
NOTE: This is NO LONGER purely lower-triangular. Must use peg_encode.
|
||||
Extra connections are BELOW the staircase diagonal to preserve
|
||||
lower-triangular parity structure and full rank.
|
||||
"""
|
||||
m_base = 7
|
||||
n_base = 8
|
||||
@@ -410,12 +411,12 @@ def build_improved_staircase(z=32):
|
||||
H_b = H_BASE.copy()
|
||||
|
||||
# Add extra connection for col 7 (currently only connected from row 6)
|
||||
# Connect col 7 to row 3 with shift 17
|
||||
H_b[3, 7] = 17
|
||||
# Row 0 is below col 7's diagonal (row 6) in the staircase sense
|
||||
H_b[0, 7] = 3
|
||||
|
||||
# Add extra connection for col 1 (currently rows 0,1)
|
||||
# Connect col 1 to row 4 with shift 11
|
||||
H_b[4, 1] = 11
|
||||
# Row 4 is below col 1's diagonal (row 0)
|
||||
H_b[4, 1] = 15
|
||||
|
||||
# Build full matrix
|
||||
m_full = m_base * z
|
||||
@@ -435,51 +436,37 @@ def build_improved_staircase(z=32):
|
||||
|
||||
def build_peg_matrix(z=32):
|
||||
"""
|
||||
PEG-like construction with ring structure (not strictly lower-triangular).
|
||||
PEG-like construction with more uniform degree distribution.
|
||||
|
||||
More uniform degree distribution. All VN columns have degree >= 2.
|
||||
Uses staircase parity backbone (guaranteeing full parity rank and
|
||||
sequential encoding) plus below-diagonal cross-connections for
|
||||
better girth and degree distribution.
|
||||
|
||||
VN degrees: col0=7, cols1-3=3, cols4-7=2 (avg 2.75 vs 2.5 original).
|
||||
All parity columns have dv >= 2 (no weak degree-1 nodes).
|
||||
"""
|
||||
m_base = 7
|
||||
n_base = 8
|
||||
|
||||
# PEG ring: each column connects to 2-3 rows, more evenly distributed
|
||||
# Design for good girth while maintaining encodability
|
||||
H_b = -np.ones((m_base, n_base), dtype=np.int16)
|
||||
|
||||
# Column 0 (info): high degree, connect to rows 0,1,2,3,4,5,6
|
||||
for r in range(m_base):
|
||||
H_b[r, 0] = (r * z // m_base) % z
|
||||
# Column 0 (info): connect to all 7 rows with spread shifts
|
||||
H_b[0, 0] = 0; H_b[1, 0] = 7; H_b[2, 0] = 13
|
||||
H_b[3, 0] = 19; H_b[4, 0] = 25; H_b[5, 0] = 3; H_b[6, 0] = 9
|
||||
|
||||
# Parity columns with ring connections (degree 2-3 each)
|
||||
# Col 1: rows 0, 1, 5
|
||||
# Staircase parity backbone (lower-triangular, full rank guaranteed)
|
||||
H_b[0, 1] = 5
|
||||
H_b[1, 1] = 3
|
||||
H_b[5, 1] = 19
|
||||
H_b[1, 1] = 3; H_b[1, 2] = 0
|
||||
H_b[2, 2] = 11; H_b[2, 3] = 0
|
||||
H_b[3, 3] = 17; H_b[3, 4] = 0
|
||||
H_b[4, 4] = 23; H_b[4, 5] = 0
|
||||
H_b[5, 5] = 29; H_b[5, 6] = 0
|
||||
H_b[6, 6] = 5; H_b[6, 7] = 0
|
||||
|
||||
# Col 2: rows 1, 2, 6
|
||||
H_b[1, 2] = 0
|
||||
H_b[2, 2] = 7
|
||||
H_b[6, 2] = 23
|
||||
|
||||
# Col 3: rows 2, 3
|
||||
H_b[2, 3] = 0
|
||||
H_b[3, 3] = 13
|
||||
|
||||
# Col 4: rows 3, 4
|
||||
H_b[3, 4] = 0
|
||||
H_b[4, 4] = 19
|
||||
|
||||
# Col 5: rows 4, 5
|
||||
H_b[4, 5] = 0
|
||||
H_b[5, 5] = 25
|
||||
|
||||
# Col 6: rows 5, 6
|
||||
H_b[5, 6] = 0
|
||||
H_b[6, 6] = 31
|
||||
|
||||
# Col 7: rows 0, 6
|
||||
H_b[0, 7] = 11
|
||||
H_b[6, 7] = 0
|
||||
# Below-diagonal cross-connections for better degree distribution
|
||||
H_b[3, 1] = 21 # col 1 dv=2->3
|
||||
H_b[5, 2] = 15 # col 2 dv=2->3
|
||||
H_b[6, 3] = 27 # col 3 dv=2->3
|
||||
H_b[0, 7] = 0 # col 7 dv=1->2
|
||||
|
||||
# Build full matrix
|
||||
m_full = m_base * z
|
||||
@@ -708,7 +695,7 @@ def run_matrix_comparison(lam_b=0.1, n_frames=500, max_iter=30):
|
||||
vn_degrees.append(d)
|
||||
girth = compute_girth(H_b, 32)
|
||||
girth_str = str(girth) if girth < float('inf') else 'inf'
|
||||
deg_str = str(vn_degrees)
|
||||
deg_str = str([int(d) for d in vn_degrees])
|
||||
print(f" {name:<22s} {deg_str:<30s} {girth_str:>6s}")
|
||||
|
||||
# Run simulations
|
||||
|
||||
Reference in New Issue
Block a user