public void AddTwoVectorsTest() { var vector1 = new Vector(new[] { new Number(2), new Number(3) }); var vector2 = new Vector(new[] { new Number(7), new Number(1) }); var add = new Add(vector1, vector2); var expected = new Vector(new[] { new Number(9), new Number(4) }); var result = add.Execute(); Assert.Equal(expected, result); }
public void Add4MatricesTest() { 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 add1 = new Add(vector1, vector2); var add2 = new Add(vector3, vector4); var add3 = new Add(add1, add2); var expected = new Vector(new IExpression[] { new Number(4), new Number(8) }); Assert.Equal(expected, add3.Execute()); }
public void AddTwoMatricesTest() { 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 add = new Add(matrix1, matrix2); var expected = new Matrix(new[] { new Vector(new[] { new Number(15), new Number(5) }), new Vector(new[] { new Number(6), new Number(4) }) }); var result = add.Execute(); Assert.Equal(expected, result); }
public void ExecuteTest2() { var exp = new Add(new Number(-3), new Number(2)); Assert.Equal(-1.0, exp.Execute()); }
public void ExecuteTest1() { var exp = new Add(new Number(1), new Number(2)); Assert.Equal(3.0, exp.Execute()); }
public void ExecuteTest6() { var exp = new Add(new Number(2), new Sqrt(new Number(-9))); var expected = new Complex(2, 3); Assert.Equal(expected, exp.Execute()); }
public void ExecuteTest5() { var exp = new Add(new ComplexNumber(7, 3), new Number(2)); var expected = new Complex(9, 3); Assert.Equal(expected, exp.Execute()); }
public void MultiOpMulAdd() { // ({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 add = new Add(mul, vector2); var expected = new Vector(new[] { new Number(6), new Number(11), new Number(16) }); var result = add.Execute(); Assert.Equal(expected, result); }