示例#1
0
        private static void AnalyzeSamplesForN26K13D12Code()
        {
            var field = new PrimePowerOrderField(27, new Polynomial(new PrimeOrderField(3), 2, 2, 0, 1));
            var informationPolynomial = new Polynomial(field);
            var encoder = new Encoder();
            var samples = new[]
            {
                new AnalyzingSample(informationPolynomial, encoder.Encode(26, informationPolynomial, informationPolynomial))
                {
                    ErrorPositions     = new[] { 2, 6, 8, 15, 16, 22 },
                    CurrentNoiseValue  = new[] { 1, 1, 12, 12, 4, 3 },
                    CorrectValuesCount = 20
                },
                new AnalyzingSample(informationPolynomial, encoder.Encode(26, informationPolynomial, informationPolynomial))
                {
                    ErrorPositions     = new[] { 0, 1, 2, 3, 4, 5 },
                    CurrentNoiseValue  = new[] { 1, 3, 1, 8, 1, 5 },
                    CorrectValuesCount = 20
                }
            };

            try
            {
                AnalyzeSamples(26, 13, 12,
                               new Polynomial(field, 22, 0, 0, 1, 2, 3, 4, 1, 6, 7, 8, 9, 1, 10, 1, 12, 1, 14, 1, 17, 1, 19, 20, 1, 1, 1),
                               samples);
            }
            catch (Exception exception)
            {
                _logger.LogError(0, exception, "Exception occurred during analysis");
                throw;
            }
        }
示例#2
0
        static GaussSolverTests()
        {
            var gf27 = new PrimePowerOrderField(27, new Polynomial(new PrimeOrderField(3), 2, 2, 0, 1));

            OneSolutionTestsData = new[]
            {
                PrepareTestCaseForOneSolution(gf27, new[, ] {
                    { 1, 1, 1 }, { 1, 2, 1 }, { 1, 1, 2 }
                }, new[] { 3, 5, 6 },
                                              new[] { 1, 2, 3 }),
                PrepareTestCaseForOneSolution(gf27, new[, ] {
                    { 1, 1, 1 }, { 1, 2, 1 }, { 1, 1, 2 }, { 2, 2, 2 }
                },
                                              new[] { 3, 5, 6, 6 }, new[] { 1, 2, 3 })
            };
            EmptySolutionTestsData = new[]
            {
                PrepareTestCaseForEmptySolution(gf27, new[, ] {
                    { 1, 1, 1 }, { 1, 2, 1 }, { 1, 1, 2 }, { 2, 2, 2 }
                },
                                                new[] { 3, 5, 6, 5 })
            };
            InfiniteSolutionTestsData = new[]
            {
                PrepareTestCaseForInfiniteSolution(gf27, new[, ] {
                    { 1, 1, 1 }, { 1, 2, 1 }
                }, new[] { 0, 2 },
                                                   new[] { 0, 2, 1 }),
                PrepareTestCaseForInfiniteSolution(gf27, new[, ] {
                    { 1, 1, 1 }, { 1, 2, 1 }
                }, new[] { 0, 0 },
                                                   new[] { 2, 0, 1 }),
            };
        }
示例#3
0
        private static void AnalyzeSamplesForN80K40D37Code()
        {
            var field = new PrimePowerOrderField(81, new Polynomial(new PrimeOrderField(3), 2, 0, 0, 2, 1));
            var informationPolynomial = new Polynomial(field);
            var encoder = new Encoder();
            var samples = new[]
            {
                new AnalyzingSample(informationPolynomial, encoder.Encode(80, informationPolynomial, informationPolynomial))
                {
                    ErrorPositions     = new[] { 2, 6, 8, 15, 16, 22, 23, 28, 35, 37, 47, 50, 51, 52, 67, 70, 71, 72, 77, 78, 79 },
                    CurrentNoiseValue  = new[] { 1, 1, 6, 4, 4, 14, 7, 3, 8, 23, 76, 1, 5, 8, 2, 6, 2, 14, 45, 64, 13 },
                    CorrectValuesCount = 59
                },
                new AnalyzingSample(informationPolynomial, encoder.Encode(80, informationPolynomial, informationPolynomial))
                {
                    ErrorPositions     = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 },
                    CurrentNoiseValue  = new[] { 1, 1, 6, 4, 4, 14, 7, 3, 8, 23, 76, 1, 5, 8, 2, 6, 2, 14, 45, 64, 13 },
                    CorrectValuesCount = 59
                }
            };

            try
            {
                AnalyzeSamples(80, 40, 37,
                               new Polynomial(field, 0, 0, 0, 50, 2, 3, 45, 1, 6, 7, 8, 9, 19, 10, 1, 80, 1, 14, 1, 17, 1, 19, 20, 1, 1, 1, 55, 77, 42, 11),
                               samples);
            }
            catch (Exception exception)
            {
                _logger.LogError(0, exception, "Exception occurred during analysis");
                throw;
            }
        }
示例#4
0
        private static void AnalyzeSamplesForN31K15D15Code()
        {
            var field = new PrimePowerOrderField(32, new Polynomial(new PrimeOrderField(2), 1, 0, 0, 1, 0, 1));
            var informationPolynomial = new Polynomial(field);
            var encoder = new Encoder();
            var samples = new[]
            {
                new AnalyzingSample(informationPolynomial, encoder.Encode(31, informationPolynomial, informationPolynomial))
                {
                    ErrorPositions     = new[] { 2, 6, 8, 14, 18, 23, 27, 30 },
                    CurrentNoiseValue  = new[] { 1, 1, 12, 12, 26, 21, 9, 6 },
                    CorrectValuesCount = 23
                },
                new AnalyzingSample(informationPolynomial, encoder.Encode(31, informationPolynomial, informationPolynomial))
                {
                    ErrorPositions     = new[] { 0, 1, 2, 3, 4, 5, 6, 7 },
                    CurrentNoiseValue  = new[] { 1, 3, 1, 8, 3, 26, 16, 6 },
                    CorrectValuesCount = 23
                }
            };

            try
            {
                AnalyzeSamples(31, 15, 15,
                               new Polynomial(field, 23, 13, 27, 1, 15, 13, 1, 16, 1, 21, 28, 30, 12, 19, 17, 4, 1, 19, 14, 0, 3, 5, 6),
                               samples);
            }
            catch (Exception exception)
            {
                _logger.LogError(0, exception, "Exception occurred during analysis");
                throw;
            }
        }
