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


C# DivergenceStopCriterium类代码示例

本文整理汇总了C#中DivergenceStopCriterium的典型用法代码示例。如果您正苦于以下问题:C# DivergenceStopCriterium类的具体用法?C# DivergenceStopCriterium怎么用?C# DivergenceStopCriterium使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: DetermineStatusWithDivergence

        public void DetermineStatusWithDivergence()
        {
            const float Increase = 0.5f;
            const int Iterations = 10;

            var criterium = new DivergenceStopCriterium(Increase, Iterations);

            // Add residuals. We should not diverge because we'll have one to few iterations
            float previous = 1;
            for (var i = 0; i < Iterations - 1; i++)
            {
                previous *= (1 + Increase + 0.01f);
                criterium.DetermineStatus(i,
                                          new DenseVector(new[] { 1.0f }),
                                          new DenseVector(new[] { 1.0f }),
                                          new DenseVector(new[] { previous }));

                Assert.IsInstanceOfType(typeof(CalculationRunning), criterium.Status, "Status check fail.");
            }

            // Add the final residual. Now we should have divergence
            previous *= (1 + Increase + 0.01f);
            criterium.DetermineStatus(Iterations - 1,
                                      new DenseVector(new[] { 1.0f }),
                                      new DenseVector(new[] { 1.0f }),
                                      new DenseVector(new[] { previous }));

            Assert.IsInstanceOfType(typeof(CalculationDiverged), criterium.Status, "Status check fail.");
        }
开发者ID:xmap2008,项目名称:mathnet-numerics,代码行数:29,代码来源:DivergenceStopCriteriumTest.cs

示例2: Create

        public void Create()
        {
            var criterium = new DivergenceStopCriterium(0.1, 3);
            Assert.IsNotNull(criterium, "There should be a criterium");

            Assert.AreEqual(0.1, criterium.MaximumRelativeIncrease, "Incorrect maximum");
            Assert.AreEqual(3, criterium.MinimumNumberOfIterations, "Incorrect iteration count");
        }
开发者ID:TransientResponse,项目名称:mathnet-numerics,代码行数:8,代码来源:DivergenceStopCriteriumTest.cs

示例3: DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException

 public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException()
 {
     var criterium = new DivergenceStopCriterium<double>(0.5, 15);
     Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(
         -1,
         DenseVector.Create(3, i => 4),
         DenseVector.Create(3, i => 5),
         DenseVector.Create(3, i => 6)));
 }
开发者ID:EricGT,项目名称:mathnet-numerics,代码行数:9,代码来源:DivergenceStopCriteriumTest.cs

示例4: ResetMaximumIncrease

        public void ResetMaximumIncrease()
        {
            var criterium = new DivergenceStopCriterium(0.5, 3);
            Assert.IsNotNull(criterium, "There should be a criterium");

            Assert.AreEqual(0.5, criterium.MaximumRelativeIncrease, "Incorrect maximum");

            criterium.ResetMaximumRelativeIncreaseToDefault();
            Assert.AreEqual(DivergenceStopCriterium.DefaultMaximumRelativeIncrease, criterium.MaximumRelativeIncrease, "Incorrect value");
        }
开发者ID:hickford,项目名称:mathnet-numerics-native,代码行数:10,代码来源:DivergenceStopCriteriumTest.cs

示例5: Clone

        public void Clone()
        {
            const double Increase = 0.5;
            const int Iterations = 10;

            var criterium = new DivergenceStopCriterium(Increase, Iterations);
            Assert.IsNotNull(criterium, "There should be a criterium");

            var clone = criterium.Clone();
            Assert.IsInstanceOf(typeof (DivergenceStopCriterium), clone, "Wrong criterium type");

            var clonedCriterium = clone as DivergenceStopCriterium;
            Assert.IsNotNull(clonedCriterium);

            Assert.AreEqual(criterium.MaximumRelativeIncrease, clonedCriterium.MaximumRelativeIncrease, "Incorrect maximum");
            Assert.AreEqual(criterium.MinimumNumberOfIterations, clonedCriterium.MinimumNumberOfIterations, "Incorrect iteration count");
        }
开发者ID:TransientResponse,项目名称:mathnet-numerics,代码行数:17,代码来源:DivergenceStopCriteriumTest.cs

