Exemple #1
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 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() }
            };
        }
Exemple #3
0
        public void ShouldFillCombinationsCacheDuringCalculations()
        {
            // Given
            const int n = 4;
            const int k = 3;
            var       combinationsCache = new FieldElement[5][].MakeSquare();

            // When
            _calculator.Calculate(Gf27, n, k, combinationsCache);

            // Then
            Assert.Equal(Gf27.One(), combinationsCache[4][3]);
            Assert.Equal(Gf27.One(), combinationsCache[3][3]);
            Assert.Equal(Gf27.Zero(), combinationsCache[3][2]);
            Assert.Equal(Gf27.One(), combinationsCache[2][2]);
            Assert.Equal(new FieldElement(Gf27, 2), combinationsCache[2][1]);
            Assert.Equal(Gf27.One(), combinationsCache[1][1]);
            Assert.Equal(Gf27.One(), combinationsCache[1][0]);
        }