public override BitNumber Decode(BitNumber codeWord) { BitNumber result = null; if (isPossibleBuildTriangular(codeWord.Length)) { int diagonalSize = getLengthDiagonal(codeWord.Length); BitNumber[] triangle = messageToTriangle(codeWord); //Создаём исходную матрицу (если не было ошибки) BitNumber[] sourceTriange = new BitNumber[triangle.Length - 1]; Array.Copy(triangle, sourceTriange, sourceTriange.Length); for (int i = 0; i < sourceTriange.Length; i++) { sourceTriange[i].Length--; } BitNumber maybeCodeWord = Generate(BitNumber.Split(sourceTriange)); if (codeWord.Equals(maybeCodeWord)) { result = BitNumber.Split(sourceTriange); } else //возникла ошибка { } } else { throw new ImpossibleBuildTriangularException("Impossible build triangular!"); } return result; }
public BitNumber Decode(BitNumber message, BitNumber[][] tableAdjacentClasses) { for (int i = 0; i < tableAdjacentClasses.GetLength(0); i++) { for (int j = 0; j < tableAdjacentClasses.GetLength(i); j++) { if (message.Equals(tableAdjacentClasses[i][j])) { return message ^ tableAdjacentClasses[i][0]; } } } return null; }