本文整理汇总了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;
}
示例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());
}
}
示例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();
}
}