コード例 #1
0
  @Test
  public void testBug27() {
    double[] tfVector = {0.0, 0.5, 0.0, 0.4, 0.0};
    DenseVector dense = new DenseVector(tfVector, false);
    SparseVector vectorTF = new SparseVector(dense);
    vectorTF.compact();

    assertTrue(vectorTF.getUsed() == 2); // vectorTF.getUsed() returns 5

    for (Iterator<VectorEntry> it = vectorTF.iterator(); it.hasNext(); ) {
      VectorEntry ve = it.next();
      int index = ve.index();
      double value = ve.get();
      assertTrue(tfVector[index] == value);
    }
  }
コード例 #2
0
 /** Tries to store the matrix as compactly as possible */
 public void compact() {
   for (Vector v : rowD) ((SparseVector) v).compact();
 }