Ejemplo n.º 1
0
        public void Vector_Reshape_To_Matrix_2()
        {
            Vector v = new [] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            Matrix ans = new double[,]
            {
                { 1, 2 },
                { 3, 4 },
                { 5, 6 },
                { 7, 8 },
                { 9, 10 }
            };

            Matrix m = v.Reshape(2, VectorType.Col, VectorType.Col);

            Assert.Equal(v[0], ans[0, 0]);
            Assert.Equal(v[4], ans[2, 0]);
            Assert.Equal(v[5], ans[2, 1]);
            Assert.Equal(v[9], ans[4, 1]);
        }
Ejemplo n.º 2
0
        public void Vector_Reshape_To_Matrix_3()
        {
            Vector v = new [] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            Matrix ans = new double[,]
            {
                { 1, 6 },
                { 2, 7 },
                { 3, 8 },
                { 4, 9 },
                { 5, 10 }
            };

            Matrix m = v.Reshape(2, VectorType.Col, VectorType.Row);

            Assert.Equal(v[0], ans[0, 0]);
            Assert.Equal(v[4], ans[4, 0]);
            Assert.Equal(v[5], ans[0, 1]);
            Assert.Equal(v[9], ans[4, 1]);
        }
Ejemplo n.º 3
0
        public void Vector_Reshape_To_Matrix_1()
        {
            Vector v = new [] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            Matrix ans = new double[,]
            {
                { 1, 2, 3, 4, 5 },
                { 6, 7, 8, 9, 10 }
            };

            Matrix m = v.Reshape(5, VectorType.Col, VectorType.Col);

            Assert.Equal(v[0], ans[0, 0]);
            Assert.Equal(v[4], ans[0, 4]);
            Assert.Equal(v[5], ans[1, 0]);
            Assert.Equal(v[9], ans[1, 4]);
        }