public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException()
        {
            var criterium = new FailureStopCriterium();
            Assert.IsNotNull(criterium, "There should be a criterium");

            Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(-1, DenseVector.Create(3, i => 4), DenseVector.Create(3, i => 5), DenseVector.Create(3, i => 6)));
        }
        public void DetermineStatus()
        {
            var criterium = new FailureStopCriterium();
            Assert.IsNotNull(criterium, "There should be a criterium");

            var solution = new DenseVector(new[] { 3.0, 2.0, 1.0 });
            var source = new DenseVector(new[] { 1001.0, 0.0, 2003.0 });
            var residual = new DenseVector(new[] { 1.0, 2.0, 3.0 });

            var status = criterium.DetermineStatus(5, solution, source, residual);
            Assert.AreEqual(IterationStatus.Continue, status, "Should be running");
        }
        public void DetermineStatusWithNonMatchingVectorsThrowsArgumentException()
        {
            var criterium = new FailureStopCriterium();
            Assert.IsNotNull(criterium, "There should be a criterium");

            Assert.Throws<ArgumentException>(() => criterium.DetermineStatus(1, DenseVector.Create(3, i => 4), DenseVector.Create(3, i => 6), DenseVector.Create(4, i => 4)));
        }
        public void DetermineStatusWithSolutionNaN()
        {
            var criterium = new FailureStopCriterium();
            Assert.IsNotNull(criterium, "There should be a criterium");

            var solution = new DenseVector(new[] { 1.0, 1.0, double.NaN });
            var source = new DenseVector(new[] { 1001.0, 0.0, 2003.0 });
            var residual = new DenseVector(new[] { 1000.0, 1000.0, 2001.0 });

            var status = criterium.DetermineStatus(5, solution, source, residual);
            Assert.AreEqual(IterationStatus.Failure, status, "Should be failed");
        }
        public void ResetCalculationState()
        {
            var criterium = new FailureStopCriterium();
            Assert.IsNotNull(criterium, "There should be a criterium");

            var solution = new DenseVector(new[] { 1.0, 1.0, 2.0 });
            var source = new DenseVector(new[] { 1001.0, 0.0, 2003.0 });
            var residual = new DenseVector(new[] { 1000.0, 1000.0, 2001.0 });

            var status = criterium.DetermineStatus(5, solution, source, residual);
            Assert.AreEqual(IterationStatus.Running, status, "Should be running");

            criterium.ResetToPrecalculationState();
            Assert.AreEqual(IterationStatus.Indetermined, criterium.Status, "Should not have started");
        }