Esempio n. 1
0
        public void MatrixCreationTest()
        {
            Assert.True((new NMatrix(0, 1, null)).Invalid);
            Assert.True((new NMatrix(1, 0, null)).Invalid);
            Assert.True((new NMatrix(1, 1, null)).Invalid);
            Assert.False(
                (new NMatrix(1, 1, new double[] { 1.0 })).Invalid);
            var MatA = new NMatrix(2, 3,
                                   new double[] { 1, 2, 3, 4, 5, 6 });

            Assert.Equal(1, MatA[0]);
            Assert.Equal(2, MatA[1]);
            Assert.Equal(3, MatA[2]);
            Assert.Equal(4, MatA[3]);
            Assert.Equal(5, MatA[4]);
            Assert.Equal(6, MatA[5]);
            Assert.Equal(1, MatA[0, 0]);
            Assert.Equal(2, MatA[0, 1]);
            Assert.Equal(3, MatA[0, 2]);
            Assert.Equal(4, MatA[1, 0]);
            Assert.Equal(5, MatA[1, 1]);
            Assert.Equal(6, MatA[1, 2]);
            var MatB = new NMatrix(2, 3,
                                   new double[] { 1, 2, 3, 4, 5, 6 });

            Assert.True(MatA.Equals(MatB));
        }
Esempio n. 2
0
        private void DivTest()
        {
            var MatA = new NMatrix(2, 3,
                                   new double[]
            {
                1, 2, 3, 4, 5, 6
            });
            var MatDiv    = MatA.Div(-2);
            var MatAnswer = new NMatrix(MatA.Row, MatA.Col,
                                        new double[] {
                -0.5, -1, -1.5,
                -2, -2.5, -3
            });

            Assert.True(MatAnswer.Equals(MatDiv));
        }
Esempio n. 3
0
        private void MultTest()
        {
            var MatA = new NMatrix(2, 3,
                                   new double[]
            {
                1, 2, 3, 4, 5, 6
            });
            var MatMult   = MatA.Mult(-0.5);
            var MatAnswer = new NMatrix(MatA.Row, MatA.Col,
                                        new double[] {
                -0.5, -1, -1.5,
                -2, -2.5, -3
            });

            Assert.True(MatAnswer.Equals(MatMult));
        }