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


C# Vector.ToArray方法代码示例

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


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

示例1: butterworth

            public Vector<double> butterworth(Vector<double> signal, double fs, double fc, int order, Filtr_Type type)
            {
                //TODO: Comments

                int L = signal.Count;
                int DCGain = 1;

                double[] DoubleArray = new double[L];
                DoubleArray = signal.ToArray();

                Complex[] ComplexArray = new Complex[L];

                for (int i = 0; i < L; i++)
                {
                    ComplexArray[i] = new Complex(DoubleArray[i], 0);
                }

                Fourier.Forward(ComplexArray, FourierOptions.Matlab);

                double binWidth, binFreq, gain;

                if (fc > 0)
                {
                    binWidth = fs / L;

                    for(int i = 0; i < (L/2); i++)
                    {
                        binFreq = binWidth * (i+1);
                        gain = DCGain / Math.Sqrt(1 + Math.Pow(binFreq/fc, 2.0 * order));
                        if (type == Filtr_Type.HIGHPASS)
                        {
                            gain = 1 - gain;
                        }
                        ComplexArray[i] *= gain;
                        ComplexArray[L - 1 - i] *= gain;
                    }
                }

                Fourier.Inverse(ComplexArray, FourierOptions.Matlab);

                for (int i = 0; i < L; i++)
                {
                    DoubleArray[i] = ComplexArray[i].Real;
                }

                Vector<double> output_signal = Vector<double>.Build.DenseOfArray(DoubleArray);
                return output_signal;
            }
开发者ID:Nefarin,项目名称:DadmProject,代码行数:48,代码来源:ECG_Baseline_Alg.cs

示例2: ConvertToString

        public static string ConvertToString(BigInteger n, bool escape, int radix)
        {
            if (radix == -1)
            {
                radix = (int)Runtime.GetDynamic(Symbols.PrintBase);
            }

            if (radix == -1)
            {
                radix = 10;
            }
            else if (radix < 2 || radix > 36)
            {
                throw new LispException("Invalid number base: {0}", radix);
            }

            if (n == 0)
            {
                return "0";
            }

            var sign = (n >= 0) ? "" : "-";
            n = (n >= 0) ? n : -n;
            var stk = new Vector();
            while (n != 0)
            {
                var d = (int)(n % radix);
                if (d <= 9)
                {
                    stk.Add((char)(d + '0'));
                }
                else {
                    stk.Add((char)(d - 10 + 'a'));
                }
                n = n / radix;
            }
            stk.Reverse();
            if (escape)
            {
                switch (radix)
                {
                    case 10:
                        return sign + Runtime.MakeString(stk.ToArray());
                    case 16:
                        return sign + "0x" + Runtime.MakeString(stk.ToArray());
                    case 8:
                        return sign + "0" + Runtime.MakeString(stk.ToArray());
                    case 2:
                        return "#b" + sign + Runtime.MakeString(stk.ToArray());
                    default:
                        return "#" + radix + "r" + sign + Runtime.MakeString(stk.ToArray());
                }
            }
            else {
                return sign + Runtime.MakeString(stk.ToArray());
            }
        }
开发者ID:jantolenaar,项目名称:kiezellisp,代码行数:57,代码来源:number.cs

示例3: WriteToString

 public static string WriteToString(object item, params object[] kwargs)
 {
     using (var stream = new StringWriter())
     {
         var kwargs2 = new Vector(kwargs);
         kwargs2.Add(Symbols.Stream);
         kwargs2.Add(stream);
         Write(item, kwargs2.ToArray());
         return stream.ToString();
     }
 }
开发者ID:jantolenaar,项目名称:kiezellisp,代码行数:11,代码来源:io.cs


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