예제 #1
0
        public void CanSplitMatrixColumnsWhenColumnCountEquals()
        {
            var result = Matrix3By6.SplitColumns(6);

            result.Count.ShouldEqual(1);
            result[0].AsColumnMajorArray().ShouldArrayEqualWithinError(Matrix3By6.AsColumnMajorArray());
        }
예제 #2
0
        public void CanCloneMatrix()
        {
            var clone = Matrix3By6.CloneMatrix();

            clone.AsColumnMajorArray().ShouldArrayEqualWithinError(Matrix3By6.AsColumnMajorArray());

            clone[1, 1] = MathProvider.Scalar(42.0f);
            clone[1, 1].ShouldNotEqual(Matrix3By6[1, 1]);
        }
예제 #3
0
        public void CanSplitMatrixColumns()
        {
            var result = Matrix3By6.SplitColumns(2);

            result.Count.ShouldEqual(3);
            for (int i = 0; i < result.Count; i++)
            {
                result[i].AsColumnMajorArray().ShouldArrayEqualWithinError(Matrix3By6.SubMatrix(0, Matrix3By6.RowCount, i * 2, 2).AsColumnMajorArray());
            }
        }
예제 #4
0
        public void CanTileMatrixRows()
        {
            var result = Matrix3By6.TileRows(3);

            result.ShouldHaveSize(9, 6);

            var test = Matrix <T> .Build.DenseOfRows(Enumerable.Range(0, 3).SelectMany(x => Matrix3By6.EnumerateRows()));

            result.AsColumnMajorArray().ShouldArrayEqualWithinError(test.AsColumnMajorArray());
        }
예제 #5
0
        public void CanCompareMatrices()
        {
            MatrixFactory.ParseString <T>(@"1.0 2.0 3.0
                                                    4.0 5.0 6.0
                                                    7.0 8.0 9.0").EqualsTo(
                MatrixFactory.ParseString <T>(@"1.0 2.0 3.0
                                                    4.0 5.0 6.0
                                                    7.0 8.0 9.0")).ShouldBeTrue();

            Matrix3By6.EqualsTo(Matrix3By6_2).ShouldBeFalse();
            var self = Matrix3By6;

            self.EqualsTo(self).ShouldBeTrue();
            Matrix3By6.EqualsTo(Matrix5By3).ShouldBeFalse();

            var arr = MathProvider.Array(1, 2, 3, 4);
            var m1  = Matrix <T> .Build.Dense(2, 2, arr);

            var m2 = Matrix <T> .Build.Dense(2, 2, arr);

            m1.EqualsTo(m2).ShouldBeTrue();
        }
예제 #6
0
 public void CantSplitMatrixColumnsWhenInvalidColumnCount()
 {
     Trap.Exception(() => Matrix3By6.SplitColumns(7)).ShouldBeInstanceOf <ArgumentOutOfRangeException>();
     Trap.Exception(() => Matrix3By6.SplitColumns(5)).ShouldBeInstanceOf <ArgumentOutOfRangeException>();
 }