示例6: Clone

        public void Clone()
        {
            const float Increase = 0.5f;
            const int Iterations = 10;

            var criterium = new DivergenceStopCriterium(Increase, Iterations);
            Assert.IsNotNull(criterium, "There should be a criterium");

            var clone = criterium.Clone();
            Assert.IsInstanceOfType(typeof(DivergenceStopCriterium), clone, "Wrong criterium type");

            var clonedCriterium = clone as DivergenceStopCriterium;
            Assert.IsNotNull(clonedCriterium);
            // ReSharper disable PossibleNullReferenceException
            Assert.AreEqual(criterium.MaximumRelativeIncrease, clonedCriterium.MaximumRelativeIncrease, "Incorrect maximum");
            Assert.AreEqual(criterium.MinimumNumberOfIterations, clonedCriterium.MinimumNumberOfIterations, "Incorrect iteration count");
            // ReSharper restore PossibleNullReferenceException
        }
开发者ID:xmap2008,项目名称:mathnet-numerics,代码行数:18,代码来源:DivergenceStopCriteriumTest.cs

示例7: DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException

 public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException()
 {
     var criterium = new DivergenceStopCriterium<float>(0.5, 15);
     Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(
         -1,
         Vector<float>.Build.Dense(3, 4),
         Vector<float>.Build.Dense(3, 5),
         Vector<float>.Build.Dense(3, 6)));
 }
开发者ID:rmundy,项目名称:mathnet-numerics,代码行数:9,代码来源:DivergenceStopCriteriumTest.cs

示例8: ResetMinimumIterationsBelowMaximum

        public void ResetMinimumIterationsBelowMaximum()
        {
            var criterium = new DivergenceStopCriterium(0.5, 15);
            Assert.IsNotNull(criterium, "There should be a criterium");

            Assert.AreEqual(15, criterium.MinimumNumberOfIterations, "Incorrect iteration count");

            criterium.ResetNumberOfIterationsToDefault();
            Assert.AreEqual(DivergenceStopCriterium.DefaultMinimumNumberOfIterations, criterium.MinimumNumberOfIterations, "Incorrect value");
        }
开发者ID:TransientResponse,项目名称:mathnet-numerics,代码行数:10,代码来源:DivergenceStopCriteriumTest.cs

示例9: DetermineStatusWithNullResidualVector

 public void DetermineStatusWithNullResidualVector()
 {
     var criterium = new DivergenceStopCriterium(0.5, 15);
     criterium.DetermineStatus(1,
                               new DenseVector(3, 4),
                               new DenseVector(3, 5),
                               null);
 }
开发者ID:xmap2008,项目名称:mathnet-numerics,代码行数:8,代码来源:DivergenceStopCriteriumTest.cs

示例10: DetermineStatusWithTooFewIterations

        public void DetermineStatusWithTooFewIterations()
        {
            const double Increase = 0.5;
            const int Iterations = 10;

            var criterium = new DivergenceStopCriterium(Increase, Iterations);

            // Add residuals. We should not diverge because we'll have to few iterations
            for (var i = 0; i < Iterations - 1; i++)
            {
                var status = criterium.DetermineStatus(
                    i,
                    new DenseVector(new[] {new Complex(1.0, 0)}),
                    new DenseVector(new[] {new Complex(1.0, 0)}),
                    new DenseVector(new[] {new Complex((i + 1)*(Increase + 0.1), 0)}));

                Assert.AreEqual(IterationStatus.Continue, status, "Status check fail.");
            }
        }
开发者ID:TransientResponse,项目名称:mathnet-numerics,代码行数:19,代码来源:DivergenceStopCriteriumTest.cs

示例11: ResetCalculationState

        public void ResetCalculationState()
        {
            const double Increase = 0.5;
            const int Iterations = 10;

            var criterium = new DivergenceStopCriterium(Increase, Iterations);

            // Add residuals. Blow it up instantly
            var status = criterium.DetermineStatus(
                1,
                new DenseVector(new[] {new Complex(1.0, 0)}),
                new DenseVector(new[] {new Complex(1.0, 0)}),
                new DenseVector(new[] {new Complex(double.NaN, 0)}));

            Assert.AreEqual(IterationStatus.Diverged, status, "Status check fail.");

            // Reset the state
            criterium.Reset();

            Assert.AreEqual(Increase, criterium.MaximumRelativeIncrease, "Incorrect maximum");
            Assert.AreEqual(Iterations, criterium.MinimumNumberOfIterations, "Incorrect iteration count");
            Assert.AreEqual(IterationStatus.Continue, criterium.Status, "Status check fail.");
        }
开发者ID:TransientResponse,项目名称:mathnet-numerics,代码行数:23,代码来源:DivergenceStopCriteriumTest.cs

