GetCol() public method

Get one column from this matrix as a column matrix.
public GetCol ( int col ) : Matrix
col int The desired column.
return Matrix
Esempio n. 1
0
        public void GetCol()
        {
            double[][] matrixData1 =
            {
                new[] { 1.0, 2.0 },
                new[] { 3.0, 4.0 }
            };
            double[][] matrixData2 =
            {
                new[] { 2.0 },
                new[] { 4.0 }
            };

            var matrix1 = new Matrix(matrixData1);
            var matrix2 = new Matrix(matrixData2);

            Matrix matrixCol = matrix1.GetCol(1);

            Assert.IsTrue(matrixCol.Equals(matrix2));

            try
            {
                matrix1.GetCol(3);
                Assert.IsTrue(false);
            }
            catch (MatrixError)
            {
                Assert.IsTrue(true);
            }
        }
        public void GetCol()
        {
            double[][] matrixData1 = {
                                         new[] {1.0, 2.0},
                                         new[] {3.0, 4.0}
                                     };
            double[][] matrixData2 = {
                                         new[] {2.0},
                                         new[] {4.0}
                                     };

            var matrix1 = new Matrix(matrixData1);
            var matrix2 = new Matrix(matrixData2);

            Matrix matrixCol = matrix1.GetCol(1);
            Assert.IsTrue(matrixCol.Equals(matrix2));

            try
            {
                matrix1.GetCol(3);
                Assert.IsTrue(false);
            }
            catch (MatrixError)
            {
                Assert.IsTrue(true);
            }
        }