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


C# DivergenceStopCriterium.DetermineStatus方法代码示例

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


在下文中一共展示了DivergenceStopCriterium.DetermineStatus方法的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: 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

示例3: 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

示例4: DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException

 public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException()
 {
     var criterium = new DivergenceStopCriterium(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:TransientResponse,项目名称:mathnet-numerics,代码行数:9,代码来源:DivergenceStopCriteriumTest.cs

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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++)
            {
                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.IsInstanceOf(typeof (CalculationRunning), criterium.Status, "Status check fail.");
            }

            // Now make it fail by throwing in a NaN
            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.IsInstanceOf(typeof (CalculationDiverged), criterium.Status, "Status check fail.");
        }
开发者ID:hickford,项目名称:mathnet-numerics-native,代码行数:28,代码来源:DivergenceStopCriteriumTest.cs

示例10: DetermineStatusWithNoDivergence

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

            var criterium = new DivergenceStopCriterium(Increase, Iterations);

            // Add residuals. We should not diverge because we won't have enough increase
            for (var i = 0; i < Iterations*2; i++)
            {
                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.IsInstanceOf(typeof (CalculationRunning), criterium.Status, "Status check fail.");
            }
        }
开发者ID:hickford,项目名称:mathnet-numerics-native,代码行数:19,代码来源:DivergenceStopCriteriumTest.cs

示例11: DetermineStatusWithNullResidualVectorThrowsArgumentNullException

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

示例12: 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
            criterium.DetermineStatus(1,
                                      new DenseVector(new [] { 1.0f }),
                                      new DenseVector(new [] { 1.0f }),
                                      new DenseVector(new [] { float.NaN }));

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

            // Reset the state
            criterium.ResetToPrecalculationState();

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

示例13: 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

示例14: 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

示例15: DetermineStatusWithIllegalIterationNumber

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


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