public void Convolution() { const long p1 = 998244353, g1 = 3; const long p2 = 1107296257, g2 = 10; var fntt1 = new FNTT202(8, p1, g1); var fntt2 = new FNTT202(8, p2, g2); var a = new long[] { 1000000, 1000000, 1000000 }; var b = new long[] { 1000000, 1000000, 1000000, 1000000 }; var c1 = fntt1.Convolution(a, b); var c2 = fntt2.Convolution(a, b); var crt = new CRT(p1, p2); var c = c1.Zip(c2, (x, y) => crt.Solve(x, y)).ToArray(); var expected = new long[] { 1000000000000, 2000000000000, 3000000000000, 3000000000000, 2000000000000, 1000000000000, 0, 0 }; CollectionAssert.AreEqual(expected, c); }
public void Transform_FNTT202() { var ntt = new FNTT202(n); Test(f => ntt.Transform(f, false), f => ntt.Transform(f, true)); }
public void Convolution_FNTT202() { var ntt = new FNTT202(n << 1); Test(ntt.Convolution); }