Exemple #1
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 #2
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 #3
0
 public DoubleArray(double[] data)
 {
     Length = data.Length;
     Handle = FFTW.malloc(Marshal.SizeOf(typeof(double)) * Length);
     Marshal.Copy(data, 0, Handle, Length);
 }
Exemple #4
0
 public DoubleArray(int length)
 {
     Length = length;
     Handle = FFTW.malloc(Marshal.SizeOf(typeof(double)) * Length);
 }