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


C# SparseArray.ValidIndexArray方法代码示例

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


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

示例1: BuildPDCube

 private void BuildPDCube(SparseArray<float> pds)
 {
     var numberOfPds = pds.Count;
     var pdIndex = pds.ValidIndexArray();
     PDCube = new int[numberOfPds][][];
     for(int i = 0; i < PDCube.Length; i++)
     {
         PDCube[i] = new int[numberOfPds][];
         for(int j = 0; j < PDCube[i].Length; j++)
         {
             PDCube[i][j] = new int[numberOfPds];
             for(int k = 0; k < PDCube[i][j].Length; k++)
             {
                 PDCube[i][j][k] = GetODIndex(pdIndex[i], pdIndex[k], pdIndex[j]);
             }
         }
     }
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:18,代码来源:V4LocationChoice.cs

示例2: FillRatioIntraZonalTravelTime

 private void FillRatioIntraZonalTravelTime(int districtNumber, IZone[] flatZones, SparseTwinIndex<float> matrix, SparseArray<float> radius)
 {
     var validDistricts = radius.ValidIndexArray();
     var flatRadius = radius.GetFlatData();
     for ( int otherDistrict = 0; otherDistrict < validDistricts.Length; otherDistrict++ )
     {
         var sparseOther = radius.GetSparseIndex( otherDistrict );
         if ( sparseOther == districtNumber ) continue;
         if ( this.AnyTripIntraDistrict( otherDistrict, flatZones, matrix ) )
         {
             var distanceRatio = radius[districtNumber] / flatRadius[otherDistrict];
             var data = matrix.GetFlatData();
             var averageTT = GetAverageIntraDistrictNonIntraZonalTravelTime( sparseOther, flatZones, data );
             var averageIntraZonealTT = GetAverageIntraZonalTravelTime( sparseOther, flatZones, data );
             var zoneRatio = GetNumberOfZonesRatio( flatZones, districtNumber, sparseOther );
             averageTT *= distanceRatio * zoneRatio;
             averageIntraZonealTT *= distanceRatio * zoneRatio;
             for ( int i = 0; i < flatZones.Length; i++ )
             {
                 if ( flatZones[i].PlanningDistrict != districtNumber ) continue;
                 for ( int j = 0; j < flatZones.Length; j++ )
                 {
                     if ( flatZones[j].PlanningDistrict != districtNumber ) continue;
                     if ( i == j )
                     {
                         data[i][j] = averageIntraZonealTT;
                     }
                     else
                     {
                         data[i][j] = averageTT;
                     }
                 }
             }
             break;
         }
     }
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:37,代码来源:BuildTripMatrix.cs

示例3: SaveVector

 public static void SaveVector(SparseArray<float> data, string saveTo)
 {
     var flatData = data.GetFlatData();
     var indexes = data.ValidIndexArray().Select(index => index.ToString()).ToArray();
     using (StreamWriter writer = new StreamWriter(saveTo))
     {
         writer.WriteLine("Zone,Value");
         for (int i = 0; i < flatData.Length; i++)
         {
             writer.Write(indexes[i]);
             writer.Write(',');
             writer.WriteLine(flatData[i]);
         }
     }
 }
开发者ID:dianatle,项目名称:XTMF,代码行数:15,代码来源:SaveData.cs

示例4: SaveData

 private void SaveData(float[][][] data, SparseArray<int> regions)
 {
     var modes = Root.AllModes.ToArray();
     var regionNumbers = regions.ValidIndexArray();
     using (StreamWriter writer = new StreamWriter(PDModeSplitFile))
     {
         writer.WriteLine("Mode,Origin,Destination,ExpandedTrips");
         for(int m = 0; m < data.Length; m++)
         {
             string modeName = modes[m].ModeName + ",";
             var oRow = data[m];
             for(int o = 0; o < oRow.Length; o++)
             {
                 var dRow = oRow[o];
                 for(int d = 0; d < dRow.Length; d++)
                 {
                     if(dRow[d] > 0)
                     {
                         // this includes the comma already
                         writer.Write(modeName);
                         writer.Write(regionNumbers[o]);
                         writer.Write(',');
                         writer.Write(regionNumbers[d]);
                         writer.Write(',');
                         writer.WriteLine(dRow[d]);
                     }
                 }
             }
         }
     }
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:31,代码来源:ConvertZonalModeSplitToPDModeSplit.cs

示例5: ProcessIE

 private void ProcessIE(SparseTriIndex<float> distribution, SparseArray<float> employment)
 {
     var indexes = employment.ValidIndexArray();
     Parallel.For( 0, indexes.Length, delegate(int i)
     {
         var zones = this.Root.ZoneSystem.ZoneArray;
         var destination = indexes[i];
         var destinationEmployment = employment[destination];
         var destinationZone = zones[destination];
         var factor = destinationEmployment / destinationZone.Employment;
         if ( destinationEmployment <= 0 | destinationZone.RegionNumber > 0 | float.IsInfinity( factor ) )
         {
             return;
         }
         var destinationIndex = zones.GetFlatIndex( destination );
         // The factor to apply to the distribution to map it to the results
         var numberOfZones = zones.GetFlatData().Length;
         foreach ( var origin in distribution.ValidIndexes() )
         {
             var originIndex = zones.GetFlatIndex( origin );
             // do not process EE trips
             if ( zones[origin].RegionNumber == 0 )
             {
                 continue;
             }
             foreach ( var mode in distribution.ValidIndexes( origin, destination ) )
             {
                 var ammount = distribution[origin, destination, mode] * factor;
                 if ( ammount <= 0 )
                 {
                     continue;
                 }
                 AddData( mode, originIndex, destinationIndex, ammount, numberOfZones );
             }
         }
     } );
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:37,代码来源:ExternalPurpose.cs

示例6: ProcessEI

        private void ProcessEI(SparseTriIndex<float> distribution, SparseArray<float> population)
        {
            var indexes = population.ValidIndexArray();
            Parallel.For( 0, indexes.Length, delegate(int i)
            {
                var zones = this.Root.ZoneSystem.ZoneArray;
                var zoneNumber = indexes[i];
                var originPopulation = population[zoneNumber];
                var originZone = zones[zoneNumber];
                var factor = originPopulation / originZone.Population;
                if ( originPopulation <= 0 | originZone.RegionNumber > 0 | float.IsInfinity( factor ) )
                {
                    return;
                }
                var originIndex = zones.GetFlatIndex( zoneNumber );
                // The factor to apply to the distribution to map it to the results

                var numberOfZones = zones.GetFlatData().Length;
                foreach ( var destination in distribution.ValidIndexes( zoneNumber ) )
                {
                    var destinationIndex = zones.GetFlatIndex( destination );
                    // do not process EE trips
                    if ( zones[destination].RegionNumber == 0 )
                    {
                        continue;
                    }
                    foreach ( var mode in distribution.ValidIndexes( zoneNumber, destination ) )
                    {
                        var ammount = distribution[zoneNumber, destination, mode] * factor;
                        AddData( mode, originIndex, destinationIndex, ammount, numberOfZones );
                    }
                }
            } );
        }
开发者ID:Cocotus,项目名称:XTMF,代码行数:34,代码来源:ExternalPurpose.cs


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