Beispiel #1
0
 private static void innerFFT(double[] x, long Iterations)
 {
     for (int i = 0; i < Iterations; i++)
     {
         FFT.transform(x); // forward transform
         FFT.inverse(x);   // backward transform
     }
 }
Beispiel #2
0
        public static double test(double[] data)
        {
            int length = data.Length;

            double[] numArray = new double[length];
            Array.Copy((Array)data, 0, (Array)numArray, 0, length);
            FFT.transform(data);
            FFT.inverse(data);
            double num1  = 0.0;
            int    index = 0;

            while (index < length)
            {
                double num2 = data[index] - numArray[index];
                num1 += num2 * num2;
                checked { ++index; }
            }
            return(Math.Sqrt(num1 / (double)length));
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }