Пример #1
0
        public Code GetCodeAlgorithm(string name, int n)
        {
            Code result = null;

            switch (name)
            {
            case "Repetition code":
                result = new RepetitionCode(n);
                break;

            case "Even parity code":
                result = new EvenParity();
                break;

            case "Rectangular code":
                result = new RectangularCode(n);
                break;

            case "Triangular code":
                result = new TriangularCode(n);
                break;
            }

            return(result);
        }
Пример #2
0
        public TableAdjacentClasses(int n, int k)
        {
            binaryArythmetic = new BinaryArythmetic();
            EvenParity evenParity = new EvenParity();

            table = new string[(int)Math.Pow(2, k), (int)Math.Pow(2, n - k)];
            List <string> allCombinationForK = binaryArythmetic.GenerateAllBinaryByLength(k);
            List <string> allCombinationForN = binaryArythmetic.GenerateAllBinaryByLength(n);

            for (int j = 0; j < table.GetLength(1); ++j)
            {
                string value = allCombinationForK[j];
                while (value.Length < n)
                {
                    value += evenParity.GetEven(value);
                }
                table[0, j] = value;
                allCombinationForN.RemoveAt(allCombinationForN.IndexOf(value));
            }
            for (int i = 1; i < table.GetLength(0); ++i)
            {
                table[i, 0] = GetElementWithMinWeight(allCombinationForN);
                allCombinationForN.RemoveAt(allCombinationForN.IndexOf(table[i, 0]));
                for (int j = 1; j < table.GetLength(1); ++j)
                {
                    string element = binaryArythmetic.Xor(table[0, j], table[i, 0]);
                    table[i, j] = element;
                    allCombinationForN.RemoveAt(allCombinationForN.IndexOf(element));
                }
            }
        }
Пример #3
0
 public RectangularCode(int n)
 {
     rowLength  = n;
     blockSize  = n * n;
     evenParity = new EvenParity();
 }
Пример #4
0
 public TriangularCode(int n)
 {
     maxBlockLength = n;
     evenParity     = new EvenParity();
 }