/** * {@inheritDoc} */ public int getVectorLength() { return syntacticCooccurrence.columns(); } }
/** * {@inheritDoc} */ public synchronized int columns() { return m.columns(); }
/** * {@inheritDoc} */ public int getVectorLength() { return wordSpace.columns(); }
/** * {@inheritDoc} */ public int getVectorLength() { return wordSpace.columns(); }
/** * {@inheritDoc} */ public int columns() { return backingMatrix.columns(); }
/** * {@inheritDoc} */ public int getVectorLength() { return wordSpace.columns(); }
/** * {@inheritDoc} */ public int columns() { return m.columns(); }
/** * {@inheritDoc} */ public double[][] toDenseArray() { double[][] arr = new double[rows][backingMatrix.columns()]; for (int i = 0; i < rowToReal.length; ++i) arr[i] = backingMatrix.getRow(rowToReal[i]); return arr; }
/** * {@inheritDoc} */ public double[][] toDenseArray() { double[][] arr = new double[rows][backingMatrix.columns()]; for (int i = 0; i < rowToReal.length; ++i) arr[i] = backingMatrix.getRow(rowToReal[i]); return arr; }
/** * Initializes every value in {@code m} to be a random value between 0 and * 1, inclusive. */ public static void initialize(Matrix m) { for (int r = 0; r < m.rows(); ++r) for (int c = 0; c < m.columns(); ++c) m.set(r,c,Math.random()); } }
/** * Initializes every value in {@code m} to be a random value between 0 and * 1, inclusive. */ public static void initialize(Matrix m) { for (int r = 0; r < m.rows(); ++r) for (int c = 0; c < m.columns(); ++c) m.set(r,c,Math.random()); } }
/** * {@inheritDoc} */ public int getVectorLength() { if (cooccurrenceMatrix != null) return cooccurrenceMatrix.columns() + cooccurrenceMatrix.rows(); return reduced.columns(); }
private static Matrix multiplyLeftDiag(Matrix m1, Matrix m2) { Matrix resultMatrix = create(m1.rows(), m2.columns(), true); for (int r = 0; r < m1.rows(); ++r) { double element = m1.get(r, r); double[] m2Row = m2.getRow(r); for (int c = 0; c < m2.columns(); ++c) resultMatrix.set(r, c, element * m2Row[c]); } return resultMatrix; }
/** * Sets any negative values of {@code m} to zero. */ public static void makeNonZero(Matrix m) { for (int r = 0; r < m.rows(); ++r) for (int c = 0; c < m.columns(); ++c) if (m.get(r,c) < 0d) m.set(r,c,0); }
private static Matrix multiplyRightDiag(Matrix m1, Matrix m2) { Matrix resultMatrix = create(m1.rows(), m2.columns(), true); for (int r = 0; r < m1.rows(); ++r) { double[] row = m1.getRow(r); for (int c = 0; c < m2.columns(); ++c) { double value = m2.get(c, c); resultMatrix.set(r, c, value * row[c]); } } return resultMatrix; }
/** * Sets any negative values of {@code m} to zero. */ public static void makeNonZero(Matrix m) { for (int r = 0; r < m.rows(); ++r) for (int c = 0; c < m.columns(); ++c) if (m.get(r,c) < 0d) m.set(r,c,0); }
private static Matrix multiplyRightDiag(Matrix m1, Matrix m2) { Matrix resultMatrix = create(m1.rows(), m2.columns(), true); for (int r = 0; r < m1.rows(); ++r) { double[] row = m1.getRow(r); for (int c = 0; c < m2.columns(); ++c) { double value = m2.get(c, c); resultMatrix.set(r, c, value * row[c]); } } return resultMatrix; }
/** * 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; }
/** * Updates the values in {@code X} based on the difference found in {@code * G} with each value scaled by the {@code learningRate}. */ private void updateX(Matrix G, double[] learningRate) { for (int k = 0; k < X.rows(); ++k) for (int c = 0; c < X.columns(); ++c) X.set(k, c, X.get(k, c) - learningRate[k] * G.get(k, c)); makeNonZero(X); }