/** * {@inheritDoc} */ public DoubleVector getColumnVector(int column) { return m.getRowVector(column); }
/** * {@inheritDoc} */ public synchronized DoubleVector getRowVector(int row) { return m.getRowVector(row); }
/** * {@inheritDoc} */ public Vector getVector(String word) { Integer index = termToIndex.get(word); if (index == null) return null; // If the matrix hasn't had columns dropped then the returned vector // will be the combination of the word's row and column else return reduced.getRowVector(index); }
/** * {@inheritDoc} */ public Vector getVector(String word) { // determine the index for the word Integer index = termToIndex.get(word); return (index == null) ? null : wordSpace.getRowVector(index.intValue()); }
/** * {@inheritDoc} */ @Override public Vector getVector(String word) { // determine the index for the word Integer index = termToIndex.get(word); return (index == null) ? null : wordSpace.getRowVector(index.intValue()); }
/** * {@inheritDoc} */ public Vector getVector(String term) { Integer index = termToIndex.get(term); return (index == null) ? null : wordSpace.getRowVector(index.intValue()); }
/** * {@inheritDoc} */ public Vector getVector(String word) { // determine the index for the word int index = termToIndex.getDimension(word); return (index < 0) ? null : wordSpace.getRowVector(index); }
/** * {@inheritDoc} */ public Vector getVector(String word) { // determine the index for the word int index = termToIndex.getDimension(word); return (index < 0) ? null : wordSpace.getRowVector(index); }
/** * {@inheritDoc} */ public DoubleVector getRowVector(int row) { return backingMatrix.getRowVector(getRealRow(row)); }
/** * {@inheritDoc} */ public Vector getVector(String term) { Integer index = termToIndex.get(term); if (index == null) return null; return Vectors.immutable( finalCorrelation.getRowVector(index.intValue())); }
/** * {@inheritDoc} */ public DoubleVector getRowVector(int row) { return backingMatrix.getRowVector(getRealRow(row)); }
/** * {@inheritDoc} */ public int getVectorLength() { return wordSpace.getRowVector(0).length(); // return wordSpace.columns(); }
/** * {@inheritDoc} */ public DoubleVector getRowVector(int row) { return new ScaledDoubleVector(m.getRowVector(row), scales.get(row)); }
public void run() { Double similarity = simFunction.sim( row, m.getRowVector(otherRow)); // lock on the Map, as it is not thread-safe synchronized(mostSimilar) { mostSimilar.put(similarity, otherRow); } } }
public void run() { Double similarity = simFunction.sim( row, m.getRowVector(otherRow)); // lock on the Map, as it is not thread-safe synchronized(mostSimilar) { mostSimilar.put(similarity, otherRow); } } }
/** * Creates an instance of {@code RowMagnitudeGlobalTransform} from a * {@link Matrix}. */ public RowMagnitudeGlobalTransform(Matrix matrix) { rowMagnitudes = new double[matrix.rows()]; for (int r = 0; r < matrix.rows(); ++r) rowMagnitudes[r] = matrix.getRowVector(r).magnitude(); }
/** * Creates an instance of {@code RowMagnitudeGlobalTransform} from a * {@link Matrix}. */ public RowMagnitudeGlobalTransform(Matrix matrix) { rowMagnitudes = new double[matrix.rows()]; for (int r = 0; r < matrix.rows(); ++r) rowMagnitudes[r] = matrix.getRowVector(r).magnitude(); }
/** * Compute the row sums of the values in {@code matrix} and returns the * values in a vector of length {@code matrix.columns()}. */ protected static <T extends Matrix> DoubleVector computeMatrixRowSum( T matrix) { DoubleVector rowSums = new DenseVector(matrix.columns()); for (int r = 0; r < matrix.rows(); ++r) VectorMath.add(rowSums, matrix.getRowVector(r)); return rowSums; }
/** * Compute the row sums of the values in {@code matrix} and returns the * values in a vector of length {@code matrix.columns()}. */ protected static <T extends Matrix> DoubleVector computeMatrixRowSum( T matrix) { DoubleVector rowSums = new DenseVector(matrix.columns()); for (int r = 0; r < matrix.rows(); ++r) VectorMath.add(rowSums, matrix.getRowVector(r)); return rowSums; }
@SuppressWarnings("unchecked") public static <T extends DoubleVector> OnlineClustering<T> computeStreamingCluster( Matrix matrix) { StreamingKMeans<T> generator = new StreamingKMeans<T>(); OnlineClustering<T> onlineClustering = generator.generate(); for (int r = 0; r < matrix.rows(); ++r) onlineClustering.addVector((T) matrix.getRowVector(r)); return onlineClustering; }