Esempio n. 1
0
        private void ReorderData()
        {
            int length = viewData.Length;

            int[] reversedBits = FourierHelper.ReverseBits(FourierHelper.Log2(length));
            for (int i = 0; i < length; i++)
            {
                int swap = reversedBits[i];
                if (swap > i)
                {
                    SwapViewData(i, swap);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// The core transformation implementation for one dimension.
        /// </summary>
        /// <param name="forward">Indicates the transformation direction.</param>
        protected override void TransformCore(bool forward)
        {
            int length = viewData.Length;
            int ln     = FourierHelper.Log2(length);

            ReorderData();

            // successive doubling
            int N = 1;

            for (int level = 1; level <= ln; level++)
            {
                int M = N;
                N <<= 1;

                double[] realCosine = FourierHelper.RealCosineCoefficients(level, forward);
                double[] imagSine   = FourierHelper.ImaginarySineCoefficients(level, forward);

                for (int j = 0; j < M; j++)
                {
                    double uR = realCosine[j];
                    double uI = imagSine[j];

                    for (int evenT = j; evenT < length; evenT += N)
                    {
                        int even = evenT << 1;
                        int odd  = (evenT + M) << 1;

                        double r = viewData[odd];
                        double i = viewData[odd + 1];

                        double odduR = r * uR - i * uI;
                        double odduI = r * uI + i * uR;

                        r = viewData[even];
                        i = viewData[even + 1];

                        viewData[even]     = r + odduR;
                        viewData[even + 1] = i + odduI;

                        viewData[odd]     = r - odduR;
                        viewData[odd + 1] = i - odduI;
                    }
                }
            }
        }