示例#5
0
        private static void CalculateSpectrumForWavelet37Code()
        {
            const int informationWordLength = 3;
            const int codeWordLength        = 7;

            var field = new PrimePowerOrderField(8, new Polynomial(new PrimeOrderField(2), 1, 1, 0, 1));
            var m     = new Polynomial(field, 1).RightShift(7);

            m[0] = 1;
            var f = new Polynomial(field, 0, 3, 2, 0, 4, 2, 7);

            CalculateSpectrum(field.Order, informationWordLength, codeWordLength,
                              informatonWord =>
            {
                var informationPolynomial = new Polynomial(field, informatonWord);
                var c = (informationPolynomial.RaiseVariableDegree(2) * f) % m;

                var codeWord = new int[field.Order - 1];
                for (var i = 0; i <= c.Degree; i++)
                {
                    codeWord[i] = c[i];
                }
                return(codeWord);
            });
        }
        static GsBasedDecoderTests()
        {
            var gf7 = new PrimeOrderField(7);
            var generationPolynomial1 = new Polynomial(gf7, 4, 2, 6, 4, 3, 4)
                                        + new Polynomial(gf7, 1, 2, 1, 5, 2, 1).RightShift(2);

            var gf8 = new PrimePowerOrderField(8, new Polynomial(new PrimeOrderField(2), 1, 1, 0, 1));
            var generationPolynomial2 = new Polynomial(gf8, 0, 0, 2, 5, 6, 0, 1);

            var gf9 = new PrimePowerOrderField(9, new Polynomial(new PrimeOrderField(3), 1, 0, 1));
            var generationPolynomial3 = new Polynomial(gf9, 1, 2, 7, 2, 2, 2, 1, 5, 7);

            var gf11 = new PrimeOrderField(11);
            var generationPolynomial4 = new Polynomial(gf11, 0, 0, 7, 3, 4, 1, 8, 1, 8, 2, 7, 5);
            var generationPolynomial5 = new Polynomial(gf11, 0, 0, 2, 0, 10, 9, 3, 9, 3, 10, 2, 2);

            var gf13 = new PrimeOrderField(13);
            var generationPolynomial6 = new Polynomial(gf13, 0, 0, 0, 8, 1, 12, 2, 11, 5, 6, 4, 2, 3, 12, 2, 4);

            var gf16 = new PrimePowerOrderField(16, new Polynomial(new PrimeOrderField(2), 1, 0, 0, 1, 1));
            var generationPolynomial7 = new Polynomial(gf16, 3, 3, 13, 2, 4, 5, 2, 9, 11, 11, 14, 3, 9, 11, 10);

            var gf27 = new PrimePowerOrderField(27, new Polynomial(new PrimeOrderField(3), 2, 2, 0, 1));
            var generationPolynomial8 = new Polynomial(gf27, 0, 0, 20, 18, 14, 15, 2, 5, 2, 19, 17, 4, 23, 1, 8, 6, 5, 4, 20, 26, 6, 5, 16,
                                                       23, 26, 15, 6, 25, 18, 22, 8, 4, 17, 20, 19, 18, 8, 6, 23, 12, 20, 22, 8, 7, 0, 7, 6, 3, 11);

            var gf32 = new PrimePowerOrderField(32, new Polynomial(new PrimeOrderField(2), 1, 0, 0, 1, 0, 1));
            var generationPolynomial9 = new Polynomial(gf32, 6, 27, 1, 17, 13, 28, 18, 23, 15, 12, 3, 8, 5, 28, 1, 5, 29, 17, 18, 10, 12,
                                                       18, 27, 22, 28, 22, 8, 2, 26, 18, 3);
            var generationPolynomial10 = new Polynomial(gf32, 7, 24, 2, 0, 5, 29, 2, 18, 3, 1, 15, 22, 1, 16, 29, 17, 6, 16, 17, 25, 21, 26,
                                                        10, 30, 18, 6, 24, 4, 31, 14, 15);

            var encoder = new Encoder();

            DecoderTestsData = new[]
            {
                PrepareTestData(encoder, 6, 3, 3, generationPolynomial1, new Polynomial(gf7, 4, 0, 2), 1),
                PrepareTestData(encoder, 6, 3, 3, generationPolynomial1, new Polynomial(gf7, 1, 2, 3), 1),
                PrepareTestData(encoder, 6, 3, 3, generationPolynomial1, new Polynomial(gf7, 6, 4, 1), 1),
                PrepareTestData(encoder, 6, 3, 3, generationPolynomial1, new Polynomial(gf7, 0, 2), 1),
                PrepareTestData(encoder, 6, 3, 3, generationPolynomial1, new Polynomial(gf7, 0, 0, 3), 1),
                PrepareTestData(encoder, 7, 3, 4, generationPolynomial2, new Polynomial(gf8, 0, 0, 3), 2),
                PrepareTestData(encoder, 7, 3, 4, generationPolynomial2, new Polynomial(gf8, 1), 2),
                PrepareTestData(encoder, 8, 4, 4, generationPolynomial3, new Polynomial(gf9, 0, 0, 3), 2),
                PrepareTestData(encoder, 8, 4, 4, generationPolynomial3, new Polynomial(gf9, 1, 2, 3, 4), 2),
                PrepareTestData(encoder, 8, 4, 4, generationPolynomial3, new Polynomial(gf9, 1, 2), 2),
                PrepareTestData(encoder, 8, 4, 4, generationPolynomial3, new Polynomial(gf9, 0, 0, 0, 6), 2),
                PrepareTestData(encoder, 10, 5, 6, generationPolynomial4, new Polynomial(gf11, 1, 2, 3, 4, 5), 3),
                PrepareTestData(encoder, 10, 5, 5, generationPolynomial5, new Polynomial(gf11, 1, 2, 3, 4, 5), 2),
                PrepareTestData(encoder, 12, 6, 6, generationPolynomial6, new Polynomial(gf13, 1, 2, 3, 4, 5, 6), 3),
                PrepareTestData(encoder, 12, 6, 6, generationPolynomial6, new Polynomial(gf13, 0, 2, 0, 2, 11), 3),
                PrepareTestData(encoder, 15, 7, 8, generationPolynomial7, new Polynomial(gf16, 1, 2, 14, 2, 11), 4),
                PrepareTestData(encoder, 15, 7, 8, generationPolynomial7, new Polynomial(gf16, 0, 0, 0, 1, 12, 12, 1), 4),
                PrepareTestData(encoder, 26, 13, 12, generationPolynomial8, new Polynomial(gf27, 0, 2, 0, 2, 11), 6),
                PrepareTestData(encoder, 31, 15, 16, generationPolynomial9, new Polynomial(gf32, 19, 2, 7, 2, 12, 23, 26), 8),
                PrepareTestData(encoder, 31, 15, 16, generationPolynomial9, new Polynomial(gf32, 0, 2, 7, 2, 2, 0, 26), 8),
                PrepareTestData(encoder, 31, 15, 16, generationPolynomial9, new Polynomial(gf32, 16, 30, 23), 8),
                PrepareTestData(encoder, 31, 15, 15, generationPolynomial10, new Polynomial(gf32, 19, 2, 7, 2, 12, 30, 11), 8)
            };
        }
        static KotterAlgorithmBasedBuilderTests()
        {
            var gf5  = new PrimeOrderField(5);
            var gf8  = new PrimePowerOrderField(8, new Polynomial(new PrimeOrderField(2), 1, 1, 0, 1));
            var gf27 = new PrimePowerOrderField(27, new Polynomial(new PrimeOrderField(3), 2, 2, 0, 1));

            var degreeWeight = new Tuple <int, int>(1, 2);

            SuccessConstructionTestsData
                = new TheoryData <InterpolationPolynomialBuilderTestCase>
                {
                new InterpolationPolynomialBuilderTestCase
                {
                    DegreeWeight      = degreeWeight,
                    MaxWeightedDegree = 3,
                    Roots             = new[]
                    {
                        Tuple.Create(gf5.One(), gf5.CreateElement(3)),
                        Tuple.Create(gf5.CreateElement(2), gf5.CreateElement(4))
                    }
                },
                new InterpolationPolynomialBuilderTestCase
                {
                    DegreeWeight      = degreeWeight,
                    MaxWeightedDegree = 3,
                    Roots             = new[]
                    {
                        Tuple.Create(gf8.CreateElement(3), gf8.CreateElement(7)),
                        Tuple.Create(gf8.CreateElement(5), gf8.CreateElement(4))
                    }
                },
                new InterpolationPolynomialBuilderTestCase
                {
                    DegreeWeight      = degreeWeight,
                    MaxWeightedDegree = 3,
                    Roots             = new[]
                    {
                        Tuple.Create(gf27.CreateElement(15), gf27.CreateElement(26)),
                        Tuple.Create(gf27.CreateElement(10), gf27.CreateElement(9))
                    }
                }
                };

            FailConstructionTestsData
                = new TheoryData <InterpolationPolynomialBuilderTestCase>
                {
                new InterpolationPolynomialBuilderTestCase
                {
                    DegreeWeight      = degreeWeight,
                    MaxWeightedDegree = 2,
                    Roots             = new[]
                    {
                        Tuple.Create(gf27.One(), gf27.CreateElement(16)),
                        Tuple.Create(gf27.CreateElement(13), gf27.CreateElement(26)),
                        Tuple.Create(gf27.CreateElement(10), gf27.CreateElement(15)),
                        Tuple.Create(gf27.CreateElement(8), gf27.CreateElement(5))
                    }
                }
                };
        }
