コード例 #1
0
        public void Clone()
        {
            var criterium = new FailureStopCriterium();
            Assert.IsNotNull(criterium, "There should be a criterium");

            var clone = criterium.Clone();
            Assert.IsInstanceOf(typeof (FailureStopCriterium), clone, "Wrong criterium type");
        }
コード例 #2
0
        public void DetermineStatus()
        {
            var criterium = new FailureStopCriterium();
            Assert.IsNotNull(criterium, "There should be a criterium");

            var solution = new DenseVector(new[] {new Complex32(3.0f, 0), new Complex32(2.0f, 0), new Complex32(1, 0)});
            var source = new DenseVector(new[] {new Complex32(1001.0f, 0), Complex32.Zero, new Complex32(2003.0f, 0)});
            var residual = new DenseVector(new[] {new Complex32(1.0f, 0), new Complex32(2.0f, 0), new Complex32(3, 0)});

            var status = criterium.DetermineStatus(5, solution, source, residual);
            Assert.AreEqual(IterationStatus.Continue, status, "Should be running");
        }
コード例 #3
0
        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)));
        }
コード例 #4
0
 public void Create()
 {
     var criterium = new FailureStopCriterium();
     Assert.IsNotNull(criterium, "Should have a criterium now");
 }
コード例 #5
0
        public void DetermineStatusWithSolutionNaN()
        {
            var criterium = new FailureStopCriterium();
            Assert.IsNotNull(criterium, "There should be a criterium");

            var solution = new DenseVector(new[] {new Complex32(1.0f, 0), new Complex32(1.0f, 0), new Complex32(float.NaN, 0)});
            var source = new DenseVector(new[] {new Complex32(1001.0f, 0), Complex32.Zero, new Complex32(2003.0f, 0)});
            var residual = new DenseVector(new[] {new Complex32(1000, 0), new Complex32(1000, 0), new Complex32(2001, 0)});

            var status = criterium.DetermineStatus(5, solution, source, residual);
            Assert.AreEqual(IterationStatus.Failure, status, "Should be failed");
        }
コード例 #6
0
        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)));
        }
コード例 #7
0
        public void ResetCalculationState()
        {
            var criterium = new FailureStopCriterium();
            Assert.IsNotNull(criterium, "There should be a criterium");

            var solution = new DenseVector(new[] {new Complex32(1.0f, 0), new Complex32(1.0f, 0), new Complex32(2, 0)});
            var source = new DenseVector(new[] {new Complex32(1001.0f, 0), Complex32.Zero, new Complex32(2003.0f, 0)});
            var residual = new DenseVector(new[] {new Complex32(1000, 0), new Complex32(1000, 0), new Complex32(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");
        }