コード例 #1
0
ファイル: Test4x1.cs プロジェクト: iliveoncaffiene/corefxlab
        public void ConstructorValuesAreAccessibleByIndexer()
        {
            Matrix4x1 matrix4x1;

            matrix4x1 = new Matrix4x1();

            for (int x = 0; x < matrix4x1.Columns; x++)
            {
                for (int y = 0; y < matrix4x1.Rows; y++)
                {
                    Assert.AreEqual(0, matrix4x1[x, y], Epsilon);
                }
            }

            double value = 33.33;
            matrix4x1 = new Matrix4x1(value);

            for (int x = 0; x < matrix4x1.Columns; x++)
            {
                for (int y = 0; y < matrix4x1.Rows; y++)
                {
                    Assert.AreEqual(value, matrix4x1[x, y], Epsilon);
                }
            }

            GenerateFilledMatrixWithValues(out matrix4x1);

            for (int y = 0; y < matrix4x1.Rows; y++)
            {
                for (int x = 0; x < matrix4x1.Columns; x++)
                {
                    Assert.AreEqual(y * matrix4x1.Columns + x, matrix4x1[x, y], Epsilon);
                }
            }
        }
コード例 #2
0
ファイル: Test4x4.cs プロジェクト: zsybupt/corefxlab
        public void RowAccessorAreCorrect()
        {
            GenerateFilledMatrixWithValues(out Matrix4x4 value);


            Matrix4x1 row1 = value.Row1;

            for (int x = 0; x < value.Columns; x++)
            {
                Assert.Equal(value[x, 0], row1[x, 0]);
            }

            Matrix4x1 row2 = value.Row2;

            for (int x = 0; x < value.Columns; x++)
            {
                Assert.Equal(value[x, 1], row2[x, 0]);
            }

            Matrix4x1 row3 = value.Row3;

            for (int x = 0; x < value.Columns; x++)
            {
                Assert.Equal(value[x, 2], row3[x, 0]);
            }
        }
コード例 #3
0
ファイル: Test4x1.cs プロジェクト: zsybupt/corefxlab
        public void EqualityOperatorWorksCorrectly()
        {
            Matrix4x1 value1 = new Matrix4x1(100);
            Matrix4x1 value2 = new Matrix4x1(50) * 2;

            Assert.Equal(value1, value2);
            Assert.True(value1 == value2, "Equality operator failed.");
        }
コード例 #4
0
ファイル: Test4x1.cs プロジェクト: zsybupt/corefxlab
        public void ConstantValuesAreCorrect()
        {
            Matrix4x1 matrix4x1 = new Matrix4x1();

            Assert.Equal(4, matrix4x1.Columns);
            Assert.Equal(1, matrix4x1.Rows);
            Assert.Equal(Matrix4x1.ColumnCount, matrix4x1.Columns);
            Assert.Equal(Matrix4x1.RowCount, matrix4x1.Rows);
        }
コード例 #5
0
ファイル: Test2x1.cs プロジェクト: yizhang82/corefxlab
        public void MuliplyByMatrix4x2ProducesMatrix4x1()
        {
            Matrix2x1 matrix1  = new Matrix2x1(3);
            Matrix4x2 matrix2  = new Matrix4x2(2);
            Matrix4x1 result   = matrix1 * matrix2;
            Matrix4x1 expected = new Matrix4x1(12, 12, 12, 12);

            Assert.Equal(expected, result);
        }
コード例 #6
0
ファイル: Test4x1.cs プロジェクト: iliveoncaffiene/corefxlab
        public void ConstantValuesAreCorrect()
        {
            Matrix4x1 matrix4x1 = new Matrix4x1();

            Assert.AreEqual(4, matrix4x1.Columns);
            Assert.AreEqual(1, matrix4x1.Rows);
            Assert.AreEqual(Matrix4x1.ColumnCount, matrix4x1.Columns);
            Assert.AreEqual(Matrix4x1.RowCount, matrix4x1.Rows);
        }
コード例 #7
0
ファイル: Test4x1.cs プロジェクト: zsybupt/corefxlab
        public void MuliplyByMatrix4x4ProducesMatrix4x1()
        {
            Matrix4x1 matrix1  = new Matrix4x1(3);
            Matrix4x4 matrix2  = new Matrix4x4(2);
            Matrix4x1 result   = matrix1 * matrix2;
            Matrix4x1 expected = new Matrix4x1(24, 24, 24, 24);

            Assert.Equal(expected, result);
        }