示例#8
0
        private static void AnalyzeSamplesForN15K7D8Code()
        {
            var field = new PrimePowerOrderField(16, new Polynomial(new PrimeOrderField(2), 1, 0, 0, 1, 1));
            var informationPolynomial = new Polynomial(field);
            var encoder = new Encoder();
            var samples = new[]
            {
                new AnalyzingSample(informationPolynomial, encoder.Encode(15, informationPolynomial, informationPolynomial))
                {
                    ErrorPositions     = new[] { 2, 6, 8, 14 },
                    CurrentNoiseValue  = new[] { 1, 1, 12, 12 },
                    CorrectValuesCount = 11
                },
                new AnalyzingSample(informationPolynomial, encoder.Encode(15, informationPolynomial, informationPolynomial))
                {
                    ErrorPositions     = new[] { 0, 1, 2, 3 },
                    CurrentNoiseValue  = new[] { 1, 3, 1, 8 },
                    CorrectValuesCount = 11
                }
            };

            try
            {
                AnalyzeSamples(15, 7, 8,
                               new Polynomial(field, 3, 2, 7, 6, 4, 2, 11, 7, 5),
                               samples);
            }
            catch (Exception exception)
            {
                _logger.LogError(0, exception, "Exception occurred during analysis");
                throw;
            }
        }
示例#9
0
        static PascalsTriangleBasedCalculatorTests()
        {
            Gf27 = new PrimePowerOrderField(27, new Polynomial(new PrimeOrderField(3), 2, 2, 0, 1));

            CalculatorTestsData
                = new TheoryData <CombinationsCountCalculatorTestCase>
                {
                new CombinationsCountCalculatorTestCase {
                    Field = Gf27, N = 6, K = 3, Expected = Gf27.CreateElement(2)
                },
                new CombinationsCountCalculatorTestCase {
                    Field = Gf27, N = 4, K = 2, Expected = Gf27.Zero()
                },
                new CombinationsCountCalculatorTestCase {
                    Field = Gf27, N = 52, K = 5, Expected = Gf27.Zero()
                },
                new CombinationsCountCalculatorTestCase {
                    Field = Gf27, N = 52, K = 5, Expected = Gf27.Zero()
                },
                new CombinationsCountCalculatorTestCase {
                    Field = Gf27, N = 13, K = 3, Expected = Gf27.One()
                },
                new CombinationsCountCalculatorTestCase {
                    Field = Gf27, N = 13, K = 10, Expected = Gf27.One()
                },
                new CombinationsCountCalculatorTestCase {
                    Field = Gf27, N = 4, K = 3, Expected = Gf27.One()
                }
                };
        }
        static LiftingSchemeBasedBuilderTests()
        {
            var gf8  = new PrimePowerOrderField(8, new Polynomial(new PrimeOrderField(2), 1, 1, 0, 1));
            var gf9  = new PrimePowerOrderField(9, new Polynomial(new PrimeOrderField(3), 1, 0, 1));
            var gf11 = new PrimeOrderField(11);
            var gf13 = new PrimeOrderField(13);
            var gf16 = new PrimePowerOrderField(16, new Polynomial(new PrimeOrderField(2), 1, 0, 0, 1, 1));
            var gf27 = new PrimePowerOrderField(27, new Polynomial(new PrimeOrderField(3), 2, 2, 0, 1));
            var gf32 = new PrimePowerOrderField(32, new Polynomial(new PrimeOrderField(2), 1, 0, 0, 1, 0, 1));

            BuildTestsData =
                new[]
            {
                new object[]
                {
                    7, 3, new Polynomial(gf8, 3, 2, 7, 6, 4, 2)
                },
                new object[]
                {
                    7, 4, new Polynomial(gf8, 3, 2, 7, 6, 4, 2)
                },
                new object[]
                {
                    8, 4, new Polynomial(gf9, 1, 2, 3, 2, 2, 3, 2, 1)
                },
                new object[]
                {
                    10, 6, new Polynomial(gf11, 0, 0, 0, 0, 0, 10, 5, 4, 3, 4)
                },
                new object[]
                {
                    10, 5, new Polynomial(gf11, 0, 0, 0, 0, 0, 10, 5, 4, 3, 4)
                },
                new object[]
                {
                    12, 6, new Polynomial(gf13, 0, 0, 0, 0, 0, 10, 5, 4, 3, 4, 11, 9)
                },
                new object[]
                {
                    15, 7, new Polynomial(gf16, 3, 2, 7, 6, 4, 2, 11, 7, 5)
                },
                new object[]
                {
                    15, 8, new Polynomial(gf16, 3, 2, 7, 6, 4, 2, 11, 7, 5)
                },
                new object[]
                {
                    26, 12, new Polynomial(gf27, 0, 0, 0, 1, 2, 3, 4, 1, 6, 7, 8, 9, 1, 10, 1, 12, 1, 14, 1, 17, 1, 19, 20, 1, 1, 1, 22)
                },
                new object[]
                {
                    31, 16, new Polynomial(gf32, 23, 13, 27, 1, 15, 13, 1, 16, 1, 21, 28, 30, 12, 19, 17, 4, 1, 19, 14, 0, 3, 5, 6)
                },
                new object[]
                {
                    31, 15, new Polynomial(gf32, 23, 13, 27, 1, 15, 13, 1, 16, 1, 21, 28, 30, 12, 19, 17, 4, 1, 19, 14, 0, 3, 5, 6)
                }
            };
        }
