Exemple #1
0
        public static void ForwardTransform(FFTW.DoubleArray input, FFTW.ComplexArray output)
        {
            IntPtr plan = FFTW.dft_r2c_1d(input.Length, input.Handle, output.Handle, Flags.Estimate);

            //FFTW.print_plan(plan);
            FFTW.execute(plan);
            FFTW.destroy_plan(plan);
        }
Exemple #2
0
        public static void BackwardTransform(FFTW.ComplexArray input, FFTW.DoubleArray output)
        {
            // TODO: make sure to use input.Length and not the output.Length ?!
            IntPtr plan = FFTW.dft_c2r_1d(input.Length, input.Handle, output.Handle, Flags.Estimate);

            //FFTW.print_plan(plan);
            FFTW.execute(plan);
            FFTW.destroy_plan(plan);
        }
Exemple #3
0
 public DoubleArray(IEnumerable <double> data, Func <int, int, double> window)
 {
     Length = data.Count();
     Handle = FFTW.malloc(Marshal.SizeOf(typeof(double)) * Length);
     double[] buffer = new double[Length];
     for (int i = 0; i < Length; i++)
     {
         buffer[i] = data.ElementAt(i) * window(i, Length);
     }
     Marshal.Copy(buffer, 0, Handle, Length);
 }
Exemple #4
0
            /// <summary>
            /// Initialize a complex array using real and imaginary data
            /// that has the length of N/2+1.
            /// </summary>
            /// <param name="realData">real data</param>
            /// <param name="imagData">imaginary data</param>
            public ComplexArray(double[] realData, double[] imagData)
            {
                if (realData.Length != imagData.Length)
                {
                    throw new ArgumentException(
                              "data length for real data [" + realData.Length + "] is not the same as imaginary data [" + imagData.Length + "]");
                }

                // make sure to have room for both arrays
                int length = realData.Length * 2;

                double[] buffer = new double[length];
                for (int i = 0; i < realData.Length; i++)
                {
                    buffer[2 * i]     = realData[i];
                    buffer[2 * i + 1] = imagData[i];
                }
                Handle = FFTW.malloc(Marshal.SizeOf(typeof(double)) * length);
                Marshal.Copy(buffer, 0, Handle, length);

                // Update length to reflect a N/2+1 input
                Length = (realData.Length - 1) * 2;
            }
Exemple #5
0
 public DoubleArray(double[] data)
 {
     Length = data.Length;
     Handle = FFTW.malloc(Marshal.SizeOf(typeof(double)) * Length);
     Marshal.Copy(data, 0, Handle, Length);
 }
Exemple #6
0
 public DoubleArray(int length)
 {
     Length = length;
     Handle = FFTW.malloc(Marshal.SizeOf(typeof(double)) * Length);
 }