示例#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);
 }