public void TestVectorOperations() { VectorOperations.Sub(_a, _b, ref _dest); Assert.AreEqual(-2.0, _dest[0], FloatComparison.DefaultEps); Assert.AreEqual(-2.0, _dest[1], FloatComparison.DefaultEps); VectorOperations.Add(_a, _b, ref _dest); Assert.AreEqual(4.0, _dest[0], FloatComparison.DefaultEps); Assert.AreEqual(6.0, _dest[1], FloatComparison.DefaultEps); VectorOperations.ScalarMul(_a, 2, ref _dest); Assert.AreEqual(2.0, _dest[0], FloatComparison.DefaultEps); Assert.AreEqual(4.0, _dest[1], FloatComparison.DefaultEps); VectorOperations.Copy(_a, ref _dest); Assert.AreEqual(1.0, _dest[0], FloatComparison.DefaultEps); Assert.AreEqual(2.0, _dest[1], FloatComparison.DefaultEps); VectorOperations.Normalize(_a, ref _dest); Assert.AreEqual(0.44721359549995793, _dest[0], FloatComparison.DefaultEps); Assert.AreEqual(0.89442719099991586, _dest[1], FloatComparison.DefaultEps); VectorOperations.Fill(ref _dest, 5.0); Assert.AreEqual(5.0, _dest[0], FloatComparison.DefaultEps); Assert.AreEqual(5.0, _dest[1], FloatComparison.DefaultEps); }
public void TestCopy() { Vector a = Vector.Create(3.0, 4.0); Vector b = new Vector(2); VectorOperations.Copy(a, ref b); Assert.IsTrue(VectorComparison.Close(a, b, FloatComparison.DefaultEps)); }