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


C# Iterator.DetermineStatus方法代码示例

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


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

示例1: DetermineStatus

        public void DetermineStatus()
        {
            var criteria = new List<IIterationStopCriterium<float>>
                {
                    new FailureStopCriterium(),
                    new DivergenceStopCriterium(),
                    new IterationCountStopCriterium<float>(1)
                };

            var iterator = new Iterator<float>(criteria);

            // First step, nothing should happen.
            iterator.DetermineStatus(
                0,
                DenseVector.Create(3, i => 4),
                DenseVector.Create(3, i => 4),
                DenseVector.Create(3, i => 4));
            Assert.AreEqual(IterationStatus.Running, iterator.Status, "Incorrect status");

            // Second step, should run out of iterations.
            iterator.DetermineStatus(
                1,
                DenseVector.Create(3, i => 4),
                DenseVector.Create(3, i => 4),
                DenseVector.Create(3, i => 4));
            Assert.AreEqual(IterationStatus.StoppedWithoutConvergence, iterator.Status, "Incorrect status");
        }
开发者ID:primebing,项目名称:mathnet-numerics,代码行数:27,代码来源:IteratorTest.cs

示例2: DetermineStatus

        public void DetermineStatus()
        {
            var criteria = new List<IIterationStopCriterium<Complex32>>
            {
                new FailureStopCriterium<Complex32>(),
                new DivergenceStopCriterium<Complex32>(),
                new IterationCountStopCriterium<Complex32>(1)
            };

            var iterator = new Iterator<Complex32>(criteria);

            // First step, nothing should happen.
            iterator.DetermineStatus(
                0,
                Vector<Complex32>.Build.Dense(3, 4),
                Vector<Complex32>.Build.Dense(3, 4),
                Vector<Complex32>.Build.Dense(3, 4));
            Assert.AreEqual(IterationStatus.Continue, iterator.Status, "Incorrect status");

            // Second step, should run out of iterations.
            iterator.DetermineStatus(
                1,
                Vector<Complex32>.Build.Dense(3, 4),
                Vector<Complex32>.Build.Dense(3, 4),
                Vector<Complex32>.Build.Dense(3, 4));
            Assert.AreEqual(IterationStatus.StoppedWithoutConvergence, iterator.Status, "Incorrect status");
        }
开发者ID:kityandhero,项目名称:mathnet-numerics,代码行数:27,代码来源:IteratorTest.cs

示例3: DetermineStatusWithoutStopCriteriaDoesNotThrow

 public void DetermineStatusWithoutStopCriteriaDoesNotThrow()
 {
     var iterator = new Iterator<Complex32>();
     Assert.DoesNotThrow(() => iterator.DetermineStatus(
         0,
         DenseVector.Create(3, i => 4),
         DenseVector.Create(3, i => 5),
         DenseVector.Create(3, i => 6)));
 }
开发者ID:EricGT,项目名称:mathnet-numerics,代码行数:9,代码来源:IteratorTest.cs

示例4: DetermineStatusWithoutStopCriteriaDoesNotThrow

 public void DetermineStatusWithoutStopCriteriaDoesNotThrow()
 {
     var iterator = new Iterator<float>();
     Assert.DoesNotThrow(() => iterator.DetermineStatus(
         0,
         Vector<float>.Build.Dense(3, 4),
         Vector<float>.Build.Dense(3, 5),
         Vector<float>.Build.Dense(3, 6)));
 }
开发者ID:Jungwon,项目名称:mathnet-numerics,代码行数:9,代码来源:IteratorTest.cs

示例5: UseMonitor

        /// <summary>
        /// Creates a convergence monitor.
        /// </summary>
        public void UseMonitor()
        {
            // Set the maximum increase in residual that we allow before
            // stopping the iteration because of divergence.
            double maximumIncrease = 0.1;

            // Set the maximum number of iterations that the convergence monitor
            // will allow before indicating that the iteration must be stopped.
            int maximumNumberOfIterations = 100;

            // Set the value the residual must maximally have before the
            // convergence monitor will declare that the iteration has converged.
            // Note that this residual is relative to the starting point which is
            // determined by the matrix norm.
            double minimumResidual = 1E-5;

            List<IIterationStopCriterium> criteria = new List<IIterationStopCriterium>();
            criteria.Add(new FailureStopCriterium());
            criteria.Add(new DivergenceStopCriterium(maximumIncrease));
            criteria.Add(new IterationCountStopCriterium(maximumNumberOfIterations));
            criteria.Add(new ResidualStopCriterium(minimumResidual));

            // Create the iterator
            Iterator monitor = new Iterator(criteria);

            // To be able to use the convergence monitor we'll need a solution vector and
            // a residual vector. For now fill both with silly numbers.
            Vector sourceVector = new DenseVector(10, 3.5);
            Vector solutionVector = new DenseVector(10, 2.5);
            Vector residualVector = new DenseVector(10, 1.5);

            // Check the solution status. There should not be a real status because
            // we haven't done anything yet
            Console.WriteLine("Solution status: " + monitor.Status.ToString());

            // Now use the monitor in a fake iteration. If all goes well this iteration should
            // stop because the number of iterations becomes larger than the number of iterations
            // we allow.
            int currentIteration = 0;
            while ((monitor.Status is CalculationRunning) || (monitor.Status is CalculationIndetermined))
            {
                currentIteration++;
                Console.WriteLine("Working. Iteration no: " + currentIteration.ToString());
                monitor.DetermineStatus(currentIteration, solutionVector, sourceVector, residualVector);
            }

            // Indicate that we exited the loop
            Console.WriteLine("Stopped working.");
            // Indicate why we exited the loop. Note that this should say
            // SolutionStatus.IterationBoundsReached.
            Console.WriteLine("Stop reason: " + monitor.Status.ToString());
        }
