Beispiel #1
0
 public void testRowsIndexed() {
   SparseMatrixLil A = new SparseMatrixLil("1 5 3; 2 8 5; 1 9 4; 2 5 3");
   DenseMatrix indexes = new DenseMatrix("2; 1; 1");
   SparseMatrixLil B = A.rows(indexes);
   System.out.println(B.toDense());
   assertTrue(B.equals(new SparseMatrixLil("1 9 4; 2 8 5; 2 8 5")));
 }
Beispiel #2
0
  public void testSliceSparse() {
    SparseMatrixLil A = sprand(5, 8);
    SparseMatrixLil B = sprand(5, 12);
    SparseMatrixLil C = sprand(4, 8);
    SparseMatrixLil AB = A.concatRight(B);
    assertTrue(A.equals(AB.cols(0, 8)));
    assertTrue(B.equals(AB.cols(8, 20)));
    SparseMatrixLil AC = A.concatDown(C);
    assertTrue(A.equals(AC.rows(0, 5)));
    assertTrue(C.equals(AC.rows(5, 9)));

    A = spzeros(1, 5);
    A.append(0, 2, 3);
    assertEquals(A.row(0).cols, 5);
  }