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


C# IGrid.GetValue方法代码示例

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


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

示例1: Compress

		private CompressionStats Compress( IGrid grid,
		                                   ICompressor compressor,
										   double[] errors,
										   string outName,
		                                   ProgressViewModel progressBar )
		{
			double[] leftBorders = new double[grid.ColumnCount];
			double[] rightBorders = new double[grid.ColumnCount];

			var qs = new IQuantization[grid.ColumnCount];
			var distrs = new IDistribution[grid.ColumnCount];

			progressBar.Status = "Quantizing columns...";

			Parallel.For( 0, grid.ColumnCount, column =>
			{
				var distr = new EmpiricalDistribution( grid, column );

				leftBorders[column] = double.MaxValue;
				rightBorders[column] = double.MinValue;

				for ( int row = 0; row < grid.RowCount; ++row )
				{
					double value = grid.GetValue( row, column );
					leftBorders[column] = leftBorders[column] < value ? leftBorders[column] : value;
					rightBorders[column] = rightBorders[column] > value ? rightBorders[column] : value;
				}

				var quantizer = new Quantizer( leftBorders[column], rightBorders[column] );
				var quantization = quantizer.Quantize( errors[column], distr );

				lock ( _lockGuard )
				{
					progressBar.Progress += 1.0 / ( grid.ColumnCount + 1 );
					distrs[column] = distr;
					qs[column] = quantization;
				}
			} );

			var quantizations = new List<IQuantization>( qs );
			var distributions = new List<IDistribution>( distrs );

			progressBar.Status = "Writing archive...";
			progressBar.Progress = ( double )grid.ColumnCount / ( grid.ColumnCount + 1 );

			ICompressionResult result;

			using ( var stream = new FileOutputStream( outName ) )
			{
				result = compressor.Compress( grid, quantizations, stream );
			}

			progressBar.Progress = 1.0;
			progressBar.TryClose( );

			return new CompressionStats
			{
				CompressionResult = result,
				Distributions = distributions,
				LeftBorders = leftBorders,
				RightBorders = rightBorders,
				Quantizations = quantizations
			};
		}
开发者ID:alex-ks,项目名称:quantpressor,代码行数:64,代码来源:MainViewModel.cs


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