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


C# Tuple.GetLength方法代码示例

本文整理汇总了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};
 }
开发者ID:kujawskip,项目名称:SPD,代码行数:15,代码来源:InitialConditionsGrid.cs

示例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");
        }
开发者ID:gvh1993,项目名称:algoritmiek,代码行数:29,代码来源:Program.cs

示例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 };
        }
开发者ID:kujawskip,项目名称:SPD,代码行数:48,代码来源:SPDView.xaml.cs


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