src/utils/matrix/AbstractMatrix.java
public Matrix split(int position, boolean splitVertically) throws MatrixException {
        if (!((this instanceof DMatrix) || (this instanceof SMatrix))) throw new MatrixException("Matrix must be of type DMatrix or SMatrix");
        Matrix matrix1;
        Matrix matrix2;
        int totalRows = getTotalRows();
        int totalColumns = getTotalColumns();
        if (splitVertically) {
            if (position < 1 || position > totalRows - 1) throw new MatrixException("For vertical split position is beyond number of rows in matrix.");
            matrix1 = getNewMatrix(position,totalColumns);
            matrix2 = getNewMatrix(totalRows - matrix1.getTotalRows(), totalColumns);
            for (int row = 0; row < totalRows; row++) {
                for (int column = 0; column < totalColumns; column++) {
                    if (row < position) matrix1.setValue(row, column, getValue(row, column));
                    else matrix2.setValue(row - position, column, getValue(row, column));
                }
            }
        }
        else {
            if (position < 1 || position > totalColumns - 1) throw new MatrixException("For vertical split position is beyond number of rows in matrix.");
            matrix1 = getNewMatrix(totalRows, position);
            matrix2 = getNewMatrix(totalRows, totalColumns - matrix1.getTotalColumns());
            for (int row = 0; row < totalRows; row++) {
                for (int column = 0; column < totalColumns; column++) {
                    if (column < position) matrix1.setValue(row, column, getValue(row, column));
                    else matrix2.setValue(row, column - position, getValue(row, column));
                }
            }
        }
        ArrayList<Matrix> matrices = new ArrayList<>();
        matrices.add(matrix1);
        matrices.add(matrix2);
        Matrix result = new JMatrix(matrices, splitVertically);
        if (hasProcedureFactory()) result.setProcedureFactory(procedureFactory);
        return result;
    }
/**
     * Splits matrix at defined position. If splitVertical is true splits vertically otherwise horizontally.
     *
     * @param position position of split
     * @param splitVertically if true splits vertically otherwise horizontally.
     * @return splitted matrix as JMatrix.
     * @throws MatrixException throws matrix exception if splitting fails.
     *
     */
Splits matrix at defined position. If splitVertical is true splits vertically otherwise horizontally.

@param position position of split
@param splitVertically if true splits vertically otherwise horizontally.
@return splitted matrix as JMatrix.
@throws MatrixException throws matrix exception if splitting fails.
Splits matrix at defined position . If splitVertical is true splits vertically otherwise horizontally . @param position position of split @param splitVertically if true splits vertically otherwise horizontally . @return splitted matrix as JMatrix . @throws MatrixException throws matrix exception if splitting fails .
public Matrix split(int position, boolean splitVertically) throws MatrixException {
        if (!((this instanceof DMatrix) || (this instanceof SMatrix))) throw new MatrixException("Matrix must be of type DMatrix or SMatrix");
        Matrix matrix1;
        Matrix matrix2;
        int totalRows = getTotalRows();
        int totalColumns = getTotalColumns();
        if (splitVertically) {
            if (position < 1 || position > totalRows - 1) throw new MatrixException("For vertical split position is beyond number of rows in matrix.");
            matrix1 = getNewMatrix(position,totalColumns);
            matrix2 = getNewMatrix(totalRows - matrix1.getTotalRows(), totalColumns);
            for (int row = 0; row < totalRows; row++) {
                for (int column = 0; column < totalColumns; column++) {
                    if (row < position) matrix1.setValue(row, column, getValue(row, column));
                    else matrix2.setValue(row - position, column, getValue(row, column));
                }
            }
        }
        else {
            if (position < 1 || position > totalColumns - 1) throw new MatrixException("For vertical split position is beyond number of rows in matrix.");
            matrix1 = getNewMatrix(totalRows, position);
            matrix2 = getNewMatrix(totalRows, totalColumns - matrix1.getTotalColumns());
            for (int row = 0; row < totalRows; row++) {
                for (int column = 0; column < totalColumns; column++) {
                    if (column < position) matrix1.setValue(row, column, getValue(row, column));
                    else matrix2.setValue(row, column - position, getValue(row, column));
                }
            }
        }
        ArrayList<Matrix> matrices = new ArrayList<>();
        matrices.add(matrix1);
        matrices.add(matrix2);
        Matrix result = new JMatrix(matrices, splitVertically);
        if (hasProcedureFactory()) result.setProcedureFactory(procedureFactory);
        return result;
    }
public Matrix split ( int position , boolean splitVertically ) throws MatrixException { if ( ! ( ( this instanceof DMatrix ) || ( this instanceof SMatrix ) ) ) throw new MatrixException ( "Matrix must be of type DMatrix or SMatrix" ) ; Matrix matrix1 ; Matrix matrix2 ; int totalRows = getTotalRows ( ) ; int totalColumns = getTotalColumns ( ) ; if ( splitVertically ) { if ( position < 1 || position > totalRows - 1 ) throw new MatrixException ( "For vertical split position is beyond number of rows in matrix." ) ; matrix1 = getNewMatrix ( position , totalColumns ) ; matrix2 = getNewMatrix ( totalRows - matrix1 . getTotalRows ( ) , totalColumns ) ; for ( int row = 0 ; row < totalRows ; row ++ ) { for ( int column = 0 ; column < totalColumns ; column ++ ) { if ( row < position ) matrix1 . setValue ( row , column , getValue ( row , column ) ) ; else matrix2 . setValue ( row - position , column , getValue ( row , column ) ) ; } } } else { if ( position < 1 || position > totalColumns - 1 ) throw new MatrixException ( "For vertical split position is beyond number of rows in matrix." ) ; matrix1 = getNewMatrix ( totalRows , position ) ; matrix2 = getNewMatrix ( totalRows , totalColumns - matrix1 . getTotalColumns ( ) ) ; for ( int row = 0 ; row < totalRows ; row ++ ) { for ( int column = 0 ; column < totalColumns ; column ++ ) { if ( column < position ) matrix1 . setValue ( row , column , getValue ( row , column ) ) ; else matrix2 . setValue ( row , column - position , getValue ( row , column ) ) ; } } } ArrayList < Matrix > matrices = new ArrayList < > ( ) ; matrices . add ( matrix1 ) ; matrices . add ( matrix2 ) ; Matrix result = new JMatrix ( matrices , splitVertically ) ; if ( hasProcedureFactory ( ) ) result . setProcedureFactory ( procedureFactory ) ; return result ; }
Splits matrix at defined position.
Splits matrix at defined position .