public static SliceArray<INDArray> repeat(INDArray s, int n) { ArrayList<INDArray> al = new ArrayList<INDArray>(n); for (int i = 0; i < n; i++) { al.add(s); } return SliceArray.create(al); }
@Override public INDArray slice(int dimension, int index) { if (dimension < 0) throw new IllegalArgumentException(ErrorMessages.invalidDimension(this, dimension)); if (dimension == 0) return slice(index); ArrayList<INDArray> al = new ArrayList<INDArray>(sliceCount()); for (INDArray s : this) { al.add(s.slice(dimension - 1, index)); } return SliceArray.create(al); }
@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)); }