Ejemplo n.º 1
0
        private static void validateFFT(int N, double[] x)
        {
            const double EPS = 1.0e-10;

            if (FFT.test(x) / N > EPS)
            {
                throw new Exception("FFT failed to validate");
            }
        }
Ejemplo n.º 2
0
        public static double measureFFT(int N, double mintime, Random R)
        {
            double[]  data      = kernel.RandomVector(checked (2 * N), R);
            long      num1      = 20000;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.start();
            int num2 = 0;

            while ((long)num2 < num1)
            {
                FFT.transform(data);
                FFT.inverse(data);
                checked { ++num2; }
            }
            stopwatch.stop();
            if (FFT.test(data) / (double)N > 0.0 / 1.0)
            {
                return(0.0);
            }
            return(FFT.num_flops(N) * (double)num1 / stopwatch.read() * 1E-06);
        }
Ejemplo n.º 3
0
        // each measurement returns approx Mflops
        public static double measureFFT(int N, double mintime, Random R)
        {
            // initialize FFT data as complex (N real/img pairs)

            double[] x = RandomVector(2 * N, R);
            //double oldx[] = NewVectorCopy(x);
            long      cycles = 1;
            Stopwatch clock  = new Stopwatch();

            while (true)
            {
                clock.Start();
                for (int i = 0; i < cycles; i++)
                {
                    FFT.transform(x);                   // forward transform
                    FFT.inverse(x);                     // backward transform
                }
                clock.Stop();
                if (clock.Elapsed.TotalSeconds >= mintime)
                {
                    break;
                }

                cycles *= 2;
            }
            // approx Mflops

            const double EPS = 1.0e-10;

            if (FFT.test(x) / N > EPS)
            {
                return(0.0);
            }

            return(FFT.num_flops(N) * cycles / clock.Elapsed.TotalMilliseconds * 1.0e-3);
        }