示例#1
0
        protected override int AnalyzeInternal(
            GaloisField field,
            int informationWordLength,
            Func <int[], FieldElement[]> encodingProcedure,
            CodeDistanceAnalyzerOptions options)
        {
            var processedPairsCount = 0L;
            var codeDistance        = int.MaxValue;

            Parallel.ForEach(
                GenerateMappings(field, encodingProcedure, new int[informationWordLength], 0),
                new ParallelOptions {
                MaxDegreeOfParallelism = options.MaxDegreeOfParallelism
            },
                () => int.MaxValue,
                (mapping, loopState, localCodeDistance) =>
            {
                foreach (var(_, codeword) in GenerateMappings(field, encodingProcedure, mapping.informationWord, 0).Skip(1))
                {
                    if (Interlocked.Increment(ref processedPairsCount) % options.LoggingResolution == 0)
                    {
                        Logger.LogInformation("Processed {processedPairsCount} pairs, code distance {codeDistance}", processedPairsCount, localCodeDistance);
                    }

                    localCodeDistance = Math.Min(localCodeDistance, mapping.codeword.ComputeHammingDistance(codeword));
                }

                return(localCodeDistance);
            },
示例#2
0
        protected override int AnalyzeInternal(
            GaloisField field,
            int informationWordLength,
            Func <int[], FieldElement[]> encodingProcedure,
            CodeDistanceAnalyzerOptions options)
        {
            var processedCodewords = 0L;
            var codeDistance       = int.MaxValue;

            Parallel.ForEach(
                GenerateMappings(field, encodingProcedure, new int[informationWordLength], 0).Skip(1),
                new ParallelOptions {
                MaxDegreeOfParallelism = options.MaxDegreeOfParallelism
            },
                () => int.MaxValue,
                (mapping, loopState, localCodeDistance) =>
            {
                if (Interlocked.Increment(ref processedCodewords) % options.LoggingResolution == 0)
                {
                    Logger.LogInformation("Processed {processedCodewords} pairs, code distance {codeDistance}", processedCodewords, localCodeDistance);
                }

                var distance = mapping.codeword.Count(x => x.Representation != 0);
                return(Math.Min(localCodeDistance, distance));
            },
                localCodeDistance => { codeDistance = Math.Min(codeDistance, localCodeDistance); }
                );

            return(codeDistance);
        }
示例#3
0
        public int Analyze(
            GaloisField field,
            int informationWordLength,
            Func <int[], FieldElement[]> encodingProcedure,
            CodeDistanceAnalyzerOptions options = null)
        {
            if (field == null)
            {
                throw new ArgumentNullException(nameof(field));
            }
            if (informationWordLength <= 0)
            {
                throw new ArgumentException($"{nameof(informationWordLength)} must be positive");
            }
            if (encodingProcedure == null)
            {
                throw new ArgumentNullException(nameof(encodingProcedure));
            }

            var opts = options ?? new CodeDistanceAnalyzerOptions();

            return(AnalyzeInternal(field, informationWordLength, encodingProcedure, opts));
        }
示例#4
0
 protected abstract int AnalyzeInternal(GaloisField field,
                                        int informationWordLength,
                                        Func <int[], FieldElement[]> encodingProcedure,
                                        CodeDistanceAnalyzerOptions options);