public void CorrectlyMultiplyByAnotherVector() { var valuesX = new[] { new RealNumber(1.0), new RealNumber(2.0), new RealNumber(-1.0) }; IVector vectorX = new Vector(valuesX); var valuesY = new[] { new RealNumber(4.0), new RealNumber(-2.0), new RealNumber(0.0) }; IVector vectorY = new Vector(valuesY); var result = vectorX.Mul(vectorY); Assert.That(result.GetMod().X, Is.EqualTo(new RealNumber(0.0).GetMod().X)); }
public void CorrectlyMultiplyByFuzzyNumber() { var values = new[] { new RealNumber(1.0), new RealNumber(2.0), new RealNumber(-1.0) }; IVector vector = new Vector(values); var multiplier = new RealNumber(3.0); vector = vector.Mul(multiplier); Assert.That(vector.Length, Is.EqualTo(3)); Assert.That(vector[0].GetMod().X, Is.EqualTo(new RealNumber(3.0).GetMod().X)); Assert.That(vector[1].GetMod().X, Is.EqualTo(new RealNumber(6.0).GetMod().X)); Assert.That(vector[2].GetMod().X, Is.EqualTo(new RealNumber(-3.0).GetMod().X)); }
public void ProvideCommutativeMultiplication() { var valuesX = new[] { new RealNumber(1.0), new RealNumber(2.0), new RealNumber(-1.0) }; IVector vectorX = new Vector(valuesX); var valuesY = new[] { new RealNumber(4.0), new RealNumber(-2.0), new RealNumber(0.0) }; IVector vectorY = new Vector(valuesY); var resultXY = vectorX.Mul(vectorY); var resultYX = vectorY.Mul(vectorX); Assert.That(resultXY.GetMod().X, Is.EqualTo(resultYX.GetMod().X)); }