示例12: DetermineStatusWithDivergence

        public void DetermineStatusWithDivergence()
        {
            const double Increase = 0.5;
            const int Iterations = 10;

            var criterium = new DivergenceStopCriterium(Increase, Iterations);

            // Add residuals. We should not diverge because we'll have one to few iterations
            double previous = 1;
            for (var i = 0; i < Iterations - 1; i++)
            {
                previous *= 1 + Increase + 0.01;
                var status = criterium.DetermineStatus(
                    i,
                    new DenseVector(new[] {new Complex(1.0, 0)}),
                    new DenseVector(new[] {new Complex(1.0, 0)}),
                    new DenseVector(new[] {new Complex(previous, 0)}));

                Assert.AreEqual(IterationStatus.Continue, status, "Status check fail.");
            }

            // Add the final residual. Now we should have divergence
            previous *= 1 + Increase + 0.01;
            var status2 = criterium.DetermineStatus(
                Iterations - 1,
                new DenseVector(new[] {new Complex(1.0, 0)}),
                new DenseVector(new[] {new Complex(1.0, 0)}),
                new DenseVector(new[] {new Complex(previous, 0)}));

            Assert.AreEqual(IterationStatus.Diverged, status2, "Status check fail.");
        }
开发者ID:TransientResponse,项目名称:mathnet-numerics,代码行数:31,代码来源:DivergenceStopCriteriumTest.cs

示例13: DetermineStatusWithDivergenceThroughNaN

        public void DetermineStatusWithDivergenceThroughNaN()
        {
            const double Increase = 0.5;
            const int Iterations = 10;

            var criterium = new DivergenceStopCriterium(Increase, Iterations);

            // Add residuals. We should not diverge because we'll have to few iterations
            for (var i = 0; i < Iterations - 5; i++)
            {
                var status = criterium.DetermineStatus(
                    i,
                    new DenseVector(new[] {new Complex(1.0, 0)}),
                    new DenseVector(new[] {new Complex(1.0, 0)}),
                    new DenseVector(new[] {new Complex((i + 1)*(Increase - 0.01), 0)}));

                Assert.AreEqual(IterationStatus.Continue, status, "Status check fail.");
            }

            // Now make it fail by throwing in a NaN
            var status2 = criterium.DetermineStatus(
                Iterations,
                new DenseVector(new[] {new Complex(1.0, 0)}),
                new DenseVector(new[] {new Complex(1.0, 0)}),
                new DenseVector(new[] {new Complex(double.NaN, 0)}));

            Assert.AreEqual(IterationStatus.Diverged, status2, "Status check fail.");
        }
开发者ID:TransientResponse,项目名称:mathnet-numerics,代码行数:28,代码来源:DivergenceStopCriteriumTest.cs

示例14: DetermineStatusWithTooFewIterations

        public void DetermineStatusWithTooFewIterations()
        {
            const float Increase = 0.5f;
            const int Iterations = 10;

            var criterium = new DivergenceStopCriterium(Increase, Iterations);

            // Add residuals. We should not diverge because we'll have to few iterations
            for (var i = 0; i < Iterations - 1; i++)
            {
                criterium.DetermineStatus(i,
                                          new DenseVector(new [] { 1.0f }),
                                          new DenseVector(new [] { 1.0f }),
                                          new DenseVector(new [] { (i + 1) * (Increase + 0.1f) }));

                Assert.IsInstanceOfType(typeof(CalculationRunning), criterium.Status, "Status check fail.");
            }
        }
开发者ID:xmap2008,项目名称:mathnet-numerics,代码行数:18,代码来源:DivergenceStopCriteriumTest.cs

示例15: DetermineStatusWithNoDivergence

        public void DetermineStatusWithNoDivergence()
        {
            const double Increase = 0.5;
            const int Iterations = 10;

            var criterium = new DivergenceStopCriterium<Complex>(Increase, Iterations);

            // Add residuals. We should not diverge because we won't have enough increase
            for (var i = 0; i < Iterations*2; i++)
            {
                var status = criterium.DetermineStatus(
                    i,
                    new DenseVector(new[] {new Complex(1.0, 0)}),
                    new DenseVector(new[] {new Complex(1.0, 0)}),
                    new DenseVector(new[] {new Complex((i + 1)*(Increase - 0.01), 0)}));

                Assert.AreEqual(IterationStatus.Continue, status, "Status check fail.");
            }
        }
开发者ID:EricGT,项目名称:mathnet-numerics,代码行数:19,代码来源:DivergenceStopCriteriumTest.cs


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