List of usage examples for org.apache.mahout.math Matrix assignColumn
Matrix assignColumn(int column, Vector other);
From source file:ca.uwaterloo.cpami.mahout.matrix.utils.GramSchmidt.java
License:Apache License
public static void storeSparseColumns(Matrix mat) { int numCols = mat.numCols(); int numRows = mat.numRows(); for (int i = 0; i < numCols; i++) { Vector sparseVect = new RandomAccessSparseVector(numRows); Vector col = mat.viewColumn(i); Iterator<Vector.Element> itr = col.iterateNonZero(); while (itr.hasNext()) { Element elem = itr.next(); if (elem.get() != 0) { System.out.println(elem.get()); sparseVect.set(elem.index(), elem.get()); }/*from w w w .ja v a 2 s . c o m*/ } System.out.println(sparseVect.getNumNondefaultElements()); mat.assignColumn(i, sparseVect); System.out.println(mat.viewColumn(i).getNumNondefaultElements()); System.exit(1); } }