Managed C++ で作った Fft クラスのラッパー。 FFT の動作の詳細は fft\fft.cpp の方を参照。
Пример #1
0
        /// <summary>
        /// 最小位相を求める。
        /// </summary>
        /// <returns>変換後</returns>
        public double[] GetMinimumPhase()
        {
            int N = this.x.Length / 2;

            double[] tmp = new double[2 * N];
            for (int i = 0; i < N; ++i)
            {
                tmp[2 * i]     = Math.Log(this[i].LinearPower);
                tmp[2 * i + 1] = 0;
            }

            CFft fft = new CFft(2 * N);

            fft.Invert(tmp);

            tmp[0] /= 2; tmp[1] /= 2;
            tmp[N] /= 2; tmp[N + 1] /= 2;
            for (int i = N + 1; i < 2 * N; ++i)
            {
                tmp[i] = 0;
            }

            fft.Transform(tmp);

            double[] y = new double[N];
            for (int i = 0; i < N; ++i)
            {
                y[i] = tmp[2 * i + 1] / N;
            }

            return(y);
        } //HilbertTransform
Пример #2
0
        /// <summary>
        /// x をヒルベルト変換する。
        /// </summary>
        /// <param name="x">変換元</param>
        /// <returns>変換後</returns>
        public static double[] HilbertTransform(double[] x)
        {
            int N = x.Length;

            double[] tmp = new double[2 * N];
            for (int i = 0; i < N; ++i)
            {
                tmp[2 * i]     = x[i];
                tmp[2 * i + 1] = 0;
            }

            CFft fft = new CFft(2 * N);

            fft.Invert(tmp);

            tmp[0] /= 2; tmp[1] /= 2;
            tmp[N] /= 2; tmp[N + 1] /= 2;
            for (int i = N + 1; i < 2 * N; ++i)
            {
                tmp[i] = 0;
            }

            fft.Transform(tmp);

            double[] y = new double[x.Length];
            for (int i = 0; i < N; ++i)
            {
                x[i] = tmp[2 * i] * 2 / N;
                y[i] = tmp[2 * i + 1] * 2 / N;
            }

            return(y);
        }        //HilbertTransform