public ReedSolomonCode(GaloisField galoisField, IParityCheckMatrixGenerator parityCheckMatrixGenerator) { GaloisField = galoisField; while (true) { ParityCheckMatrix = parityCheckMatrixGenerator.Generate(this); Debug.WriteLine(ParityCheckMatrix); if (Helper.Weight(ParityCheckMatrix) < Math.Ceiling(ParityCheckMatrix.RowCount * ParityCheckMatrix.ColumnCount * 0.7)) { continue; } try { GeneratorMatrix = GeneratorMatrixCalculator.CalculateGeneratorMatrix(this); Debug.WriteLine(GeneratorMatrix); } catch (LinearCodeException ex) { Debug.WriteLine(ex.Message); continue; } if (IsGeneratorMatrixValid(ParityCheckMatrix, GeneratorMatrix, GaloisField)) { break; } } }
public ReedSolomonCode(GaloisField galoisField, MatrixInt parityCheckMatrix) { GaloisField = galoisField; ParityCheckMatrix = parityCheckMatrix; GeneratorMatrix = GeneratorMatrixCalculator.CalculateGeneratorMatrix(this); if (!IsGeneratorMatrixValid(ParityCheckMatrix, GeneratorMatrix, GaloisField)) { throw new LinearCodeException("Could not produce correct Generator matrix from provided ParityCheck matrix."); } }