Exemplo n.º 1
0
        public void InfinitelyManySolutions()
        {
            int n = 3;
            SysOfLinearEquation s = new SysOfLinearEquation(n);

            s.Add(new LinearEquation("3, 2,-4, 7"));
            s.Add(new LinearEquation("6, 4, -8, 15"));
            s.Add(new LinearEquation("6, 4, -8, 15"));
            s.StepUp();
            Assert.Equals(typeof(ArgumentException), s.Solve());
        }
Exemplo n.º 2
0
        public void CorrectAnswer()
        {
            int n = 3;
            SysOfLinearEquation s = new SysOfLinearEquation(n);

            s.Add(new LinearEquation("3, 2, -4, 3"));
            s.Add(new LinearEquation("2, 3, 3, 15"));
            s.Add(new LinearEquation("5, -3, 1, 14"));
            s.StepUp();
            double[] solve1 = new double[] { 3, 1, 2 };
            double[] solve2 = s.Solve();
            bool     check  = true;

            for (int i = 0; i < n; i++)
            {
                if (Math.Abs(solve1[i] - solve2[i]) > 1e-9)
                {
                    check = false;
                }
            }
            Assert.AreEqual(true, check);
        }