示例#11
0
        static LiftingSchemeBasedBuilderTests()
        {
            var gf8  = new PrimePowerOrderField(8, new Polynomial(new PrimeOrderField(2), 1, 1, 0, 1));
            var gf9  = new PrimePowerOrderField(9, new Polynomial(new PrimeOrderField(3), 1, 0, 1));
            var gf11 = new PrimeOrderField(11);
            var gf13 = new PrimeOrderField(13);
            var gf16 = new PrimePowerOrderField(16, new Polynomial(new PrimeOrderField(2), 1, 0, 0, 1, 1));
            var gf27 = new PrimePowerOrderField(27, new Polynomial(new PrimeOrderField(3), 2, 2, 0, 1));
            var gf32 = new PrimePowerOrderField(32, new Polynomial(new PrimeOrderField(2), 1, 0, 0, 1, 0, 1));

            BuildTestsData =
                new TheoryData <GeneratingPolynomialsBuilderTestCase>
            {
                new GeneratingPolynomialsBuilderTestCase
                {
                    N = 7, D = 3, SourceFilter = new Polynomial(gf8, 3, 2, 7, 6, 4, 2)
                },
                new GeneratingPolynomialsBuilderTestCase
                {
                    N = 7, D = 4, SourceFilter = new Polynomial(gf8, 3, 2, 7, 6, 4, 2)
                },
                new GeneratingPolynomialsBuilderTestCase
                {
                    N = 8, D = 4, SourceFilter = new Polynomial(gf9, 1, 2, 3, 2, 2, 3, 2, 1)
                },
                new GeneratingPolynomialsBuilderTestCase
                {
                    N = 10, D = 6, SourceFilter = new Polynomial(gf11, 0, 0, 0, 0, 0, 10, 5, 4, 3, 4)
                },
                new GeneratingPolynomialsBuilderTestCase
                {
                    N = 10, D = 5, SourceFilter = new Polynomial(gf11, 0, 0, 0, 0, 0, 10, 5, 4, 3, 4)
                },
                new GeneratingPolynomialsBuilderTestCase
                {
                    N = 12, D = 6, SourceFilter = new Polynomial(gf13, 0, 0, 0, 0, 0, 10, 5, 4, 3, 4, 11, 9)
                },
                new GeneratingPolynomialsBuilderTestCase
                {
                    N = 15, D = 7, SourceFilter = new Polynomial(gf16, 3, 2, 7, 6, 4, 2, 11, 7, 5)
                },
                new GeneratingPolynomialsBuilderTestCase
                {
                    N = 15, D = 8, SourceFilter = new Polynomial(gf16, 3, 2, 7, 6, 4, 2, 11, 7, 5)
                },
                new GeneratingPolynomialsBuilderTestCase
                {
                    N = 26, D = 12, SourceFilter = new Polynomial(gf27, 0, 0, 0, 1, 2, 3, 4, 1, 6, 7, 8, 9, 1, 10, 1, 12, 1, 14, 1, 17, 1, 19, 20, 1, 1, 1, 22)
                },
                new GeneratingPolynomialsBuilderTestCase
                {
                    N = 31, D = 16, SourceFilter = new Polynomial(gf32, 23, 13, 27, 1, 15, 13, 1, 16, 1, 21, 28, 30, 12, 19, 17, 4, 1, 19, 14, 0, 3, 5, 6)
                },
                new GeneratingPolynomialsBuilderTestCase
                {
                    N = 31, D = 15, SourceFilter = new Polynomial(gf32, 23, 13, 27, 1, 15, 13, 1, 16, 1, 21, 28, 30, 12, 19, 17, 4, 1, 19, 14, 0, 3, 5, 6)
                }
            };
        }
        public void ShouldSumTwoFieldElements(PrimePowerOrderField field, int firstItem, int secondItem, int expected)
        {
            // When
            var actual =  field.Add(firstItem, secondItem);

            //Then
            Assert.Equal(expected, actual);
        }
        public void ShouldDivideTwoFieldElements(PrimePowerOrderField field, int dividend, int divisor, int expected)
        {
            // When
            var actual = field.Divide(dividend, divisor);

            // Then
            Assert.Equal(expected, actual);
        }
        public void ShouldSubtractTwoFieldElements(PrimePowerOrderField field, int minuend, int subtrahend, int expected)
        {
            // When
            var actual = field.Subtract(minuend, subtrahend);

            //Then
            Assert.Equal(expected, actual);
        }
        public void ShouldMultiplyTwoFieldElements(PrimePowerOrderField field, int firstMultiplied, int secondMultiplied, int expected)
        {
            // When
            var actual = field.Multiply(firstMultiplied, secondMultiplied);

            // Then
            Assert.Equal(expected, actual);
        }
        static KotterAlgorithmBasedBuilderTests()
        {
            var gf5  = new PrimeOrderField(5);
            var gf8  = new PrimePowerOrderField(8, new Polynomial(new PrimeOrderField(2), 1, 1, 0, 1));
            var gf27 = new PrimePowerOrderField(27, new Polynomial(new PrimeOrderField(3), 2, 2, 0, 1));

            var degreeWeight = new Tuple <int, int>(1, 2);

            SuccessConstructionTestsData = new[]
            {
                new object[]
                {
                    degreeWeight, 3,
                    new[]
                    {
                        new Tuple <FieldElement, FieldElement>(new FieldElement(gf5, 1), new FieldElement(gf5, 3)),
                        new Tuple <FieldElement, FieldElement>(new FieldElement(gf5, 2), new FieldElement(gf5, 4))
                    }
                },
                new object[]
                {
                    degreeWeight, 3,
                    new[]
                    {
                        new Tuple <FieldElement, FieldElement>(new FieldElement(gf8, 3), new FieldElement(gf8, 7)),
                        new Tuple <FieldElement, FieldElement>(new FieldElement(gf8, 5), new FieldElement(gf8, 4))
                    }
                },
                new object[]
                {
                    degreeWeight, 3,
                    new[]
                    {
                        new Tuple <FieldElement, FieldElement>(new FieldElement(gf27, 15), new FieldElement(gf27, 26)),
                        new Tuple <FieldElement, FieldElement>(new FieldElement(gf27, 10), new FieldElement(gf27, 9))
                    }
                }
            };

            FailConstructionTestsData = new[]
            {
                new object[]
                {
                    degreeWeight, 2,
                    new[]
                    {
                        new Tuple <FieldElement, FieldElement>(new FieldElement(gf27, 1), new FieldElement(gf27, 16)),
                        new Tuple <FieldElement, FieldElement>(new FieldElement(gf27, 13), new FieldElement(gf27, 26)),
                        new Tuple <FieldElement, FieldElement>(new FieldElement(gf27, 10), new FieldElement(gf27, 15)),
                        new Tuple <FieldElement, FieldElement>(new FieldElement(gf27, 8), new FieldElement(gf27, 5))
                    }
                }
            };
        }
        public void ShouldNotPerformDecodeReceivedCodevord()
        {
            // Given
            var       gf9                   = new PrimePowerOrderField(9, new Polynomial(new PrimeOrderField(3), 1, 0, 1));
            const int n                     = 8;
            const int k                     = 5;
            const int errorsCount           = 1;
            var       informationPolynomial = new Polynomial(gf9);
            var       decodedCodeword       = AddRandomNoise(new Encoder().Encode(n, informationPolynomial), errorsCount + 1);

            // When, Then
            Assert.Throws <InformationPolynomialWasNotFoundException>(() => _decoder.Decode(n, k, decodedCodeword, errorsCount));
        }
        static PascalsTriangleBasedCalcualtorTests()
        {
            Gf27 = new PrimePowerOrderField(27, new Polynomial(new PrimeOrderField(3), 2, 2, 0, 1));

            CalculatorTestsData = new[]
            {
                new object[] { Gf27, 6, 3, new FieldElement(Gf27, 2) },
                new object[] { Gf27, 4, 2, Gf27.Zero() },
                new object[] { Gf27, 52, 5, Gf27.Zero() },
                new object[] { Gf27, 52, 5, Gf27.Zero() },
                new object[] { Gf27, 13, 3, Gf27.One() },
                new object[] { Gf27, 13, 10, Gf27.One() },
                new object[] { Gf27, 4, 3, Gf27.One() }
            };
        }
