/// <summary> /// Returns a new matrix with all of the specified rows removed /// </summary> public Matrix RemoveRows(int[] passedIndicesOfRowsToRemove) { Matrix returnMatrix = new Matrix(this); int[] indicesOfRowsToRemove = new int[passedIndicesOfRowsToRemove.Count()]; passedIndicesOfRowsToRemove.CopyTo(indicesOfRowsToRemove, 0); foreach (int rowToRemove in indicesOfRowsToRemove) { returnMatrix = returnMatrix.RemoveRow(rowToRemove); //Now that the matrix has shrunk by 1 row, all of the indices at or after that row need to be decreased by 1 int arrayIndex = 0; foreach (int index in indicesOfRowsToRemove) { if (index >= rowToRemove) { indicesOfRowsToRemove[arrayIndex] = index - 1; } arrayIndex++; } } return returnMatrix; }