开发者ID:alexflorea,项目名称:CN,代码行数:55,代码来源:Iterator.cs

示例6: DetermineStatusWithNegativeIterationNumberThrowsArgumentOutOfRangeException

        public void DetermineStatusWithNegativeIterationNumberThrowsArgumentOutOfRangeException()
        {
            var criteria = new List<IIterationStopCriterion<float>>
            {
                new FailureStopCriterion<float>(),
                new DivergenceStopCriterion<float>(),
                new IterationCountStopCriterion<float>(),
                new ResidualStopCriterion<float>(1e-6)
            };
            var iterator = new Iterator<float>(criteria);

            Assert.That(() => iterator.DetermineStatus(
                -1,
                Vector<float>.Build.Dense(3, 4),
                Vector<float>.Build.Dense(3, 5),
                Vector<float>.Build.Dense(3, 6)), Throws.TypeOf<ArgumentOutOfRangeException>());
        }
开发者ID:Jungwon,项目名称:mathnet-numerics,代码行数:17,代码来源:IteratorTest.cs

示例7: DetermineStatusWithNegativeIterationNumberThrowsArgumentOutOfRangeException

        public void DetermineStatusWithNegativeIterationNumberThrowsArgumentOutOfRangeException()
        {
            var criteria = new List<IIterationStopCriterium<Complex32>>
            {
                new FailureStopCriterium<Complex32>(),
                new DivergenceStopCriterium<Complex32>(),
                new IterationCountStopCriterium<Complex32>(),
                new ResidualStopCriterium<Complex32>(1e-6)
            };
            var iterator = new Iterator<Complex32>(criteria);

            Assert.Throws<ArgumentOutOfRangeException>(() => iterator.DetermineStatus(
                -1,
                DenseVector.Create(3, i => 4),
                DenseVector.Create(3, i => 5),
                DenseVector.Create(3, i => 6)));
        }
开发者ID:EricGT,项目名称:mathnet-numerics,代码行数:17,代码来源:IteratorTest.cs

示例8: ResetToPrecalculationState

        public void ResetToPrecalculationState()
        {
            var criteria = new List<IIterationStopCriterium>
                {
                    new FailureStopCriterium(),
                    new DivergenceStopCriterium(),
                    new IterationCountStopCriterium(1)
                };

            var iterator = new Iterator(criteria);

            // First step, nothing should happen.
            iterator.DetermineStatus(
                0,
                DenseVector.Create(3, i => 4),
                DenseVector.Create(3, i => 4),
                DenseVector.Create(3, i => 4));
            Assert.IsInstanceOf(typeof (CalculationRunning), iterator.Status, "Incorrect status");

            iterator.ResetToPrecalculationState();
            Assert.IsInstanceOf(typeof (CalculationIndetermined), iterator.Status, "Incorrect status");
            Assert.IsInstanceOf(typeof (CalculationIndetermined), criteria[0].Status, "Incorrect status");
            Assert.IsInstanceOf(typeof (CalculationIndetermined), criteria[1].Status, "Incorrect status");
            Assert.IsInstanceOf(typeof (CalculationIndetermined), criteria[2].Status, "Incorrect status");
        }
开发者ID:hickford,项目名称:mathnet-numerics-native,代码行数:25,代码来源:IteratorTest.cs

示例9: DetermineStatus

        public void DetermineStatus()
        {
            var criteria = new List<IIterationStopCriterium>
                {
                    new FailureStopCriterium(),
                    new DivergenceStopCriterium(),
                    new IterationCountStopCriterium(1)
                };

            var iterator = new Iterator(criteria);

            // First step, nothing should happen.
            iterator.DetermineStatus(
                0,
                DenseVector.Create(3, i => 4),
                DenseVector.Create(3, i => 4),
                DenseVector.Create(3, i => 4));
            Assert.IsInstanceOf(typeof (CalculationRunning), iterator.Status, "Incorrect status");

            // Second step, should run out of iterations.
            iterator.DetermineStatus(
                1,
                DenseVector.Create(3, i => 4),
                DenseVector.Create(3, i => 4),
                DenseVector.Create(3, i => 4));
            Assert.IsInstanceOf(typeof (CalculationStoppedWithoutConvergence), iterator.Status, "Incorrect status");
        }
