Example usage for org.apache.mahout.math Matrix assignColumn

List of usage examples for org.apache.mahout.math Matrix assignColumn

Introduction

In this page you can find the example usage for org.apache.mahout.math Matrix assignColumn.

Prototype

Matrix assignColumn(int column, Vector other);

Source Link

Document

Assign the other vector values to the column of the receiver

Usage

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);

    }
}