コード例 #8
0
ファイル: Test4x1.cs プロジェクト: zsybupt/corefxlab
        public void AccessorThrowsWhenOutOfBounds()
        {
            Matrix4x1 matrix4x1 = new Matrix4x1();

            Assert.Throws <ArgumentOutOfRangeException>(() => { matrix4x1[-1, 0] = 0; });
            Assert.Throws <ArgumentOutOfRangeException>(() => { matrix4x1[0, -1] = 0; });
            Assert.Throws <ArgumentOutOfRangeException>(() => { matrix4x1[4, 0] = 0; });
            Assert.Throws <ArgumentOutOfRangeException>(() => { matrix4x1[0, 1] = 0; });
        }
コード例 #9
0
        public void MuliplyByMatrix4x3ProducesMatrix4x1()
        {
            Matrix3x1 matrix1  = new Matrix3x1(3);
            Matrix4x3 matrix2  = new Matrix4x3(2);
            Matrix4x1 result   = matrix1 * matrix2;
            Matrix4x1 expected = new Matrix4x1(18, 18, 18, 18);

            Assert.Equal(expected, result);
        }
コード例 #10
0
        public void MuliplyByMatrix4x1ProducesMatrix4x2()
        {
            Matrix1x2 matrix1  = new Matrix1x2(3);
            Matrix4x1 matrix2  = new Matrix4x1(2);
            Matrix4x2 result   = matrix1 * matrix2;
            Matrix4x2 expected = new Matrix4x2(6, 6, 6, 6,
                                               6, 6, 6, 6);

            Assert.Equal(expected, result);
        }
コード例 #11
0
    static Matrix4x1 mul(Matrix4x4 A, Matrix4x1 B) // float4x1 mul(float4x4 A, float4x1 B);
    {
        Matrix4x1 result = new Matrix4x1();

        result.m00 = (float)((double)A.m00 * (double)B.m00 + (double)A.m01 * (double)B.m10 + (double)A.m02 * (double)B.m20 + (double)A.m03 * (double)B.m30);
        result.m10 = (float)((double)A.m10 * (double)B.m00 + (double)A.m11 * (double)B.m10 + (double)A.m12 * (double)B.m20 + (double)A.m13 * (double)B.m30);
        result.m20 = (float)((double)A.m20 * (double)B.m00 + (double)A.m21 * (double)B.m10 + (double)A.m22 * (double)B.m20 + (double)A.m23 * (double)B.m30);
        result.m30 = (float)((double)A.m30 * (double)B.m00 + (double)A.m31 * (double)B.m10 + (double)A.m32 * (double)B.m20 + (double)A.m33 * (double)B.m30);
        return(result);
    }
コード例 #12
0
ファイル: Test4x1.cs プロジェクト: zsybupt/corefxlab
        public void HashCodeGenerationWorksCorrectly()
        {
            HashSet <int> hashCodes = new HashSet <int>();
            Matrix4x1     value     = new Matrix4x1(1);

            for (int i = 2; i <= 100; i++)
            {
                Assert.True(hashCodes.Add(value.GetHashCode()), "Unique hash code generation failure.");

                value *= i;
            }
        }
コード例 #13
0
ファイル: Test4x1.cs プロジェクト: zsybupt/corefxlab
        public void SimpleSubtractionGeneratesCorrectValues()
        {
            Matrix4x1 value1 = new Matrix4x1(100);
            Matrix4x1 value2 = new Matrix4x1(1);
            Matrix4x1 result = value1 - value2;

            for (int y = 0; y < Matrix4x1.RowCount; y++)
            {
                for (int x = 0; x < Matrix4x1.ColumnCount; x++)
                {
                    Assert.Equal(100 - 1, result[x, y], Epsilon);
                }
            }
        }
コード例 #14
0
        public void RowAccessorAreCorrect()
        {
            Matrix4x2 value;

            GenerateFilledMatrixWithValues(out value);


            Matrix4x1 row1 = value.Row1;

            for (int x = 0; x < value.Columns; x++)
            {
                Assert.Equal(value[x, 0], row1[x, 0]);
            }
        }