开发者ID:hickford,项目名称:mathnet-numerics-native,代码行数:27,代码来源:IteratorTest.cs

示例10: DetermineStatusWithNullResidualVectorThrowsArgumentNullException

        public void DetermineStatusWithNullResidualVectorThrowsArgumentNullException()
        {
            var criteria = new List<IIterationStopCriterium>
                {
                    new FailureStopCriterium(),
                    new DivergenceStopCriterium(),
                    new IterationCountStopCriterium(),
                    new ResidualStopCriterium()
                };
            var iterator = new Iterator(criteria);

            Assert.Throws<ArgumentNullException>(() => iterator.DetermineStatus(
                1,
                DenseVector.Create(3, i => 4),
                DenseVector.Create(3, i => 5),
                null));
        }
开发者ID:hickford,项目名称:mathnet-numerics-native,代码行数:17,代码来源:IteratorTest.cs

示例11: DetermineStatusWithoutStopCriteriaThrowsArgumentException

 public void DetermineStatusWithoutStopCriteriaThrowsArgumentException()
 {
     var iterator = new Iterator();
     Assert.Throws<ArgumentException>(() => iterator.DetermineStatus(
         0,
         DenseVector.Create(3, i => 4),
         DenseVector.Create(3, i => 5),
         DenseVector.Create(3, i => 6)));
 }
开发者ID:hickford,项目名称:mathnet-numerics-native,代码行数:9,代码来源:IteratorTest.cs

示例12: DetermineStatusWithoutStopCriteriaThrowsArgumentException

 public void DetermineStatusWithoutStopCriteriaThrowsArgumentException()
 {
     var iterator = new Iterator();
     Assert.Throws<ArgumentException>(() => iterator.DetermineStatus(
         0,
         new DenseVector(3, 4),
         new DenseVector(3, 5),
         new DenseVector(3, 6)));
 }
开发者ID:jvangael,项目名称:mathnet-numerics,代码行数:9,代码来源:IteratorTest.cs

示例13: DetermineStatusWithNegativeIterationNumberThrowsArgumentOutOfRangeException

        public void DetermineStatusWithNegativeIterationNumberThrowsArgumentOutOfRangeException()
        {
            var criteria = new List<IIterationStopCriterium>
                           {
                               new FailureStopCriterium(),
                               new DivergenceStopCriterium(),
                               new IterationCountStopCriterium(),
                               new ResidualStopCriterium()
                           };
            var iterator = new Iterator(criteria);

            Assert.Throws<ArgumentOutOfRangeException>(() => iterator.DetermineStatus(
                -1,
                new DenseVector(3, 4),
                new DenseVector(3, 5),
                new DenseVector(3, 6)));
        }
开发者ID:jvangael,项目名称:mathnet-numerics,代码行数:17,代码来源:IteratorTest.cs

示例14: DetermineStatusWithNullResidualVector

        public void DetermineStatusWithNullResidualVector()
        {
            var criteria = new List<IIterationStopCriterium<float>>
                           {
                               new FailureStopCriterium(),
                               new DivergenceStopCriterium(),
                               new IterationCountStopCriterium(),
                               new ResidualStopCriterium()
                           };
            var iterator = new Iterator(criteria);

            iterator.DetermineStatus(1,
                                     new DenseVector(3, 4),
                                     new DenseVector(3, 5),
                                     null);
        }
开发者ID:xmap2008,项目名称:mathnet-numerics,代码行数:16,代码来源:IteratorTest.cs

示例15: ResetToPrecalculationState

        public void ResetToPrecalculationState()
        {
            var criteria = new List<IIterationStopCriterion<float>>
            {
                new FailureStopCriterion<float>(),
                new DivergenceStopCriterion<float>(),
                new IterationCountStopCriterion<float>(1)
            };

            var iterator = new Iterator<float>(criteria);

            // First step, nothing should happen.
            iterator.DetermineStatus(
                0,
                Vector<float>.Build.Dense(3, 4),
                Vector<float>.Build.Dense(3, 4),
                Vector<float>.Build.Dense(3, 4));
            Assert.AreEqual(IterationStatus.Continue, iterator.Status, "Incorrect status");

            iterator.Reset();
            Assert.AreEqual(IterationStatus.Continue, iterator.Status, "Incorrect status");
            Assert.AreEqual(IterationStatus.Continue, criteria[0].Status, "Incorrect status");
            Assert.AreEqual(IterationStatus.Continue, criteria[1].Status, "Incorrect status");
            Assert.AreEqual(IterationStatus.Continue, criteria[2].Status, "Incorrect status");
        }
开发者ID:Jungwon,项目名称:mathnet-numerics,代码行数:25,代码来源:IteratorTest.cs


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