Example #1
0
            /// <summary>
            /// Initialize a complex array using a complex double array (alternating between real and imaginary values)
            /// that has the length of N/2+1.
            /// </summary>
            public ComplexArray(double[] complexArray)
            {
                // make sure to have room for both arrays
                int length = complexArray.Length;

                Handle = FFTW.malloc(Marshal.SizeOf(typeof(double)) * length);
                Marshal.Copy(complexArray, 0, Handle, length);

                // Update length to reflect a N/2+1 input
                Length = length;
            }
Example #2
0
            public DoubleArray(IEnumerable <double> data, Func <int, int, double> window)
            {
                Length = data.Count();
                Handle = FFTW.malloc(Marshal.SizeOf(typeof(double)) * Length);
                var 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);
            }
Example #3
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;
                var 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;
            }
Example #4
0
 public DoubleArray(double[] data)
 {
     Length = data.Length;
     Handle = FFTW.malloc(Marshal.SizeOf(typeof(double)) * Length);
     Marshal.Copy(data, 0, Handle, Length);
 }
Example #5
0
 public DoubleArray(int length)
 {
     Length = length;
     Handle = FFTW.malloc(Marshal.SizeOf(typeof(double)) * Length);
 }