本文整理汇总了C#中Tuple.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# Tuple.GetLength方法的具体用法?C# Tuple.GetLength怎么用?C# Tuple.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tuple
的用法示例。
在下文中一共展示了Tuple.GetLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromCellArray
internal static InitialConditionsGrid FromCellArray(Tuple<int,float>[,] cells)
{
InitialConditionCell[,] arr = new InitialConditionCell[cells.GetLength(0),cells.GetLength(1)];
var list = new List<List<InitialConditionCell>>();
for(int i=0;i<SPDAssets.MAX;i++) list.Add(new List<InitialConditionCell>());
for(int i=0;i<cells.GetLength(0);i++)
for (int j = 0; j < cells.GetLength(1); j++)
{
int k = (new IntegerStrategy(cells[i,j].Item1)).BetrayalThreshold;
arr[i,j] = new InitialConditionCell(i,j,k,k);
list[k].Add(arr[i, j]);
}
var arr2 = list.Select(l => l.ToArray()).ToArray();
return new InitialConditionsGrid {CellGrid = arr, CellSets = arr2};
}
示例2: PrintPredecessorMatrix
private static void PrintPredecessorMatrix(Tuple<Vector2, Vector2>[,] predecessorMatrix)
{
System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\gertj\myPredecessorMatrix.txt");
//Print distance matrix
for (int j = 0; j < predecessorMatrix.GetLength(0); j++)
{
string array = "";
Console.Write("[");
for (int k = 0; k < predecessorMatrix.GetLength(1); k++)
{
if (predecessorMatrix[j, k] == null)
{
array += "X";
Console.Write("X");
}
else
{
array += predecessorMatrix[j, k];
Console.Write(" " + predecessorMatrix[j, k]);
}
}
array += " ]";
Console.Write(" ] \r\n");
file.WriteLine(array);
array = "";
}
Console.Write(" ] \r\n");
}
示例3: CalculateModels
/// <summary>
/// Metoda wyliczająca dane do wykresów na podstawie stanu automatu
/// </summary>
double[][] CalculateModels(Tuple<int,float>[,] cells)
{
var result = new double[_strategyCount];
var count = new double[result.Length];
var sum = new double[result.Length];
for (var i = 0; i < result.Length; i++)
{
result[i] = 0;
count[i] = 0;
}
for (var i = 0; i < cells.GetLength(0); i++)
for (var j = 0; j < cells.GetLength(1); j++)
{
var c = cells[i, j];
var integerStrategy = (IntegerStrategy) _strategyDictionary[c.Item1];
if (integerStrategy != null)
{
var k = integerStrategy.BetrayalThreshold;
double d = (double)c.Item2/_spd.Neighbours(i,j).Length;
result[k] += d;
count[k]++;
}
}
for (var i = 0; i < count.Length; i++)
{
if ((count[i] - 100*Double.Epsilon) <= 0) continue;
result[i] /= count[i];
}
var d1 = result.Sum();
if (Math.Abs(d1) < double.Epsilon*100) d1 = 1;
var d2 = count.Sum();
if (Math.Abs(d2) < double.Epsilon * 100) d2 = 1;
result = result.Select(d => 100 * d / d1).ToArray();
for (int i = 0; i < result.Length; i++) _sumPoints[i] += result[i];
_sumPointsHistory.Add(_sumPoints);
count = count.Select(d => 100 * d / d2).ToArray();
return new[] { count, result };
}