feat: add Z=128 support for matrix construction and validation

Make validate_matrix() and run_full_pipeline() accept z parameter
instead of using hardcoded Z=32. Thread cn_mode/alpha to validation.
Add --z/--cn-mode/--alpha CLI options to full pipeline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
cah
2026-02-24 16:49:55 -07:00
parent 30b4d95be2
commit 6bffc6cb5f
2 changed files with 39 additions and 10 deletions

View File

@@ -283,6 +283,31 @@ class TestNormalizedMinSumDE:
)
class TestZ128Support:
"""Tests for Z=128 matrix construction and optimization."""
def test_construct_z128_valid(self):
"""Construct matrix for [7,4,4,4,4,3,3,3] with z=128. Verify full rank, girth >= 6, encodable."""
from density_evolution import construct_base_matrix, verify_matrix
np.random.seed(42)
target = [7, 4, 4, 4, 4, 3, 3, 3]
H_base, girth = construct_base_matrix(target, z=128, n_trials=500)
checks = verify_matrix(H_base, z=128)
assert checks['full_rank'], f"Full rank failed: {checks['actual_rank']}/{checks['expected_rank']}"
assert girth >= 6, f"Girth {girth} should be >= 6"
assert checks['encodable'], "Should be encodable"
def test_validate_z128_runs(self):
"""Run validate_matrix with z=128, n_frames=5 at lam_s=5. Verify returns dict with FER."""
from density_evolution import construct_base_matrix, validate_matrix
np.random.seed(42)
target = [7, 4, 4, 4, 4, 3, 3, 3]
H_base, girth = construct_base_matrix(target, z=128, n_trials=200)
results = validate_matrix(H_base, lam_s_points=[5.0], n_frames=5, lam_b=0.1, z=128)
assert 5.0 in results, f"Expected key 5.0, got {list(results.keys())}"
assert 'fer' in results[5.0]
class TestAlphaOptimization:
"""Tests for alpha sweep optimization."""