コード例 #15
0
ファイル: Test4x1.cs プロジェクト: zsybupt/corefxlab
        public void ScalarMultiplicationIsCorrect()
        {
            GenerateFilledMatrixWithValues(out Matrix4x1 matrix4x1);

            for (double c = -10; c <= 10; c += 0.5)
            {
                Matrix4x1 result = matrix4x1 * c;

                for (int y = 0; y < matrix4x1.Rows; y++)
                {
                    for (int x = 0; x < matrix4x1.Columns; x++)
                    {
                        Assert.Equal(matrix4x1[x, y] * c, result[x, y], Epsilon);
                    }
                }
            }
        }
コード例 #16
0
ファイル: Test4x1.cs プロジェクト: zsybupt/corefxlab
        public void MemberGetAndSetValuesCorrectly()
        {
            Matrix4x1 matrix4x1 = new Matrix4x1();

            matrix4x1.M11 = 0;
            matrix4x1.M21 = 1;
            matrix4x1.M31 = 2;
            matrix4x1.M41 = 3;

            Assert.Equal(0, matrix4x1.M11, Epsilon);
            Assert.Equal(1, matrix4x1.M21, Epsilon);
            Assert.Equal(2, matrix4x1.M31, Epsilon);
            Assert.Equal(3, matrix4x1.M41, Epsilon);

            Assert.Equal(matrix4x1[0, 0], matrix4x1.M11, Epsilon);
            Assert.Equal(matrix4x1[1, 0], matrix4x1.M21, Epsilon);
            Assert.Equal(matrix4x1[2, 0], matrix4x1.M31, Epsilon);
            Assert.Equal(matrix4x1[3, 0], matrix4x1.M41, Epsilon);
        }
コード例 #17
0
ファイル: Test4x1.cs プロジェクト: zsybupt/corefxlab
        public void IndexerGetAndSetValuesCorrectly()
        {
            Matrix4x1 matrix4x1 = new Matrix4x1();

            for (int x = 0; x < matrix4x1.Columns; x++)
            {
                for (int y = 0; y < matrix4x1.Rows; y++)
                {
                    matrix4x1[x, y] = y * matrix4x1.Columns + x;
                }
            }

            for (int y = 0; y < matrix4x1.Rows; y++)
            {
                for (int x = 0; x < matrix4x1.Columns; x++)
                {
                    Assert.Equal(y * matrix4x1.Columns + x, matrix4x1[x, y], Epsilon);
                }
            }
        }
コード例 #18
0
ファイル: Test4x1.cs プロジェクト: TerabyteX/corefxlab
        public void IndexerGetAndSetValuesCorrectly()
        {
            Matrix4x1 matrix4x1 = new Matrix4x1();

            for (int x = 0; x < matrix4x1.Columns; x++)
            {
                for (int y = 0; y < matrix4x1.Rows; y++)
                {
                    matrix4x1[x, y] = y * matrix4x1.Columns + x;
                }
            }

            for (int y = 0; y < matrix4x1.Rows; y++)
            {
                for (int x = 0; x < matrix4x1.Columns; x++)
                {
                    Assert.Equal(y * matrix4x1.Columns + x, matrix4x1[x, y], Epsilon);
                }
            }
        }
コード例 #19
0
ファイル: Test4x1.cs プロジェクト: zsybupt/corefxlab
        public void ConstructorValuesAreAccessibleByIndexer()
        {
            Matrix4x1 matrix4x1;

            matrix4x1 = new Matrix4x1();

            for (int x = 0; x < matrix4x1.Columns; x++)
            {
                for (int y = 0; y < matrix4x1.Rows; y++)
                {
                    Assert.Equal(0, matrix4x1[x, y], Epsilon);
                }
            }

            double value = 33.33;

            matrix4x1 = new Matrix4x1(value);

            for (int x = 0; x < matrix4x1.Columns; x++)
            {
                for (int y = 0; y < matrix4x1.Rows; y++)
                {
                    Assert.Equal(value, matrix4x1[x, y], Epsilon);
                }
            }

            GenerateFilledMatrixWithValues(out matrix4x1);

            for (int y = 0; y < matrix4x1.Rows; y++)
            {
                for (int x = 0; x < matrix4x1.Columns; x++)
                {
                    Assert.Equal(y * matrix4x1.Columns + x, matrix4x1[x, y], Epsilon);
                }
            }
        }
