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


C# IterationCountStopCriterium类代码示例

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


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

示例1: DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException

        public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException()
        {
            var criterium = new IterationCountStopCriterium(10);
            Assert.IsNotNull(criterium, "A criterium should have been created");

            Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(-1, new DenseVector(3, 1), new DenseVector(3, 2), new DenseVector(3, 3)));
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:7,代码来源:IterationCountStopCriteriumTest.cs

示例2: DetermineStatusWithIllegalIterationNumber

        public void DetermineStatusWithIllegalIterationNumber()
        {
            var criterium = new IterationCountStopCriterium(10);
            Assert.IsNotNull(criterium, "A criterium should have been created");

            criterium.DetermineStatus(-1, new DenseVector(3, 1), new DenseVector(3, 2), new DenseVector(3,3));
            Assert.Fail();
        }
开发者ID:xmap2008,项目名称:mathnet-numerics,代码行数:8,代码来源:IterationCountStopCriteriumTest.cs

示例3: ResetMaximumIterations

        public void ResetMaximumIterations()
        {
            var criterium = new IterationCountStopCriterium(10);
            Assert.IsNotNull(criterium, "A criterium should have been created");
            Assert.AreEqual(10, criterium.MaximumNumberOfIterations, "Incorrect maximum number of iterations");

            criterium.ResetMaximumNumberOfIterationsToDefault();
            Assert.AreNotEqual(10, criterium.MaximumNumberOfIterations, "Should have reset");
            Assert.AreEqual(IterationCountStopCriterium.DefaultMaximumNumberOfIterations, criterium.MaximumNumberOfIterations, "Reset to the wrong value");
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:10,代码来源:IterationCountStopCriteriumTest.cs

示例4: ResetCalculationState

        public void ResetCalculationState()
        {
            var criterium = new IterationCountStopCriterium(10);
            Assert.IsNotNull(criterium, "A criterium should have been created");

            criterium.DetermineStatus(5, new DenseVector(3, 1), new DenseVector(3, 2), new DenseVector(3, 3));
            Assert.IsInstanceOfType(typeof(CalculationRunning), criterium.Status, "Should be running");

            criterium.ResetToPrecalculationState();
            Assert.IsInstanceOfType(typeof(CalculationIndetermined), criterium.Status, "Should not have started");
        }
开发者ID:xmap2008,项目名称:mathnet-numerics,代码行数:11,代码来源:IterationCountStopCriteriumTest.cs

示例5: DetermineStatus

        public void DetermineStatus()
        {
            var criterium = new IterationCountStopCriterium(10);
            Assert.IsNotNull(criterium, "A criterium should have been created");

            criterium.DetermineStatus(5, new DenseVector(3, 1), new DenseVector(3, 2), new DenseVector(3, 3));
            Assert.IsInstanceOfType(typeof(CalculationRunning), criterium.Status, "Should be running");

            criterium.DetermineStatus(10, new DenseVector(3, 1), new DenseVector(3, 2), new DenseVector(3, 3));
            Assert.IsInstanceOfType(typeof(CalculationStoppedWithoutConvergence), criterium.Status, "Should be finished");
        }
开发者ID:xmap2008,项目名称:mathnet-numerics,代码行数:11,代码来源:IterationCountStopCriteriumTest.cs

示例6: Clone

        public void Clone()
        {
            var criterium = new IterationCountStopCriterium(10);
            Assert.IsNotNull(criterium, "A criterium should have been created");
            Assert.AreEqual(10, criterium.MaximumNumberOfIterations, "Incorrect maximum");

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

            var clonedCriterium = clone as IterationCountStopCriterium;
            Assert.IsNotNull(clonedCriterium);
            // ReSharper disable PossibleNullReferenceException
            Assert.AreEqual(criterium.MaximumNumberOfIterations, clonedCriterium.MaximumNumberOfIterations, "Clone failed");
            // ReSharper restore PossibleNullReferenceException
        }
开发者ID:xmap2008,项目名称:mathnet-numerics,代码行数:15,代码来源:IterationCountStopCriteriumTest.cs

示例7: Create

 public void Create()
 {
     var criterium = new IterationCountStopCriterium(10);
     Assert.IsNotNull(criterium, "A criterium should have been created");
 }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:5,代码来源:IterationCountStopCriteriumTest.cs

示例8: DetermineStatus

        public void DetermineStatus()
        {
            var criterium = new IterationCountStopCriterium<Complex32>(10);
            Assert.IsNotNull(criterium, "A criterium should have been created");

            var status = criterium.DetermineStatus(5, Vector<Complex32>.Build.Dense(3, 1), Vector<Complex32>.Build.Dense(3, 2), Vector<Complex32>.Build.Dense(3, 3));
            Assert.AreEqual(IterationStatus.Continue, status, "Should be running");

            var status2 = criterium.DetermineStatus(10, Vector<Complex32>.Build.Dense(3, 1), Vector<Complex32>.Build.Dense(3, 2), Vector<Complex32>.Build.Dense(3, 3));
            Assert.AreEqual(IterationStatus.StoppedWithoutConvergence, status2, "Should be finished");
        }
开发者ID:rmundy,项目名称:mathnet-numerics,代码行数:11,代码来源:IterationCountStopCriteriumTest.cs

示例9: ResetCalculationState

        public void ResetCalculationState()
        {
            var criterium = new IterationCountStopCriterium<Complex32>(10);
            Assert.IsNotNull(criterium, "A criterium should have been created");

            var status = criterium.DetermineStatus(5, Vector<Complex32>.Build.Dense(3, 1), Vector<Complex32>.Build.Dense(3, 2), Vector<Complex32>.Build.Dense(3, 3));
            Assert.AreEqual(IterationStatus.Continue, status, "Should be running");

            criterium.Reset();
            Assert.AreEqual(IterationStatus.Continue, criterium.Status, "Should not have started");
        }
开发者ID:rmundy,项目名称:mathnet-numerics,代码行数:11,代码来源:IterationCountStopCriteriumTest.cs

示例10: DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException

        public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException()
        {
            var criterium = new IterationCountStopCriterium<double>(10);
            Assert.IsNotNull(criterium, "A criterium should have been created");

            Assert.That(() => criterium.DetermineStatus(-1, Vector<double>.Build.Dense(3, 1), Vector<double>.Build.Dense(3, 2), Vector<double>.Build.Dense(3, 3)), Throws.TypeOf<ArgumentOutOfRangeException>());
        }
开发者ID:kityandhero,项目名称:mathnet-numerics,代码行数:7,代码来源:IterationCountStopCriteriumTest.cs

示例11: Run

        /// <summary>
        /// Run example
        /// </summary>
        public void Run()
        {
            // Format matrix output to console
            var formatProvider = (CultureInfo)CultureInfo.InvariantCulture.Clone();
            formatProvider.TextInfo.ListSeparator = " ";

            // Solve next system of linear equations (Ax=b):
            // 5*x + 2*y - 4*z = -7
            // 3*x - 7*y + 6*z = 38
            // 4*x + 1*y + 5*z = 43

            // Create matrix "A" with coefficients
            var matrixA = DenseMatrix.OfArray(new[,] { { 5.00, 2.00, -4.00 }, { 3.00, -7.00, 6.00 }, { 4.00, 1.00, 5.00 } });
            Console.WriteLine(@"Matrix 'A' with coefficients");
            Console.WriteLine(matrixA.ToString("#0.00\t", formatProvider));
            Console.WriteLine();

            // Create vector "b" with the constant terms.
            var vectorB = new DenseVector(new[] { -7.0, 38.0, 43.0 });
            Console.WriteLine(@"Vector 'b' with the constant terms");
            Console.WriteLine(vectorB.ToString("#0.00\t", formatProvider));
            Console.WriteLine();

            // Create stop criteriums to monitor an iterative calculation. There are next available stop criteriums:
            // - DivergenceStopCriterium: monitors an iterative calculation for signs of divergence;
            // - FailureStopCriterium: monitors residuals for NaN's;
            // - IterationCountStopCriterium: monitors the numbers of iteration steps;
            // - ResidualStopCriterium: monitors residuals if calculation is considered converged;

            // Stop calculation if 1000 iterations reached during calculation
            var iterationCountStopCriterium = new IterationCountStopCriterium<double>(1000);

            // Stop calculation if residuals are below 1E-10 --> the calculation is considered converged
            var residualStopCriterium = new ResidualStopCriterium<double>(1e-10);

            // Create monitor with defined stop criteriums
            var monitor = new Iterator<double>(iterationCountStopCriterium, residualStopCriterium);

            // Create Transpose Free Quasi-Minimal Residual solver
            var solver = new TFQMR();

            // 1. Solve the matrix equation
            var resultX = matrixA.SolveIterative(vectorB, solver, monitor);
            Console.WriteLine(@"1. Solve the matrix equation");
            Console.WriteLine();

            // 2. Check solver status of the iterations.
            // Solver has property IterationResult which contains the status of the iteration once the calculation is finished.
            // Possible values are:
            // - CalculationCancelled: calculation was cancelled by the user;
            // - CalculationConverged: calculation has converged to the desired convergence levels;
            // - CalculationDiverged: calculation diverged;
            // - CalculationFailure: calculation has failed for some reason;
            // - CalculationIndetermined: calculation is indetermined, not started or stopped;
            // - CalculationRunning: calculation is running and no results are yet known;
            // - CalculationStoppedWithoutConvergence: calculation has been stopped due to reaching the stopping limits, but that convergence was not achieved;
            Console.WriteLine(@"2. Solver status of the iterations");
            Console.WriteLine(monitor.Status);
            Console.WriteLine();

            // 3. Solution result vector of the matrix equation
            Console.WriteLine(@"3. Solution result vector of the matrix equation");
            Console.WriteLine(resultX.ToString("#0.00\t", formatProvider));
            Console.WriteLine();

            // 4. Verify result. Multiply coefficient matrix "A" by result vector "x"
            var reconstructVecorB = matrixA * resultX;
            Console.WriteLine(@"4. Multiply coefficient matrix 'A' by result vector 'x'");
            Console.WriteLine(reconstructVecorB.ToString("#0.00\t", formatProvider));
            Console.WriteLine();
        }
开发者ID:smoothdeveloper,项目名称:mathnet-numerics,代码行数:74,代码来源:TFQMRSolver.cs

示例12: DetermineStatus

        public void DetermineStatus()
        {
            var criterium = new IterationCountStopCriterium<Complex>(10);
            Assert.IsNotNull(criterium, "A criterium should have been created");

            var status = criterium.DetermineStatus(5, DenseVector.Create(3, i => 1), DenseVector.Create(3, i => 2), DenseVector.Create(3, i => 3));
            Assert.AreEqual(IterationStatus.Running, status, "Should be running");

            var status2 = criterium.DetermineStatus(10, DenseVector.Create(3, i => 1), DenseVector.Create(3, i => 2), DenseVector.Create(3, i => 3));
            Assert.AreEqual(IterationStatus.StoppedWithoutConvergence, status2, "Should be finished");
        }
开发者ID:primebing,项目名称:mathnet-numerics,代码行数:11,代码来源:IterationCountStopCriteriumTest.cs

示例13: ResetCalculationState

        public void ResetCalculationState()
        {
            var criterium = new IterationCountStopCriterium<Complex>(10);
            Assert.IsNotNull(criterium, "A criterium should have been created");

            var status = criterium.DetermineStatus(5, DenseVector.Create(3, i => 1), DenseVector.Create(3, i => 2), DenseVector.Create(3, i => 3));
            Assert.AreEqual(IterationStatus.Running, status, "Should be running");

            criterium.ResetToPrecalculationState();
            Assert.AreEqual(IterationStatus.Indetermined, criterium.Status, "Should not have started");
        }
开发者ID:primebing,项目名称:mathnet-numerics,代码行数:11,代码来源:IterationCountStopCriteriumTest.cs


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