@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()); }
@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)); } }
@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()); }
public void add(double[] ds) { ensureSize(length + 1); data[length++] = Vectorz.create(ds); }
public void add(AVector v) { ensureSize(length + 1); data[length++] = Vectorz.create(v); }
public void add(Iterable<Object> d) { ensureSize(length + 1); data[length++] = Vectorz.create(d); }