public static double[][] readMatrix(Path path, HamaConfiguration conf,
			int rows, int columns, int blockSize) {

		int finalRows = getBlockMultiple(rows, blockSize);
		int finalCols = getBlockMultiple(columns, blockSize);

		double[][] matrix = new double[finalRows][finalCols];
		SequenceFile.Reader reader = null;
		try {
			FileSystem fs = FileSystem.get(conf);
			reader = new SequenceFile.Reader(fs, path, conf);
			VectorWritable row = new VectorWritable();
			IntWritable i = new IntWritable();
			while (reader.next(i, row) && i.get()<rows) {
				DoubleVector v = row.getVector();
				for (int j = 0; j < columns; j++) {
					matrix[i.get()][j] = v.get(j);
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}

		for (int k = rows; k < finalRows; k++) {
			for (int p = columns; p < finalCols; p++) {
				matrix[k][p] = 0;
			}
		}
		return matrix;
	}