/** * {@inheritDoc} The length of the returned row vector reflects the size of * matrix at the time of the call, which may be different from earlier calls * to {@link #columns()}. */ public SparseDoubleVector getRowVector(int row) { return getRowVector(row, true); }
/** * Provides non-atomic access to the data at the specified row, which may * present an inconsistent view of the data if this matrix is being * concurrently modified. This method should only be used in special cases * where the vector is being accessed at a time when the matrix (or this * particular row) will not be modified. */ public SparseDoubleVector getRowVectorUnsafe(int row) { return getRowVector(row, false); }
/** * {@inheritDoc} The length of the returned row vector reflects the size of * matrix at the time of the call, which may be different from earlier calls * to {@link #columns()}. */ public SparseDoubleVector getRowVector(int row) { return getRowVector(row, true); }
/** * Provides non-atomic access to the data at the specified row, which may * present an inconsistent view of the data if this matrix is being * concurrently modified. This method should only be used in special cases * where the vector is being accessed at a time when the matrix (or this * particular row) will not be modified. */ public SparseDoubleVector getRowVectorUnsafe(int row) { return getRowVector(row, false); }
/** * {@inheritDoc} The length of the returned row reflects the size of matrix * at the time of the call, which may be different from earlier calls to * {@link #columns()}. */ public double[] getRow(int row) { return getRowVector(row).toArray(); }
/** * {@inheritDoc} The length of the returned row reflects the size of matrix * at the time of the call, which may be different from earlier calls to * {@link #columns()}. */ public double[] getRow(int row) { return getRowVector(row).toArray(); }
SparseDoubleVector sv = cooccurrenceMatrix.getRowVector(row); for (int col : sv.getNonZeroIndices()) { double v = cooccurrenceMatrix.get(row, col);
/** * {@inheritDoc} */ public double[][] toDenseArray() { int r = rows.get(); int c = cols.get(); for (int i = 0; i < r; ++i) lockRow(i, c); double[][] m = new double[r][0]; for (int i = 0; i < r; ++i) { DoubleVector row = getRowVector(i); // Ensure that we see a consistent length for all the rows if (row.length() != c) row = Vectors.subview(row, 0, c); m[i] = row.toArray(); } for (int i = 0; i < r; ++i) unlockRow(i, c); return m; }
/** * {@inheritDoc} */ public double[][] toDenseArray() { int r = rows.get(); int c = cols.get(); for (int i = 0; i < r; ++i) lockRow(i, c); double[][] m = new double[r][0]; for (int i = 0; i < r; ++i) { DoubleVector row = getRowVector(i); // Ensure that we see a consistent length for all the rows if (row.length() != c) row = Vectors.subview(row, 0, c); m[i] = row.toArray(); } for (int i = 0; i < r; ++i) unlockRow(i, c); return m; }