public void ArgumentExceptionTest()
        {
            double[,] A = { { 0, 0 }, { 0, 0 } };
            double[]             B      = { 0, 0 };
            LinearEquationSystem system = new LinearEquationSystem(A, B);

            Assert.Throws <ArgumentException>(() => system.Solve());
        }
        public void ThreedimensionalArrayTest()
        {
            double[,] A = { { 2, 1, -1 }, { 3, 2, 2 }, { 1, 0, 1 } };
            double[]             B        = { 3, -7, -2 };
            double[]             expected = { 1, -2, -3 };
            LinearEquationSystem system   = new LinearEquationSystem(A, B);
            var actual = system.Solve();

            CollectionAssert.AreEqual(expected, actual);
        }
        public void TwodimensionalArrayTest()
        {
            double[,] A = { { 1, 2 }, { 1, 3 } };
            double[]             B        = { 2, 1 };
            double[]             expected = { 4, -1 };
            LinearEquationSystem system   = new LinearEquationSystem(A, B);
            var actual = system.Solve();

            CollectionAssert.AreEqual(expected, actual);
        }
        public void CanSolveSimpleLinearEquationSystem()
        {
            // 2x = 1
            var equation = new LinearEquation
            {
                Coefficients = new[] { 2.0 },
                Result       = 1
            };
            var linearEquationSystem = new LinearEquationSystem(equation);

            Assert.AreEqual(0.5, linearEquationSystem.Solve()[0]);
        }
        public void CanSolveLinearEquationSystem()
        {
            // x - y + 2z = 6
            var firstEquation = new LinearEquation(new[] { 1.0, -1.0, 2.0 }, 6);
            // 2x + 3y + 2z = 11
            var secondEquation = new LinearEquation(new[] { 2.0, 3.0, 2.0 }, 11);
            // 3x + 2y + z = 8
            var thirdEquation = new LinearEquation(new[] { 3.0, 2.0, 1.0 }, 8);

            var linearEquationSystem = new LinearEquationSystem(firstEquation, secondEquation, thirdEquation);

            double[] results = linearEquationSystem.Solve();
            Assert.AreEqual(1, results[0]);
            Assert.AreEqual(1, results[1]);
            Assert.AreEqual(3, results[2]);
        }