本文整理汇总了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
};
}