package sspr2;

public class ParserMPI {

    public static int[][] parseMatrix(int[] requestMatrix, int row, int col) {
        int iterator = 0;
        int[][] matrix = new int[row][col];
        for (int i = 0; i < row; i++) {
            System.arraycopy(requestMatrix, iterator, matrix[i], 0, col);
            iterator += col;
        }
        return matrix;
    }

    public static int[] convertMatrixToArray(int[][] matrix, int row, int col) {
        int iterator = 0;
        int[] response = new int[row * col];
        for (int i = 0; i < row; i++) {
            System.arraycopy(matrix[i], 0, response, iterator, col);
            iterator += col;
        }
        return response;
    }
}
