コード例 #1
0
        public void SetUpdatesMatrixEntry(int i, int j, double newValue)
        {
            Double[,] dblArray = new Double[,] {
                {0, 0, 0},
                {0, 0, 0},
                {0, 0, 0},
            };

            var symmMatrix = new SymmetricMatrix<Double>(Guid.NewGuid(), dblArray);
            symmMatrix.SetEdge(i, j, newValue);
            Assert.Equal(newValue, symmMatrix[i, j]);
        }
コード例 #2
0
        public void IsBinaryReturnsTrueAndFalseForInt32Matrix()
        {
            Int32[,] dblArray = new Int32[,] {
                {0, 0, 1, 0},
                {1, 1, 0, 0},
                {0, 0, 0, 0},
                {1, 0, 0, 1}
            };

            var symmMatrix = new SymmetricMatrix<Int32>(Guid.NewGuid(), dblArray);
            Assert.True(symmMatrix.IsBinary);

            symmMatrix.SetEdge(2, 2, 3);
            Assert.False(symmMatrix.IsBinary);
        }
コード例 #3
0
        public void SetEdgeThrowsExceptionIfIndexIsOutOfRange()
        {
            Int32[,] dblArray = new Int32[,] {
                {1, 2, 3},
                {2, 1, 2},
                {3, 2, 1}
            };

            var symmMatrix = new SymmetricMatrix<Int32>(Guid.NewGuid(), dblArray);
            Assert.Throws<IndexOutOfRangeException>(()
                => symmMatrix.SetEdge(4, 0, 3));
            Assert.Throws<IndexOutOfRangeException>(()
                => symmMatrix.SetEdge(1, -1, -10));
        }
コード例 #4
0
        public void IsBinaryReturnsTrueAndFalseForDoubleMatrix()
        {
            Double[,] dblArray = new Double[,] {
                {0, 0, 1, 0},
                {1, 1, 0, 0},
                {0, 0, 0, 0},
                {1, 0, 0, 1}
            };

            var symmMatrix = new SymmetricMatrix<Double>(Guid.NewGuid(), dblArray);
            Assert.True(symmMatrix.IsBinary);

            symmMatrix.SetEdge(2, 2, 1.444);
            Assert.False(symmMatrix.IsBinary);
        }