示例#19
0
        static RsBasedDecoderTests()
        {
            var gf7 = new PrimeOrderField(7);
            var generationPolynomial1 = new Polynomial(gf7, 4, 2, 6, 4, 3, 4)
                                        + new Polynomial(gf7, 1, 2, 1, 5, 2, 1).RightShift(2);

            var gf8 = new PrimePowerOrderField(8, new Polynomial(new PrimeOrderField(2), 1, 1, 0, 1));
            var generationPolynomial2 = new Polynomial(gf8, 6, 4, 2, 7, 4, 7, 4);

            var gf9 = new PrimePowerOrderField(9, new Polynomial(new PrimeOrderField(3), 1, 0, 1));
            var generationPolynomial3 = new Polynomial(gf9, 1, 2, 7, 2, 2, 2, 1, 5, 7);

            var gf11 = new PrimeOrderField(11);
            var generationPolynomial4 = new Polynomial(gf11, 0, 0, 7, 3, 4, 1, 8, 1, 8, 2, 7, 5);
            var generationPolynomial5 = new Polynomial(gf11, 0, 0, 2, 0, 10, 9, 3, 9, 3, 10, 2, 2);

            var gf13 = new PrimeOrderField(13);
            var generationPolynomial6 = new Polynomial(gf13, 0, 0, 0, 8, 1, 12, 2, 11, 5, 6, 4, 2, 3, 12, 2, 4);

            var gf27 = new PrimePowerOrderField(27, new Polynomial(new PrimeOrderField(3), 2, 2, 0, 1));
            var generationPolynomial7 = new Polynomial(gf27, 0, 0, 20, 18, 14, 15, 2, 5, 2, 19, 17, 4, 23, 1, 8, 6, 5, 4, 20, 26, 6, 5, 16,
                                                       23, 26, 15, 6, 25, 18, 22, 8, 4, 17, 20, 19, 18, 8, 6, 23, 12, 20, 22, 8, 7, 0, 7, 6, 3, 11);

            var encoder = new Encoder();

            DecoderTestsData
                = new TheoryData <DecoderTestCase>
                {
                PrepareDataWithErrors(6, 3, 3, generationPolynomial1, encoder, new Polynomial(gf7, 4, 0, 2), 1),
                PrepareDataWithErrors(6, 3, 3, generationPolynomial1, encoder, new Polynomial(gf7, 1, 2, 3), 1),
                PrepareDataWithErrors(6, 3, 3, generationPolynomial1, encoder, new Polynomial(gf7, 6, 4, 1), 1),
                PrepareDataWithErrors(6, 3, 3, generationPolynomial1, encoder, new Polynomial(gf7, 0, 2), 1),
                PrepareDataWithErrors(6, 3, 3, generationPolynomial1, encoder, new Polynomial(gf7, 0, 0, 3), 1),
                PrepareDataWithErrors(7, 3, 3, generationPolynomial2, encoder, new Polynomial(gf8, 0, 0, 3), 1),
                PrepareDataWithErrors(7, 3, 3, generationPolynomial2, encoder, new Polynomial(gf8, 1), 1),
                PrepareDataWithErrors(7, 3, 3, generationPolynomial2, encoder, new Polynomial(gf8, 0, 0, 1), 1),
                PrepareDataWithErrors(8, 4, 4, generationPolynomial3, encoder, new Polynomial(gf9, 0, 0, 3), 1),
                PrepareDataWithErrors(8, 4, 4, generationPolynomial3, encoder, new Polynomial(gf9, 1, 2, 3, 4), 1),
                PrepareDataWithErrors(8, 4, 4, generationPolynomial3, encoder, new Polynomial(gf9, 1, 2), 1),
                PrepareDataWithErrors(8, 4, 4, generationPolynomial3, encoder, new Polynomial(gf9, 0, 0, 0, 6), 1),
                PrepareDataWithErrors(10, 5, 6, generationPolynomial4, encoder, new Polynomial(gf11, 1, 2, 3, 4, 5), 2),
                PrepareDataWithErrors(10, 5, 5, generationPolynomial5, encoder, new Polynomial(gf11, 1, 2, 3, 4, 5), 2),
                PrepareDataWithErrors(12, 6, 6, generationPolynomial6, encoder, new Polynomial(gf13, 1, 2, 3, 4, 5, 6), 2),
                PrepareDataWithErrors(12, 6, 6, generationPolynomial6, encoder, new Polynomial(gf13, 0, 2, 0, 2, 11), 2),
                PrepareDataWithErrors(26, 13, 12, generationPolynomial7, encoder, new Polynomial(gf27, 0, 2, 0, 2, 11), 5),
                PrepareDataWithoutErrors(26, 13, 12, generationPolynomial7, encoder, new Polynomial(gf27, 0, 2, 0, 2, 11), 5)
                };
        }
        static BerlekampWelchDecoderTests()
        {
            var gf8     = new PrimePowerOrderField(8, new Polynomial(new PrimeOrderField(2), 1, 1, 0, 1));
            var gf9     = new PrimePowerOrderField(9, new Polynomial(new PrimeOrderField(3), 1, 0, 1));
            var encoder = new Encoder();

            DecoderTestsData = new[]
            {
                PrepareTestsWithErrors(7, 3, encoder, new Polynomial(gf8, 1, 2, 3), 2),
                PrepareTestsWithErrors(7, 3, encoder, new Polynomial(gf8, 7, 4, 1), 2),
                PrepareTestsWithErrors(7, 3, encoder, new Polynomial(gf8, 0, 2), 1),
                PrepareTestsWithErrors(7, 3, encoder, new Polynomial(gf8, 0, 0, 3), 1),
                PrepareTestsWithErrors(8, 5, encoder, new Polynomial(gf9, 0, 0, 3, 1, 1), 1),
                PrepareTestsDataWithoutErrors(8, 5, encoder, new Polynomial(gf9, 0, 0, 3, 1, 1), 1)
            };
        }
