public static Matrix collateArray(Matrix[] matrices) {
        int columnCount = matrices[0].columnCount;
        int rowCount = matrices[0].rowCount;
        double[][] elements = new double[rowCount][columnCount * matrices.length];
        int columnsFilled = 0;
        for (int i = 0; i < matrices.length; i++) {
            if (matrices[i].columnCount != columnCount || matrices[i].rowCount != rowCount) {
                return null;
            }
            for (int row = 0; row < rowCount; row++) {
                for (int column = 0; column < columnCount; column++) {
                    elements[row][column + columnsFilled] = matrices[i].elements[row][column];
                }
            }
            columnsFilled += columnCount;
        }
        return new Matrix(elements);
    }