Esempio n. 1
0
        public void ExecuteTest4()
        {
            var exp = new Sub(new ComplexNumber(7, 3), new Number(2));
            var expected = new Complex(5, 3);

            Assert.Equal(expected, exp.Execute());
        }
Esempio n. 2
0
        public void ExecuteTest6()
        {
            var exp = new Sub(new Number(2), new Sqrt(new Number(-9)));
            var expected = new Complex(2, -3);

            Assert.Equal(expected, exp.Execute());
        }
Esempio n. 3
0
        public void ExecuteTest3()
        {
            var exp = new Sub(new Number(7), new ComplexNumber(2, 4));
            var expected = new Complex(5, -4);

            Assert.Equal(expected, exp.Execute());
        }
Esempio n. 4
0
        public void MultiOpMulSub()
        {
            // ({1, 2, 3} * 4) - {2, 3, 4}
            var vector1 = new Vector(new[] { new Number(1), new Number(2), new Number(3) });
            var vector2 = new Vector(new[] { new Number(2), new Number(3), new Number(4) });
            var mul = new Mul(vector1, new Number(4));
            var sub = new Sub(mul, vector2);

            var expected = new Vector(new[] { new Number(2), new Number(5), new Number(8) });
            var result = sub.Execute();

            Assert.Equal(expected, result);
        }
Esempio n. 5
0
        public void ExecuteTest1()
        {
            var exp = new Sub(new Number(1), new Number(2));

            Assert.Equal(-1.0, exp.Execute());
        }
Esempio n. 6
0
        public void SubTwoVectorsTest()
        {
            var vector1 = new Vector(new[] { new Number(2), new Number(3) });
            var vector2 = new Vector(new[] { new Number(7), new Number(1) });
            var sub = new Sub(vector1, vector2);

            var expected = new Vector(new[] { new Number(-5), new Number(2) });
            var result = sub.Execute();

            Assert.Equal(expected, result);
        }
Esempio n. 7
0
        public void SubTwoMatricesTest()
        {
            var matrix1 = new Matrix(new[]
            {
                new Vector(new[] { new Number(6), new Number(3) }),
                new Vector(new[] { new Number(2), new Number(1) })
            });
            var matrix2 = new Matrix(new[]
            {
                new Vector(new[] { new Number(9), new Number(2) }),
                new Vector(new[] { new Number(4), new Number(3) })
            });
            var sub = new Sub(matrix1, matrix2);

            var expected = new Matrix(new[]
            {
                new Vector(new[] { new Number(-3), new Number(1) }),
                new Vector(new[] { new Number(-2), new Number(-2) })
            });
            var result = sub.Execute();

            Assert.Equal(expected, result);
        }
Esempio n. 8
0
        public void Sub4MatricesTest()
        {
            var vector1 = new Vector(new IExpression[] { new Number(1), new Number(2) });
            var vector2 = new Vector(new IExpression[] { new Number(1), new Number(2) });
            var vector3 = new Vector(new IExpression[] { new Number(1), new Number(2) });
            var vector4 = new Vector(new IExpression[] { new Number(1), new Number(2) });
            var sub1 = new Sub(vector1, vector2);
            var sub2 = new Sub(vector3, vector4);
            var sub3 = new Sub(sub1, sub2);

            var expected = new Vector(new IExpression[] { new Number(0), new Number(0) });

            Assert.Equal(expected, sub3.Execute());
        }