示例#21
0
        static GsDecoderTests()
        {
            var gf8     = new PrimePowerOrderField(8, new Polynomial(new PrimeOrderField(2), 1, 1, 0, 1));
            var gf9     = new PrimePowerOrderField(9, new Polynomial(new PrimeOrderField(3), 1, 0, 1));
            var encoder = new Encoder();

            DecoderTestsData = new[]
            {
                PrepareTestsData(7, 3, encoder, new Polynomial(gf8, 1, 2, 3), 2, 3, 6),
                PrepareTestsData(7, 3, encoder, new Polynomial(gf8, 1, 2, 3), 3),
                PrepareTestsData(7, 3, encoder, new Polynomial(gf8, 7, 4, 1), 3),
                PrepareTestsData(7, 3, encoder, new Polynomial(gf8, 0, 2), 3),
                PrepareTestsData(7, 3, encoder, new Polynomial(gf8, 0, 0, 3), 3),
                PrepareTestsData(8, 5, encoder, new Polynomial(gf9, 0, 0, 3, 1, 1), 2)
            };
        }
示例#22
0
        public void ShouldNotPerformDecodeReceivedCodevord()
        {
            // Given
            var gf27 = new PrimePowerOrderField(27, new Polynomial(new PrimeOrderField(3), 2, 2, 0, 1));
            var generationPolynomial = new Polynomial(gf27, 0, 0, 20, 18, 14, 15, 2, 5, 2, 19, 17, 4, 23, 1, 8, 6, 5, 4, 20, 26, 6, 5, 16,
                                                      23, 26, 15, 6, 25, 18, 22, 8, 4, 17, 20, 19, 18, 8, 6, 23, 12, 20, 22, 8, 7, 0, 7, 6, 3, 11);
            const int n                     = 26;
            const int k                     = 13;
            const int d                     = 12;
            const int errorsCount           = 5;
            var       informationPolynomial = new Polynomial(gf27, 0, 2, 0, 2, 11);
            var       decodedCodeword       = AddRandomNoise(new Encoder().Encode(n, generationPolynomial, informationPolynomial), errorsCount + 1);

            // When, Then
            Assert.Throws <InformationPolynomialWasNotFoundException>(() => _decoder.Decode(n, k, d, generationPolynomial, decodedCodeword, errorsCount));
        }
        static PrimePowerOrderFieldTests()
        {
            Gf8 = new PrimePowerOrderField(8, new Polynomial(new PrimeOrderField(2), 1, 1, 0, 1));
            Gf27 = new PrimePowerOrderField(27, new Polynomial(new PrimeOrderField(3), 2, 2, 0, 1));

            IncorrectFieldCreationTestsData = new[]
                                              {
                                                  new object[] {8, null},
                                                  new object[] {8, new Polynomial(new PrimeOrderField(3), 1)},
                                                  new object[] {8, new Polynomial(new PrimeOrderField(2), 1)},
                                                  new object[] {8, new Polynomial(new PrimeOrderField(2), 0, 0, 0, 1)}
                                              };
            SumTestsData = new[]
                            {
                                new object[] {Gf8, 3, 4, 7},
                                new object[] {Gf8, 1, 3, 2},
                                new object[] {Gf8, 1, 6, 7},
                                new object[] {Gf8, 5, 6, 3},
                                new object[] {Gf8, 4, 7, 3},
                                new object[] {Gf8, 5, 5, 0},
                                new object[] {Gf27, 3, 4, 7},
                                new object[] {Gf27, 10, 12, 22},
                                new object[] {Gf27, 11, 10, 18},
                                new object[] {Gf27, 18, 9, 0},
                                new object[] {Gf27, 20, 17, 7},
                                new object[] {Gf27, 9, 21, 3}
                            };
            SubtractTestsData = new[]
                                 {
                                     new object[] {Gf8, 3, 4, 7},
                                     new object[] {Gf8, 1, 3, 2},
                                     new object[] {Gf8, 1, 6, 7},
                                     new object[] {Gf8, 5, 6, 3},
                                     new object[] {Gf8, 4, 7, 3},
                                     new object[] {Gf8, 5, 5, 0},
                                     new object[] {Gf27, 3, 4, 2},
                                     new object[] {Gf27, 10, 12, 7},
                                     new object[] {Gf27, 11, 14, 6},
                                     new object[] {Gf27, 18, 9, 9},
                                     new object[] {Gf27, 20, 17, 12},
                                     new object[] {Gf27, 9, 21, 24}
                                 };
            MultiplyTestsData = new[]
                                 {
                                     new object[] {Gf8, 0, 4, 0},
                                     new object[] {Gf8, 2, 4, 3},
                                     new object[] {Gf8, 3, 4, 7},
                                     new object[] {Gf8, 2, 3, 6},
                                     new object[] {Gf8, 6, 7, 4},
                                     new object[] {Gf8, 2, 7, 5},
                                     new object[] {Gf27, 0, 4, 0},
                                     new object[] {Gf27, 12, 5, 1},
                                     new object[] {Gf27, 3, 4, 12},
                                     new object[] {Gf27, 21, 3, 17},
                                     new object[] {Gf27, 20, 21, 26},
                                     new object[] {Gf27, 2, 7, 5}
                                 };
            DivideTestsData = new[]
                               {
                                   new object[] {Gf8, 0, 3, 0},
                                   new object[] {Gf8, 4, 3, 5},
                                   new object[] {Gf8, 7, 2, 6},
                                   new object[] {Gf8, 2, 7, 3},
                                   new object[] {Gf27, 0, 3, 0},
                                   new object[] {Gf27, 15, 7, 6},
                                   new object[] {Gf27, 11, 26, 14},
                                   new object[] {Gf27, 10, 17, 15},
                                   new object[] {Gf27, 2, 23, 25}
                               };
        }
