public void TestDistanceVec4() { var outputs = Eval(() => Distance(vec4, vec4), V4fA, V4fB); var expected = V4fA.Zip(V4fB, (x, y) => (float)CpuLength(x.X - y.X, x.Y - y.Y, x.Z - y.Z, x.W - y.W)); foreach (var x in outputs.Zip(expected, (x, y) => new Tuple <float, float>(x.X, y))) { Assert.That(x.Item1, Is.EqualTo(x.Item2).Within(MaxErr).Ulps); } }
public void TestDotVec4() { var outputs = Eval(() => Dot(vec4, vec4), V4fA, V4fB); var expected = V4fA.Zip(V4fB, (x, y) => x.X * y.X + x.Y * y.Y + x.Z * y.Z + x.W * y.W); foreach (var x in outputs.Zip(expected, (x, y) => new Tuple <float, float>(x.X, y))) { Assert.That(x.Item1, Is.EqualTo(x.Item2).Within(MaxErr).Ulps); } }
public void TestPowVec4() { var outputs = Eval(() => Pow(vec4, vec4), V4fA, V4fB); var expected = V4fA.Zip(V4fB, (a, b) => new Tuple <float, float, float, float>((float)Math.Pow(a.X, b.X), (float)Math.Pow(a.Y, b.Y), (float)Math.Pow(a.Z, b.Z), (float)Math.Pow(a.W, b.W))); foreach (var x in outputs.Zip(expected, (x, y) => new Tuple <Vector4, float, float, float, float>(x, y.Item1, y.Item2, y.Item3, y.Item4))) { Assert.That(x.Item1.X, Is.EqualTo(x.Item2).Within(MaxErr).Ulps); Assert.That(x.Item1.Y, Is.EqualTo(x.Item3).Within(MaxErr).Ulps); Assert.That(x.Item1.Z, Is.EqualTo(x.Item4).Within(MaxErr).Ulps); Assert.That(x.Item1.W, Is.EqualTo(x.Item5).Within(MaxErr).Ulps); } }