encode($referenceDataCodewords, $ecCodewords); echo "EC codewords (from reference data): " . implode(', ', $referenceEC) . "\n\n"; // Test RS encoding with our data codewords $ourEC = $rs->encode($ourDataCodewords, $ecCodewords); echo "EC codewords (from our data): " . implode(', ', $ourEC) . "\n\n"; // Verify both with decoder require_once __DIR__ . '/test-reed-solomon-decoder.php'; $decoder = new SimpleRSDecoder(); // Test reference $fullReference = array_merge($referenceDataCodewords, $referenceEC); $syndromesRef = $decoder->calculateSyndromes($fullReference, $ecCodewords); echo "Reference syndromes: " . implode(', ', $syndromesRef) . "\n"; $allZeroRef = true; foreach ($syndromesRef as $s) { if ($s !== 0) { $allZeroRef = false; break; } } echo ($allZeroRef ? "✅" : "❌") . " Reference codewords are " . ($allZeroRef ? "valid" : "invalid") . "\n\n"; // Test ours $fullOurs = array_merge($ourDataCodewords, $ourEC); $syndromesOurs = $decoder->calculateSyndromes($fullOurs, $ecCodewords); echo "Our syndromes: " . implode(', ', $syndromesOurs) . "\n"; $allZeroOurs = true; foreach ($syndromesOurs as $s) { if ($s !== 0) { $allZeroOurs = false; break; } } echo ($allZeroOurs ? "✅" : "❌") . " Our codewords are " . ($allZeroOurs ? "valid" : "invalid") . "\n\n"; // Now try to find expected EC codewords from known sources echo "=== Finding Expected EC Codewords ===\n"; echo "If we can find a working QR code generator or reference implementation,\n"; echo "we can compare our EC codewords with the expected ones.\n\n"; // Known EC codewords from QR code specification for "HELLO WORLD" // These are from the ISO/IEC 18004 specification example // But we need to verify if our data codewords match first // The issue is: our data codewords don't match the reference! // This means the problem is in the encoding step, not Reed-Solomon. // But let's still test if RS works correctly with correct input.