示例#24
0
        static RrFactorizatorTests()
        {
            var gf19 = new PrimeOrderField(19);
            var gf8  = new PrimePowerOrderField(8, new Polynomial(new PrimeOrderField(2), 1, 1, 0, 1));

            FactorizationTestsData = new[]
            {
                new object[]
                {
                    new BiVariablePolynomial(gf19)
                    {
                        [new Tuple <int, int>(0, 0)] = new FieldElement(gf19, 4),
                        [new Tuple <int, int>(1, 0)] = new FieldElement(gf19, 12),
                        [new Tuple <int, int>(2, 0)] = new FieldElement(gf19, 5),
                        [new Tuple <int, int>(3, 0)] = new FieldElement(gf19, 11),
                        [new Tuple <int, int>(4, 0)] = new FieldElement(gf19, 8),
                        [new Tuple <int, int>(5, 0)] = new FieldElement(gf19, 13),
                        [new Tuple <int, int>(0, 1)] = new FieldElement(gf19, 14),
                        [new Tuple <int, int>(1, 1)] = new FieldElement(gf19, 14),
                        [new Tuple <int, int>(2, 1)] = new FieldElement(gf19, 9),
                        [new Tuple <int, int>(3, 1)] = new FieldElement(gf19, 16),
                        [new Tuple <int, int>(4, 1)] = new FieldElement(gf19, 8),
                        [new Tuple <int, int>(0, 2)] = new FieldElement(gf19, 14),
                        [new Tuple <int, int>(1, 2)] = new FieldElement(gf19, 13),
                        [new Tuple <int, int>(2, 2)] = new FieldElement(gf19, 1),
                        [new Tuple <int, int>(0, 3)] = new FieldElement(gf19, 2),
                        [new Tuple <int, int>(1, 3)] = new FieldElement(gf19, 11),
                        [new Tuple <int, int>(2, 3)] = new FieldElement(gf19, 1),
                        [new Tuple <int, int>(0, 4)] = new FieldElement(gf19, 17)
                    },
                    1,
                    new[]
                    {
                        new Polynomial(gf19, 18, 14),
                        new Polynomial(gf19, 14, 16),
                        new Polynomial(gf19, 8, 8)
                    }
                },
                new object[]
                {
                    new BiVariablePolynomial(gf8)
                    {
                        [new Tuple <int, int>(1, 1)] = gf8.One(),
                        [new Tuple <int, int>(0, 2)] = gf8.One()
                    },
                    1,
                    new []
                    {
                        new Polynomial(gf8),
                        new Polynomial(gf8, 0, 1)
                    }
                },
                new object[]
                {
                    new BiVariablePolynomial(gf8)
                    {
                        [new Tuple <int, int>(2, 1)] = gf8.One(),
                        [new Tuple <int, int>(0, 2)] = gf8.One()
                    },
                    2,
                    new []
                    {
                        new Polynomial(gf8),
                        new Polynomial(gf8, 0, 0, 1)
                    }
                }
            };
        }
 public PolynomialUnderPrimePowerOrderFieldTest()
 {
     _gf8 = new PrimePowerOrderField(8, new Polynomial(new PrimeOrderField(2), 1, 1, 0, 1));
 }
        static PrimePowerOrderFieldTests()
        {
            Gf8  = new PrimePowerOrderField(8, new Polynomial(new PrimeOrderField(2), 1, 1, 0, 1));
            Gf27 = new PrimePowerOrderField(27, new Polynomial(new PrimeOrderField(3), 2, 2, 0, 1));

            IncorrectFieldCreationTestsData
                = new TheoryData <IncorrectFieldCreationTestCase>
                {
                new IncorrectFieldCreationTestCase {
                    FieldOrder = 8
                },
                new IncorrectFieldCreationTestCase
                {
                    FieldOrder            = 8,
                    IrreduciblePolynomial = new Polynomial(new PrimeOrderField(3), 1)
                },
                new IncorrectFieldCreationTestCase
                {
                    FieldOrder            = 8,
                    IrreduciblePolynomial = new Polynomial(new PrimeOrderField(2), 1)
                },
                new IncorrectFieldCreationTestCase
                {
                    FieldOrder            = 8,
                    IrreduciblePolynomial = new Polynomial(new PrimeOrderField(2), 0, 0, 0, 1)
                }
                };

            SumTestsData
                = new TheoryData <BinaryOperationTestCase>
                {
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 3, SecondOperand = 4, Expected = 7
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 1, SecondOperand = 3, Expected = 2
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 1, SecondOperand = 6, Expected = 7
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 5, SecondOperand = 6, Expected = 3
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 4, SecondOperand = 7, Expected = 3
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 5, SecondOperand = 5, Expected = 0
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 3, SecondOperand = 4, Expected = 7
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 10, SecondOperand = 12, Expected = 22
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 11, SecondOperand = 10, Expected = 18
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 18, SecondOperand = 9, Expected = 0
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 20, SecondOperand = 17, Expected = 7
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 9, SecondOperand = 21, Expected = 3
                }
                };
            SubtractTestsData
                = new TheoryData <BinaryOperationTestCase>
                {
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 3, SecondOperand = 4, Expected = 7
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 1, SecondOperand = 3, Expected = 2
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 1, SecondOperand = 6, Expected = 7
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 5, SecondOperand = 6, Expected = 3
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 4, SecondOperand = 7, Expected = 3
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 5, SecondOperand = 5, Expected = 0
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 3, SecondOperand = 4, Expected = 2
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 10, SecondOperand = 12, Expected = 7
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 11, SecondOperand = 14, Expected = 6
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 18, SecondOperand = 9, Expected = 9
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 20, SecondOperand = 17, Expected = 12
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 9, SecondOperand = 21, Expected = 24
                }
                };
            MultiplyTestsData
                = new TheoryData <BinaryOperationTestCase>
                {
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 0, SecondOperand = 4, Expected = 0
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 2, SecondOperand = 4, Expected = 3
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 3, SecondOperand = 4, Expected = 7
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 2, SecondOperand = 3, Expected = 6
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 6, SecondOperand = 7, Expected = 4
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 2, SecondOperand = 7, Expected = 5
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 0, SecondOperand = 4, Expected = 0
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 12, SecondOperand = 5, Expected = 1
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 3, SecondOperand = 4, Expected = 12
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 21, SecondOperand = 3, Expected = 17
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 20, SecondOperand = 21, Expected = 26
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 2, SecondOperand = 7, Expected = 5
                }
                };
            DivideTestsData
                = new TheoryData <BinaryOperationTestCase>
                {
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 0, SecondOperand = 3, Expected = 0
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 4, SecondOperand = 3, Expected = 5
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 7, SecondOperand = 2, Expected = 6
                },
                new BinaryOperationTestCase {
                    Field = Gf8, FirstOperand = 2, SecondOperand = 7, Expected = 3
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 0, SecondOperand = 3, Expected = 0
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 15, SecondOperand = 7, Expected = 6
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 11, SecondOperand = 26, Expected = 14
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 10, SecondOperand = 17, Expected = 15
                },
                new BinaryOperationTestCase {
                    Field = Gf27, FirstOperand = 2, SecondOperand = 23, Expected = 25
                }
                };
        }
        static RrFactorizatorTests()
        {
            var gf19 = new PrimeOrderField(19);
            var gf8  = new PrimePowerOrderField(8, new Polynomial(new PrimeOrderField(2), 1, 1, 0, 1));

            FactorizationTestsData
                = new TheoryData <InterpolationPolynomialFactorizatorTestCase>
                {
                new InterpolationPolynomialFactorizatorTestCase
                {
                    Polynomial = new BiVariablePolynomial(gf19)
                    {
                        [Tuple.Create(0, 0)] = gf19.CreateElement(4),
                        [Tuple.Create(1, 0)] = gf19.CreateElement(12),
                        [Tuple.Create(2, 0)] = gf19.CreateElement(5),
                        [Tuple.Create(3, 0)] = gf19.CreateElement(11),
                        [Tuple.Create(4, 0)] = gf19.CreateElement(8),
                        [Tuple.Create(5, 0)] = gf19.CreateElement(13),
                        [Tuple.Create(0, 1)] = gf19.CreateElement(14),
                        [Tuple.Create(1, 1)] = gf19.CreateElement(14),
                        [Tuple.Create(2, 1)] = gf19.CreateElement(9),
                        [Tuple.Create(3, 1)] = gf19.CreateElement(16),
                        [Tuple.Create(4, 1)] = gf19.CreateElement(8),
                        [Tuple.Create(0, 2)] = gf19.CreateElement(14),
                        [Tuple.Create(1, 2)] = gf19.CreateElement(13),
                        [Tuple.Create(2, 2)] = gf19.CreateElement(1),
                        [Tuple.Create(0, 3)] = gf19.CreateElement(2),
                        [Tuple.Create(1, 3)] = gf19.CreateElement(11),
                        [Tuple.Create(2, 3)] = gf19.CreateElement(1),
                        [Tuple.Create(0, 4)] = gf19.CreateElement(17)
                    },
                    MaxFactorDegree = 1,
                    Expected        = new[]
                    {
                        new Polynomial(gf19, 18, 14),
                        new Polynomial(gf19, 14, 16),
                        new Polynomial(gf19, 8, 8)
                    }
                },
                new InterpolationPolynomialFactorizatorTestCase
                {
                    Polynomial = new BiVariablePolynomial(gf8)
                    {
                        [Tuple.Create(1, 1)] = gf8.One(),
                        [Tuple.Create(0, 2)] = gf8.One()
                    },
                    MaxFactorDegree = 1,
                    Expected        = new[]
                    {
                        new Polynomial(gf8),
                        new Polynomial(gf8, 0, 1)
                    }
                },
                new InterpolationPolynomialFactorizatorTestCase
                {
                    Polynomial = new BiVariablePolynomial(gf8)
                    {
                        [Tuple.Create(2, 1)] = gf8.One(),
                        [Tuple.Create(0, 2)] = gf8.One()
                    },
                    MaxFactorDegree = 2,
                    Expected        = new[]
                    {
                        new Polynomial(gf8),
                        new Polynomial(gf8, 0, 0, 1)
                    }
                }
                };
        }