public void testMult() { IntegerPolynomial i1 = new IntegerPolynomial(new int[] { 1368, 2047, 672, 871, 1662, 1352, 1099, 1608 }); IntegerPolynomial i2 = new IntegerPolynomial(new int[] { 1729, 1924, 806, 179, 1530, 1381, 1695, 60 }); LongPolynomial2 a = new LongPolynomial2(i1); LongPolynomial2 b = new LongPolynomial2(i2); IntegerPolynomial c1 = i1.Multiply(i2, 2048); IntegerPolynomial c2 = a.Multiply(b).ToIntegerPolynomial(); Assert.True(c1.coeffs.SequenceEqual(c2.coeffs)); SecureRandom rng = new SecureRandom(); for (int i = 0; i < 10; i++) { int N = 2 + rng.NextInt(2000); i1 = PolynomialGenerator.GenerateRandom(N, 2048); i2 = PolynomialGenerator.GenerateRandom(N, 2048); a = new LongPolynomial2(i1); b = new LongPolynomial2(i2); c1 = i1.Multiply(i2); c1.ModPositive(2048); c2 = a.Multiply(b).ToIntegerPolynomial(); Assert.True(c1.coeffs.SequenceEqual(c2.coeffs)); } }
public void testMult() { ProductFormPolynomial p1 = ProductFormPolynomial.GenerateRandom(N, df1, df2, df3, df3 - 1, new SecureRandom()); IntegerPolynomial p2 = PolynomialGenerator.GenerateRandom(N, q); IntegerPolynomial p3 = p1.Multiply(p2); IntegerPolynomial p4 = p1.ToIntegerPolynomial().Multiply(p2); Assert.AreEqual(p3.ToIntegerPolynomial().coeffs, p4.ToIntegerPolynomial().coeffs); }