本文整理汇总了C#中Number.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Number.Select方法的具体用法?C# Number.Select怎么用?C# Number.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Number
的用法示例。
在下文中一共展示了Number.Select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Manhattan
/// <summary>
/// Calculates the Manhattan (taxicab) distance between two sets of points.
/// <see href="http://en.wikipedia.org/wiki/Manhattan_distance"/>
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public static Number Manhattan(Number[] x, Number[] y)
{
CheckArgumentLengths(x, y);
var distance = x.Select((n, i) => Math.Abs(n - y[i])).Sum();
return distance;
}
示例2: Minkowski
/// <summary>
/// Calculates the Minkowski distance between two sets of points.
/// <see href="http://en.wikipedia.org/wiki/Minkowski_distance" />
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public static Number Minkowski(Number[] x, Number[] y)
{
CheckArgumentLengths(x, y);
var distance = x.Select((n, i) => Math.Abs(n - y[i])).Max();
return distance;
}
示例3: Euclidean
/// <summary>
/// Calculates the Euclidean distance between two sets of points.
/// <see href="http://en.wikipedia.org/wiki/Euclidean_distance" />
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public static Number Euclidean(Number[] x, Number[] y)
{
CheckArgumentLengths(x, y);
var sum = x.Select((n, i) => Math.Pow(Math.Abs(n - y[i]), 2)).Sum();
var distance = Math.Sqrt(sum);
return distance;
}