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


C# Tuple.Take方法代码示例

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


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

示例1: LearnAndApply

        public void LearnAndApply(
                ICollection<string> seedPaths, Tuple<string, string>[] learningSets,
                LearningExperiment[] experiments) {
            var projectPaths =
                    learningSets.Take(ProjectCount).Select(
                            t => {
                                var url = t.Item1;
                                var path = Fixture.GetGitRepositoryPath(url);
                                Git.Clone(path, url);
                                Git.Checkout(path, t.Item2);
                                return path;
                            }).ToList();
            var failedCount = 0;
            foreach (var exp in experiments) {
                var learningResult = LearnWithoutClearing(
                        seedPaths, exp, projectPaths.Take(ProjectCountToLearn).ToList());

                var w = CreateWriter(exp.GetType().Name + "_classifier_" +
                                     ProjectCountToLearn + "_" + ProjectCount + ".txt");
                w.WriteLine(learningResult.Classifier.GetClassifierSummary());
                w.Flush();

                var writer = CreateWriter(exp.GetType().Name + "_apply_" +
                                          ProjectCountToLearn + "_" + ProjectCount + ".csv");
                foreach (var projectPath in projectPaths.Skip(ProjectCountToLearn)) {
                    var codePaths = Directory.GetFiles(projectPath, SearchPattern,
                            SearchOption.AllDirectories);
                    writer.Write(DateTime.Now);
                    writer.Write(",");
                    writer.Write(projectPath);
                    writer.Write(",");
                    var classificationResult = exp.Apply(codePaths, SearchPattern,
                            learningResult.FeatureEncoder,
                            learningResult.Classifier, writer);
                    var features =
                            learningResult.Classifier.GetAllAcceptingFeatureStrings(
                                    learningResult.FeatureEncoder);
                    writer.Write(classificationResult.WrongElementCount);
                    writer.Write(",");
                    writer.Write(classificationResult.WrongVectorCount);
                    writer.Write(",");
                    writer.WriteLine();
                    writer.Flush();
                    if (classificationResult.WrongElementCount > 0) {
                        failedCount++;
                        PrintWrongResults(classificationResult, learningResult);
                    }
                    Console.WriteLine(exp.GetType().Name);
                    Assert.That(failedCount, Is.EqualTo(0));
                }
            }
        }
开发者ID:RainsSoft,项目名称:Code2Xml,代码行数:52,代码来源:Experiment.cs

示例2: Match

        public static double Match(List<Minutia> minutiae1, List<Minutia> minutiae2)
        {
            var tasks =
                new Tuple<Minutia, Minutia, Minutia, Minutia>[6000];

            var sw = new Stopwatch();
            sw.Start();
            double max = 0;
            int count = -1;
            Parallel.ForEach(minutiae1, new ParallelOptions() {MaxDegreeOfParallelism = 4},
                             core1 =>
                                 {
                                     foreach (var to1 in minutiae1)
                                     {
                                         if (core1 == to1) continue;
                                         var angle1 = DetermineAngle(core1, to1);
                                         var length1 = DetermineDistance(core1, to1);

                                         foreach (var core2 in minutiae2)
                                         {
                                             var others2 = minutiae2.Except(new List<Minutia>() {core2});
                                             foreach (var to2 in others2)
                                             {
                                                 if (core2 == to2) continue;
                                                 var angle2 = DetermineAngle(core2, to2);
                                                 if (Math.Abs(angle1 - angle2) > AngleToleranceBox)
                                                     continue;
                                                 var length2 = DetermineDistance(core2, to2);
                                                 if (Math.Abs(length1 - length2) > DistanceToleranceBox) continue;
                                                 int localCount = Interlocked.Increment(ref count);
                                                 tasks[localCount] = Tuple.Create(core1, to1, core2, to2);
                                             }
                                         }
                                     }
                                 });
            object _lock = new object();
            Parallel.ForEach(tasks.Take(count), new ParallelOptions() {MaxDegreeOfParallelism = 4},
                             x =>
                                 {
                                     var angle1 = DetermineAngle(x.Item1, x.Item2);
                                     var angle2 = DetermineAngle(x.Item3, x.Item4);
                                     var score = TranslateAndMatch(minutiae1, x.Item1, minutiae2, x.Item3, angle2 - angle1);
                                     lock(_lock)
                                     {
                                         if (score > max) max = score;
                                     }
                                 });

            sw.Stop();
            return max;
        }
开发者ID:Cool2Feel,项目名称:cuda-fingerprinting,代码行数:51,代码来源:MinutiaeMatcher.cs


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