当前位置: 首页>>代码示例>>C#>>正文


C# Complex.Clone方法代码示例

本文整理汇总了C#中Complex.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Complex.Clone方法的具体用法?C# Complex.Clone怎么用?C# Complex.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Complex的用法示例。


在下文中一共展示了Complex.Clone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ComputeSpectrum

        public Complex[] ComputeSpectrum(Complex[] srcData)
        {
            var data = srcData.Clone() as Complex[];
            ComputeSpectrumInPlace(data);

            return data;
        }
开发者ID:imazepov,项目名称:ITuner,代码行数:7,代码来源:Fft.cs

示例2: fft2d

 public static Complex[,] fft2d(Complex[,] input)
 {
     Complex[,] output = (Complex[,])input.Clone();
     // Rows first:
     Complex[] x = new Complex[output.GetLength(1)];
     for (int h = 0; h < output.GetLength(0); h++)
     {
         for (int i = 0; i < output.GetLength(1); i++)
         {
             x[i] = output[h, i];
         }
         x = fft(x);
         for (int i = 0; i < output.GetLength(1); i++)
         {
             output[h, i] = x[i];
         }
     }
     //Columns last
     Complex[] y = new Complex[output.GetLength(0)];
     for (int h = 0; h < output.GetLength(1); h++)
     {
         for (int i = 0; i < output.GetLength(0); i++)
         {
             y[i] = output[i, h];
         }
         y = fft(y);
         for (int i = 0; i < output.GetLength(0); i++)
         {
             output[i, h] = y[i];
         }
     }
     return output;
 }
开发者ID:opentibia,项目名称:item-editor,代码行数:33,代码来源:Fourier.cs

示例3: FHT

        /// <summary>
        ///   Performs the Fast Hilbert Transform over a complex[] array.
        /// </summary>
        /// 
        public static void FHT(Complex[] data, FourierTransform.Direction direction)
        {
            int N = data.Length;

            // Forward operation
            if (direction == FourierTransform.Direction.Forward)
            {
                // Makes a copy of the data so we don't lose the
                //  original information to build our final signal
                Complex[] shift = (Complex[])data.Clone();

                // Perform FFT
                FourierTransform.FFT(shift, FourierTransform.Direction.Backward);

                //double positive frequencies
                for (int i = 1; i < (N / 2); i++)
                {
                    shift[i] *= 2.0;
                }
                // zero out negative frequencies
                //  (leaving out the dc component)
                for (int i = (N / 2) + 1; i < N; i++)
                {
                    shift[i] = Complex.Zero;
                }

                // Reverse the FFT
                FourierTransform.FFT(shift, FourierTransform.Direction.Forward);

                // Put the Hilbert transform in the Imaginary part
                //  of the input signal, creating a Analytic Signal
                for (int i = 0; i < N; i++)
                    data[i] = new Complex(data[i].Real, shift[i].Imaginary);
            }

            else // Backward operation
            {
                // Just discard the imaginary part
                for (int i = 0; i < data.Length; i++)
                    data[i] = new Complex(data[i].Real, 0.0);
            }
        }
开发者ID:CanerPatir,项目名称:framework,代码行数:46,代码来源:HilbertTransform.cs

示例4: Clean

        /// <summary>
        /// Removes unnecessary zero terms.
        /// </summary>
        public void Clean()
        {
            int i;

            for (i = Degree; i >= 0 && Coefficients[i] == 0; i--) ;

            Complex[] coeffs = new Complex[i + 1];

            for (int k = 0; k <= i; k++)
                coeffs[k] = Coefficients[k];

            Coefficients = (Complex[])coeffs.Clone();
        }
开发者ID:patrick-huyphan,项目名称:fuzzyDemo,代码行数:16,代码来源:Polynomial.cs

示例5: fft_frequency

        /// <summary>
        /// 一维频率抽取基2快速傅里叶变换
        /// 频率抽取:输入为自然顺序,输出为码位倒置顺序
        /// 基2:待变换的序列长度必须为2的整数次幂
        /// </summary>
        /// <param name="sourceData">待变换的序列(复数数组)</param>
        /// <param name="countN">序列长度,可以指定[0,sourceData.Length-1]区间内的任意数值</param>
        /// <returns>返回变换后的序列(复数数组)</returns>
        private Complex[] fft_frequency(Complex[] sourceData, int countN)
        {
            if (countN == 0)
                return null;
            if (sourceData == null)
                return null;

            //2的r次幂为N,求出r.r能代表fft算法的迭代次数
            double dr = Math.Log(countN, 2);
            //int r = Convert.ToInt32(dr);
            int r = (int)Math.Ceiling(dr);   //向上取整
            Complex[] resultData = new Complex[sourceData.Length];

            if (dr - r != 0)
            {
                countN = (int)Math.Pow(2, r);
            }

            //分别存储蝶形运算过程中左右两列的结果
            Complex[] interVar1 = new Complex[countN];
            Complex[] interVar2 = new Complex[countN];

            //interVar1 = (Complex[])sourceData.Clone();
            int index = 0;
            for (; index < sourceData.Length; index++)
            {
                interVar1[index] = sourceData[index];
            }
            if (sourceData.Length < countN)
            {

                while (index < countN)
                {

                    interVar1[index] = new Complex();
                    index++;
                }
            }

            //w代表旋转因子
            Complex[] w = new Complex[countN / 2];
            //为旋转因子赋值。(在蝶形运算中使用的旋转因子是已经确定的,提前求出以便调用)
            //旋转因子公式 \  /\  /k __
            //              \/  \/N  --  exp(-j*2πk/N)
            //这里还用到了欧拉公式
            for (int i = 0; i < countN / 2; i++)
            {
                double angle = -i * Math.PI * 2 / countN;
                w[i] = new Complex(Math.Cos(angle), Math.Sin(angle));
            }

            //蝶形运算
            for (int i = 0; i < r; i++)
            {
                //i代表当前的迭代次数,r代表总共的迭代次数.
                //i记录着迭代的重要信息.通过i可以算出当前迭代共有几个分组,每个分组的长度

                //interval记录当前有几个组
                // <<是左移操作符,左移一位相当于*2
                //多使用位运算符可以人为提高算法速率^_^
                int interval = 1 << i;

                //halfN记录当前循环每个组的长度N
                int halfN = 1 << (r - i);

                //循环,依次对每个组进行蝶形运算
                for (int j = 0; j < interval; j++)
                {
                    //j代表第j个组

                    //gap=j*每组长度,代表着当前第j组的首元素的下标索引
                    int gap = j * halfN;

                    //进行蝶形运算
                    for (int k = 0; k < halfN / 2; k++)
                    {

                        interVar2[k + gap] = interVar1[k + gap] + interVar1[k + gap + halfN / 2];
                        interVar2[k + (halfN / 2) + gap] = (interVar1[k + gap] - interVar1[k + gap + (halfN / 2)]) * w[k * interval];
                    }
                }

                //将结果拷贝到输入端,为下次迭代做好准备
                interVar1 = (Complex[])interVar2.Clone();
            }

            //将输出码位倒置
            for (uint j = 0; j < countN; j++)
            {
                //j代表自然顺序的数组元素的下标索引

                //用rev记录j码位倒置后的结果
//.........这里部分代码省略.........
开发者ID:radarDemo,项目名称:RadarSimulation-v2,代码行数:101,代码来源:FeatureModel.cs


注:本文中的Complex.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。