InsertMatrixAt() public method

Inserts the passed Matrix into this Matrix starting at the specified index
public InsertMatrixAt ( Matrix passedMatrix, int destinationRow, int destinationColumn ) : Matrix
passedMatrix Matrix
destinationRow int
destinationColumn int
return Matrix
        public void Matrix_RemoveRowsAndColumnsTest()
        {
            Matrix testMatrix = new Matrix(3,3);
            testMatrix.InsertMatrixAt(Matrix.IdentityMatrix(2), 1, 1);

            int[] rowsToRemove = { 0 };
            int[] columnsToRemove = { 0, 1 };

            Matrix actualMatrix = testMatrix.RemoveRows(rowsToRemove);
            actualMatrix = actualMatrix.RemoveColumns(columnsToRemove);

            Matrix expectedMatrix = new Matrix(2, 1);
            expectedMatrix.SetElement(1, 0, 1.0);

            (actualMatrix == expectedMatrix).Should().BeTrue();
        }
        /// <summary>
        /// Strips out all the elements from each submatrix and creates an equivalent matrix.
        /// For a more detailed explanation, see http://stackoverflow.com/questions/24678305/converting-a-2d-array-of-2d-arrays-into-a-single-2d-array
        /// </summary>
        public Matrix ConvertToMatrix()
        {
            //Creates a matrix big enough to hold all of the values in the MatricesMatrix
            Matrix returnMatrix = new Matrix(this.TotalRows(), this.TotalColumns());

            int nextRow = 0;
            int nextCol = 0;

            //Loop through the rows of this matrices matrix
            for (int row = 0; row < this.NumberOfRows; row++)
            {
                //Loop through the columns of this matrices matrix
                for (int col = 0; col < this.NumberOfColumns; col++)
                {
                    Matrix currentMatrix = this.GetElement(row, col);
                    returnMatrix.InsertMatrixAt(currentMatrix, nextRow, nextCol);
                    nextCol += this.GetColumnWidth(col); //The next column of the Matrix should be inserted a distance away that is equal to the total width of the current MatricesMatrix column
                }
                nextRow += this.GetRowHeight(row); //The next row of the Matrix should be inserted a distance away that is equal to the total height of the current MatricesMatrix row
                nextCol = 0;
            }

            return returnMatrix;
        }
        public void Matrix_InsertMatrixTest()
        {
            Matrix originalMatrix = new Matrix(3,3);

            double[] matrix1Row1 = { 1, 5, 6 };
            double[] matrix1Row2 = { 2, 4, 7 };
            double[] matrix1Row3 = { 3, 6, 8 };

            originalMatrix.SetRow(0, matrix1Row1);
            originalMatrix.SetRow(1, matrix1Row2);
            originalMatrix.SetRow(2, matrix1Row3);

            Matrix matrixToInsert = Matrix.IdentityMatrix(2);

            Matrix expectedResult = new Matrix(3,3);

            double[] expectedResultRow1 = { 1, 5, 6 };
            double[] expectedResultRow2 = { 1, 0, 7 };
            double[] expectedResultRow3 = { 0, 1, 8 };

            expectedResult.SetRow(0, expectedResultRow1);
            expectedResult.SetRow(1, expectedResultRow2);
            expectedResult.SetRow(2, expectedResultRow3);

            Matrix actualResult = originalMatrix.InsertMatrixAt(matrixToInsert, 1, 0);

            bool equalityResult = (actualResult == expectedResult);

            equalityResult.Should().BeTrue();

        }
        // --------------------------------------------------------------------------------------------------------------


        /// <summary>
        /// Solves for the column matrix x, where Ax = b.
        /// </summary>
        public Matrix SystemSolve(Matrix columnMatrix)
        {
            var augmentedMatrix = new Matrix(this.NumberOfRows, this.NumberOfColumns + 1);
            augmentedMatrix.InsertMatrixAt(this, 0, 0);
            augmentedMatrix.InsertMatrixAt(columnMatrix, 0, this.NumberOfColumns);

            var solution = SolveMatrix(augmentedMatrix.As2DArray);
            return new Matrix(solution);
        }