Exemplo n.º 1
0
  @Test
  public void testCreateFromArray() {
    INDArray[] as = new INDArray[2];
    as[0] = Vector.of(1, 2);
    as[1] = Vector.of(3, 4);

    INDArray a = Arrayz.create((Object) as);
    assertTrue(a instanceof AMatrix);
  }
Exemplo n.º 2
0
  @Test
  public void testZeroPaddedReshape() {
    assertTrue(Vector0.INSTANCE.reshape(1, 1).asVector().isZero());
    assertTrue(Matrix.create(1, 1).reshape(1, 2, 3).asVector().isZero());

    assertEquals(Vector.of(2, 0, 0), Scalar.create(2).reshape(3));
    assertEquals(Vector.of(1, 2), Vector.of(1, 2, 3, 4).reshape(2));
    assertEquals(Scalar.create(2), Vector.of(2, 3, 4).reshape());

    assertEquals(Vector0.INSTANCE, Array.newArray(2, 3, 4, 5).reshape(0));
  }
Exemplo n.º 3
0
  @Test
  public void testCholesky() {
    AMatrix m =
        Matrixx.create(Vector.of(4, 12, -16), Vector.of(12, 37, -43), Vector.of(-16, -43, 98));

    Matrix L = Cholesky.decompose(m);

    assertEquals((Matrixx.create(Vector.of(2, 0, 0), Vector.of(6, 1, 0), Vector.of(-8, 5, 3))), L);
  }
Exemplo n.º 4
0
 @Test
 public void testParse() {
   assertEquals(Vector.of(4, 5), Arrayz.parse("[[1, 2], [4, 5], [7, 8]]").slice(1));
 }
Exemplo n.º 5
0
 @Test
 public void testDoubleSlice() {
   assertEquals(new Double(2.0), Array.create(Vector.of(1, 2, 3)).getSlices().get(1));
   assertEquals(new Double(2.0), SliceArray.create(Vector.of(1, 2, 3)).getSlices().get(1));
 }