Пример #1
0
        public void NormalizeZero()
        {
            Assert.True(Avx.IsSupported);

            vec1 = new Vec3[8] {
                new Vec3(0, 0, 0), new Vec3(1, 1, 1), new Vec3(2, 3, 4), new Vec3(2, 3, 4), new Vec3(0, 0, 0), new Vec3(0, 0, 0), new Vec3(6, 5, 2), new Vec3(0, 0, 0)
            };
            vec2 = new Vec3[8] {
                new Vec3(1, 1, 1), new Vec3(0, 0, 0), new Vec3(0, 0, 0), Vec3.backward, Vec3.forward, Vec3.left, Vec3.down, Vec3.up
            };
            result = new Vec3[8];
            actual = new Vec3[8];


            Vector3Fallbacks.Normalize(vec1, result);
            Vector3Avx.NormalizeAvx2(vec1, actual);

            for (int i = 0; i < 8; i++)
            {
                Assert.True(result[i].ApproximatelyEquals(actual[i]),
                            $"index: {i}, result: {result[i]}, actual: {actual[i]}");
            }

            Vector3Fallbacks.Normalize(vec2, result);
            Vector3Avx.Normalize(vec2, actual);

            for (int i = 0; i < 8; i++)
            {
                Assert.True(result[i].ApproximatelyEquals(actual[i]),
                            $"index: {i}, result: {result[i]}, actual: {actual[i]}");
            }
        }
Пример #2
0
        public void NormalizeAvx2()
        {
            Assert.True(Avx2.IsSupported);
            initializeArrays();

            Vector3Fallbacks.Normalize(vec1, result);
            Vector3Avx.NormalizeAvx2(vec1, actual);

            for (int i = 0; i < arrLength; i++)
            {
                Assert.True(result[i].ApproximatelyEquals(actual[i]),
                            $"index: {i}, result: {result[i]}, actual: {actual[i]}");
            }
        }