/** * {@inheritDoc} */ public int columns() { return backing.columns(); }
/** * {@inheritDoc} */ public synchronized int columns() { return m.columns(); }
/** * {@inheritDoc} */ public int getVectorLength() { return bigramMatrix.columns(); }
/** * {@inheritDoc} */ public int columns() { return backing.columns(); }
/** * {@inheritDoc} */ public synchronized int columns() { return m.columns(); }
/** * {@inheritDoc} */ public int getVectorLength() { if (cooccurrenceMatrix != null) return cooccurrenceMatrix.columns() + cooccurrenceMatrix.rows(); return reduced.columns(); }
/** * Writes the {@link SparseMatrix} to the file using a particular format. */ public void writeMatrix(SparseMatrix m, OutputStream s) { PrintStream p = new PrintStream(s); // Check to see if the last element in the matrix is non zero. If it // has a zero value, print out a single dummy value to bound the total // size of the matrix. if (m.get(m.rows()-1, m.columns()-1) == 0d) p.printf("%d %d %f\n", m.rows(), m.columns(), 0.0); // Print the row, col, value entrie for each element in the matrix. for (int r = 0; r < m.rows(); ++r) { SparseDoubleVector v = m.getRowVector(r); for (int c : v.getNonZeroIndices()) p.printf("%d %d %f\n", r+1, c+1, m.get(r,c)); } p.flush(); p.close(); } }
this.rows = rows; centroid = new CompactSparseVector(sm.columns()); double simSum = 0d; for (int r : rows) {
this.rows = rows; centroid = new CompactSparseVector(sm.columns()); double simSum = 0d; for (int r : rows) {
double total = 0; for (int r = 0; r < termGraph.rows(); ++r) for (int c = r+1; c < termGraph.columns(); ++c) { termFrequency[r] += termGraph.get(r,c); total += termGraph.get(r,c);
/** * {@inheritDoc} */ public void factorize(SparseMatrix m, int numDimensions) { if (numDimensions >= m.columns() || numDimensions >= m.rows()) throw new IllegalArgumentException( "Cannot factorize with more dimensions than there are " + "rows or columns"); this.numDimensions = numDimensions; A = new ArrayMatrix(m.rows(), numDimensions); initialize(A); X = new ArrayMatrix(numDimensions, m.columns()); initialize(X); for (int i = 0; i < numIterations; ++i) { updateX(computeGofX(m), computeLearningRateX()); updateA(computeGofA(m), computeLearningRateA()); } }
/** * {@inheritDoc} */ public void factorize(SparseMatrix m, int numDimensions) { if (numDimensions >= m.columns() || numDimensions >= m.rows()) throw new IllegalArgumentException( "Cannot factorize with more dimensions than there are " + "rows or columns"); this.numDimensions = numDimensions; A = new ArrayMatrix(m.rows(), numDimensions); initialize(A); X = new ArrayMatrix(numDimensions, m.columns()); initialize(X); for (int i = 0; i < numIterations; ++i) { updateX(computeGofX(m), computeLearningRateX()); updateA(computeGofA(m), computeLearningRateA()); } }
W = new ArrayMatrix(matrix.rows(), numDimensions); initialize(W); H = new ArrayMatrix(numDimensions, matrix.columns()); initialize(H);
W = new ArrayMatrix(matrix.rows(), numDimensions); initialize(W); H = new ArrayMatrix(numDimensions, matrix.columns()); initialize(H);