private static void PlaceNoiseIntoSamplesAndDecodeWrapperForParallelRunning(AnalyzingSample sample, int n, int k, int d, Polynomial generatingPolynomial, GsBasedDecoder decoder) { try { PlaceNoiseIntoSamplesAndDecode(sample, 0, n, k, d, generatingPolynomial, decoder); } catch (Exception exception) { /* * _logger.LogError(0, exception, "Error on processing sample {0}", * "[" + string.Join(",", sample.Codeword.Select(v => $"({v.Item1},{v.Item2})")) + "]"); */ throw; } }
private static void PlaceNoiseIntoSamplesAndDecode(AnalyzingSample sample, int currentErrorNumber, int n, int k, int d, Polynomial generatingPolynomial, GsBasedDecoder decoder) { if (currentErrorNumber == sample.ErrorPositions.Length) { var decodingResults = decoder.Decode(n, k, d, generatingPolynomial, sample.Codeword, sample.CorrectValuesCount); if (decodingResults.Contains(sample.InformationPolynomial) == false) { throw new InvalidOperationException("Failed to decode sample"); } if (++sample.ProcessedNoises % 50 == 0) { var errors = new int[n]; for (var i = 0; i < sample.ErrorPositions.Length; i++) { errors[sample.ErrorPositions[i]] = sample.CurrentNoiseValue[i]; } //_logger.LogInformation($"[{Thread.CurrentThread.ManagedThreadId}]: Current noise value ({string.Join(",", errors)})"); } if (decoder.TelemetryCollector.ProcessedSamplesCount % 100 == 0) { _logger.LogInformation(decoder.TelemetryCollector.ToString()); } return; } var field = sample.InformationPolynomial.Field; var corretValue = sample.Codeword[sample.ErrorPositions[currentErrorNumber]]; for (var i = sample.CurrentNoiseValue[currentErrorNumber]; i < field.Order; i++) { sample.Codeword[sample.ErrorPositions[currentErrorNumber]] = Tuple.Create(corretValue.Item1, corretValue.Item2 + field.CreateElement(i)); sample.CurrentNoiseValue[currentErrorNumber] = i; PlaceNoiseIntoSamplesAndDecode(sample, currentErrorNumber + 1, n, k, d, generatingPolynomial, decoder); } sample.Codeword[sample.ErrorPositions[currentErrorNumber]] = corretValue; sample.CurrentNoiseValue[currentErrorNumber] = 1; }
public AnalyzingSample(AnalyzingSample sample) { InformationPolynomial = sample.InformationPolynomial; Codeword = sample.Codeword.Select(x => new Tuple <FieldElement, FieldElement>(x.Item1, new FieldElement(x.Item2))).ToArray(); }