Пример #1
0
        public static BigInt operator *(BigInt A, BigInt B)
        {
            Complex[] a, b;
            int       N = 2 << (int)Math.Ceiling(Math.Log(Math.Max(A.s.Length, B.s.Length)) / Math.Log(2));

            a = A.FFT(N);
            b = B.FFT(N);
            for (int i = 0; i < a.Length; i++)
            {
                a[i] *= b[i];
            }

            Fourier.IFFT(ref a);
            BigInt C = new BigInt(0);

            for (int i = 0; i < a.Length - 1; i++)
            {
                C = C * 10 + new BigInt((int)Math.Round(a[i].Real));
            }
            return(C);
        }