public static Path writeMatrix(double[][] matrix, Path path,
			HamaConfiguration conf) {
		SequenceFile.Writer writer = null;
		try {
			FileSystem fs = FileSystem.get(conf);
			writer = new SequenceFile.Writer(fs, conf, path, IntWritable.class,
					VectorWritable.class);
			for (int i = 0; i < matrix.length; i++) {
				DenseDoubleVector rowVector = new DenseDoubleVector(matrix[i]);
				writer.append(new IntWritable(i), new VectorWritable(rowVector));
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (writer != null) {
				try {
					writer.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return path;
	}