コード例 #20
0
ファイル: Test4x1.cs プロジェクト: iliveoncaffiene/corefxlab
        public void AccessorThrowsWhenOutOfBounds()
        {
            Matrix4x1 matrix4x1 = new Matrix4x1();

            try
            {
                matrix4x1[-1, 0] = 0;
                Assert.Fail("Matrix4x1[-1, 0] did not throw when it should have.");
            }
            catch (ArgumentOutOfRangeException)
            { }

            try
            {
                matrix4x1[0, -1] = 0;
                Assert.Fail("Matrix4x1[0, -1] did not throw when it should have.");
            }
            catch (ArgumentOutOfRangeException)
            { }

            try
            {
                matrix4x1[4, 0] = 0;
                Assert.Fail("Matrix4x1[4, 0] did not throw when it should have.");
            }
            catch (ArgumentOutOfRangeException)
            { }

            try
            {
                matrix4x1[0, 1] = 0;
                Assert.Fail("Matrix4x1[0, 1] did not throw when it should have.");
            }
            catch (ArgumentOutOfRangeException)
            { }
        }
コード例 #21
0
ファイル: Test4x1.cs プロジェクト: zsybupt/corefxlab
 private void GenerateFilledMatrixWithValues(out Matrix4x1 matrix)
 {
     matrix = new Matrix4x1(0, 1, 2, 3);
 }
コード例 #22
0
ファイル: Test4x1.cs プロジェクト: iliveoncaffiene/corefxlab
 private void GenerateFilledMatrixWithValues(out Matrix4x1 matrix)
 {
     matrix = new Matrix4x1(0, 1, 2, 3);
 }
コード例 #23
0
ファイル: Test4x1.cs プロジェクト: iliveoncaffiene/corefxlab
        public void SimpleSubtractionGeneratesCorrectValues()
        {
            Matrix4x1 value1 = new Matrix4x1(100);
            Matrix4x1 value2 = new Matrix4x1(1);
            Matrix4x1 result = value1 - value2;

            for (int y = 0; y < Matrix4x1.RowCount; y++)
            {
                for (int x = 0; x < Matrix4x1.ColumnCount; x++)
                {
                    Assert.AreEqual(100 - 1, result[x, y], Epsilon);
                }
            }
        }
コード例 #24
0
ファイル: Test2x1.cs プロジェクト: iliveoncaffiene/corefxlab
        public void MuliplyByMatrix4x2ProducesMatrix4x1()
        {
            Matrix2x1 matrix1 = new Matrix2x1(3);
            Matrix4x2 matrix2 = new Matrix4x2(2);
            Matrix4x1 result = matrix1 * matrix2;
            Matrix4x1 expected = new Matrix4x1(12, 12, 12, 12);

            Assert.AreEqual(expected, result);
        }
コード例 #25
0
ファイル: Test4x1.cs プロジェクト: iliveoncaffiene/corefxlab
        public void MemberGetAndSetValuesCorrectly()
        {
            Matrix4x1 matrix4x1 = new Matrix4x1();

            matrix4x1.M11 = 0;
            matrix4x1.M21 = 1;
            matrix4x1.M31 = 2;
            matrix4x1.M41 = 3;

            Assert.AreEqual(0, matrix4x1.M11, Epsilon);
            Assert.AreEqual(1, matrix4x1.M21, Epsilon);
            Assert.AreEqual(2, matrix4x1.M31, Epsilon);
            Assert.AreEqual(3, matrix4x1.M41, Epsilon);

            Assert.AreEqual(matrix4x1[0, 0], matrix4x1.M11, Epsilon);
            Assert.AreEqual(matrix4x1[1, 0], matrix4x1.M21, Epsilon);
            Assert.AreEqual(matrix4x1[2, 0], matrix4x1.M31, Epsilon);
            Assert.AreEqual(matrix4x1[3, 0], matrix4x1.M41, Epsilon);
        }
