List of usage examples for org.apache.mahout.math SparseMatrix set
@Override
public void set(String rowLabel, double[] rowData)
From source file:com.twitter.algebra.AlgebraCommon.java
License:Apache License
/** * Convert a 2-dimensional array to a sparse matrix in {@link MapDir} format * @param vectors a 2-dimensional array of doubles * @param outPath the path to which the dense matrix will be written * @param tmpPath an argument required to be passed to {@link DistributedRowMatrix} * @param label a unique label to name the output matrix directory * @return a {@link DistributedRowMatrix} pointing to the in-filesystem matrix * @throws Exception/*from w w w . j ava 2 s. c om*/ */ public static DistributedRowMatrix toSparseMapDir(double[][] vectors, Path outPath, Path tmpPath, String label) throws Exception { int nRows = vectors.length; int nCols = vectors[0].length; SparseMatrix m = new SparseMatrix(nRows, nCols); for (int r = 0; r < nRows; r++) m.set(r, vectors[r]); return AlgebraCommon.toMapDir(m, outPath, tmpPath, label); }