예제 #1
0
  @Test
  public void testNonZeroCount() {
    AVector v = Vectorz.createUniformRandomVector(5);
    v.add(1);
    assertEquals(v.length(), v.nonZeroCount());

    v.scale(0.0);
    assertEquals(0, v.nonZeroCount());
  }
예제 #2
0
 @Override
 public AVector getBand(int band) {
   if (band == 0) {
     return getLeadingDiagonal();
   } else {
     if ((band > dimensions) || (band < -dimensions))
       throw new IndexOutOfBoundsException(ErrorMessages.invalidBand(this, band));
     return Vectorz.createZeroVector(bandLength(band));
   }
 }
예제 #3
0
  @Test
  public void testOuterProducts() {
    AVector v = Vectorz.createUniformRandomVector(5);
    INDArray a = v.outerProduct(v);
    assertTrue(a instanceof AMatrix);

    AMatrix m = (AMatrix) a;
    AVector v2 = v.clone();
    v2.square();
    assertEquals(v2, m.getLeadingDiagonal());
  }
예제 #4
0
 public void add(double[] ds) {
   ensureSize(length + 1);
   data[length++] = Vectorz.create(ds);
 }
예제 #5
0
 public void add(AVector v) {
   ensureSize(length + 1);
   data[length++] = Vectorz.create(v);
 }
예제 #6
0
 public void add(Iterable<Object> d) {
   ensureSize(length + 1);
   data[length++] = Vectorz.create(d);
 }