Пример #1
0
        private static void DemoDiscreteHamming()
        {
            var config = CodeConfig.Size7_6d_4f;

            var input = 15003.GetBools(14)
                        .Concat(Enumerable.Repeat(false, 6));
            //var input = "11101010011011".ParseBools();

            var encoder = new Encoder(config, terminateCode: false);
            var output  = encoder.Encode(input);

            var viterbi  = Viterbi.CreateWithHammingDistance(config);
            var restored = viterbi.Solve(output);

            Console.WriteLine("Configuration: " + config);
            Console.WriteLine();
            Console.WriteLine("Input:    " + input.Format());
            Console.WriteLine("Encoded:  " + output.Format());
            Console.WriteLine("Restored: " + restored.Message.Format());
            Console.Write($"Score:    {restored.BestEndScore:F2}");
            //if (restored.TerminationStateScore.HasValue)
            Console.Write($" / {restored.TerminationStateScore:F2}");
            Console.WriteLine();
            Console.WriteLine();
        }
Пример #2
0
        public void WorkbookExamples(TestCase testCase)
        {
            var decoder = Viterbi.CreateWithHammingDistance(testCase.Config);
            var res     = decoder.Solve(testCase.Input.ParseBools());


            var expected = testCase.Expected.ParseBools();

            output.WriteLine("Result:   " + res.Message.Format());
            output.WriteLine("Expected: " + expected.Format());

            res.Message.ShouldBe(expected);
        }
Пример #3
0
        public void Setup()
        {
            var config = CodeConfig.Size7_6d_4f;

            var input =
                15003.GetBools(14)
                .Concat(Enumerable.Repeat(false, 6));

            var encoder = new Encoder(config, terminateCode: true);

            encoded = encoder.Encode(input);

            viterbi = Viterbi.CreateWithHammingDistance(config);
        }