コード例 #26
0
ファイル: Test4x1.cs プロジェクト: iliveoncaffiene/corefxlab
        public void HashCodeGenerationWorksCorrectly()
        {
            HashSet<int> hashCodes = new HashSet<int>();
            Matrix4x1 value = new Matrix4x1(1);

            for (int i = 2; i <= 100; i++)
            {
                if (!hashCodes.Add(value.GetHashCode()))
                {
                    Assert.Fail("Unique hash code generation failure.");
                }

                value *= i;
            }
        }
コード例 #27
0
ファイル: Test4x1.cs プロジェクト: iliveoncaffiene/corefxlab
        public void EqualityOperatorWorksCorrectly()
        {
            Matrix4x1 value1 = new Matrix4x1(100);
            Matrix4x1 value2 = new Matrix4x1(50) * 2;

            Assert.AreEqual(value1, value2);
            Assert.IsTrue(value1 == value2, "Equality operator failed.");
        }
コード例 #28
0
ファイル: Test1x3.cs プロジェクト: kronic/corefxlab
        public void MuliplyByMatrix4x1ProducesMatrix4x3()
        {
            Matrix1x3 matrix1 = new Matrix1x3(3);
            Matrix4x1 matrix2 = new Matrix4x1(2);
            Matrix4x3 result = matrix1 * matrix2;
            Matrix4x3 expected = new Matrix4x3(6, 6, 6, 6, 
                                               6, 6, 6, 6, 
                                               6, 6, 6, 6);

            Assert.Equal(expected, result);
        }
コード例 #29
0
ファイル: Test4x1.cs プロジェクト: iliveoncaffiene/corefxlab
        public void MuliplyByMatrix4x4ProducesMatrix4x1()
        {
            Matrix4x1 matrix1 = new Matrix4x1(3);
            Matrix4x4 matrix2 = new Matrix4x4(2);
            Matrix4x1 result = matrix1 * matrix2;
            Matrix4x1 expected = new Matrix4x1(24, 24, 24, 24);

            Assert.AreEqual(expected, result);
        }
コード例 #30
0
ファイル: Test4x1.cs プロジェクト: TerabyteX/corefxlab
        public void SimpleAdditionGeneratesCorrectValues()
        {
            Matrix4x1 value1 = new Matrix4x1(1);
            Matrix4x1 value2 = new Matrix4x1(99);
            Matrix4x1 result = value1 + value2;

            for (int y = 0; y < Matrix4x1.RowCount; y++)
            {
                for (int x = 0; x < Matrix4x1.ColumnCount; x++)
                {
                    Assert.Equal(1 + 99, result[x, y], Epsilon);
                }
            }
        }
コード例 #31
0
ファイル: Test3x1.cs プロジェクト: iliveoncaffiene/corefxlab
        public void MuliplyByMatrix4x3ProducesMatrix4x1()
        {
            Matrix3x1 matrix1 = new Matrix3x1(3);
            Matrix4x3 matrix2 = new Matrix4x3(2);
            Matrix4x1 result = matrix1 * matrix2;
            Matrix4x1 expected = new Matrix4x1(18, 18, 18, 18);

            Assert.AreEqual(expected, result);
        }
コード例 #32
0
ファイル: Test1x2.cs プロジェクト: iliveoncaffiene/corefxlab
        public void MuliplyByMatrix4x1ProducesMatrix4x2()
        {
            Matrix1x2 matrix1 = new Matrix1x2(3);
            Matrix4x1 matrix2 = new Matrix4x1(2);
            Matrix4x2 result = matrix1 * matrix2;
            Matrix4x2 expected = new Matrix4x2(6, 6, 6, 6,
                                               6, 6, 6, 6);

            Assert.AreEqual(expected, result);
        }
コード例 #33
0
ファイル: Test4x1.cs プロジェクト: TerabyteX/corefxlab
        public void AccessorThrowsWhenOutOfBounds()
        {
            Matrix4x1 matrix4x1 = new Matrix4x1();

            Assert.Throws<ArgumentOutOfRangeException>(() => { matrix4x1[-1, 0] = 0; });
            Assert.Throws<ArgumentOutOfRangeException>(() => { matrix4x1[0, -1] = 0; });
            Assert.Throws<ArgumentOutOfRangeException>(() => { matrix4x1[4, 0] = 0; });
            Assert.Throws<ArgumentOutOfRangeException>(() => { matrix4x1[0, 1] = 0; });
        }