예제 #1
0
        public void SymmetricMatrixAccess()
        {
            SymmetricMatrix M = CreateSymmetricRandomMatrix(4, 1);

            // check column
            ColumnVector c = M.Column(1);

            Assert.IsTrue(c.Dimension == M.Dimension);
            for (int i = 0; i < c.Dimension; i++)
            {
                Assert.IsTrue(c[i] == M[i, 1]);
            }

            // check row
            RowVector r = M.Row(1);

            Assert.IsTrue(r.Dimension == M.Dimension);
            for (int i = 0; i < r.Dimension; i++)
            {
                Assert.IsTrue(r[i] == c[i]);
            }

            // check clone
            SymmetricMatrix MC = M.Copy();

            Assert.IsTrue(MC == M);
            Assert.IsFalse(MC != M);

            // check independence of clone
            MC[0, 1] += 1.0;
            Assert.IsFalse(MC == M);
            Assert.IsTrue(MC != M);

            // check that update was symmetric
            Assert.IsTrue(M[0, 1] == M[1, 0]);
        }