@Test public void testNonCanonicalOrder() { int[] shape = new int[] {1, 2, 3}; Storage<Float> store = new ArrayFloat.StorageF(new float[] {1, 2, 3, 4, 5, 6}); Array<Float> array = new ArrayFloat(shape, store); array = Arrays.flip(array, 1); float[] expected = new float[] {4, 5, 6, 1, 2, 3}; int count = 0; for (float val : array) { assertThat(val).isEqualTo(expected[count]); count++; } float[] result = new float[3]; array.arraycopy(1, result, 0, 3); assertThat(result).isEqualTo(new float[] {5, 6, 1}); }
@Override void arraycopy(int srcPos, Object dest, int destPos, long length) { if (indexFn.isCanonicalOrder()) { storageF.arraycopy(srcPos, dest, destPos, length); } else { float[] ddest = (float[]) dest; int destIndex = destPos; Iterator<Integer> iter = indexFn.iterator(srcPos, length); while (iter.hasNext()) { ddest[destIndex++] = storageF.get(iter.next()); } } }
ArrayFloat extends Array<Float> { @Override void arraycopy(int srcPos, Object dest, int destPos, long length) { if (indexFn.isCanonicalOrder()) { storageF.arraycopy(srcPos, dest, destPos, length); } else { float[] ddest = (float[]) dest; int destIndex = destPos; Iterator<Integer> iter = indexFn.iterator(srcPos, length); while (iter.hasNext()) { ddest[destIndex++] = storageF.get(iter.next()); } } } }
ArrayFloat extends Array<Float> { @Override void arraycopy(int srcPos, Object dest, int destPos, long length) { if (indexFn.isCanonicalOrder()) { storageF.arraycopy(srcPos, dest, destPos, length); } else { float[] ddest = (float[]) dest; int destIndex = destPos; Iterator<Integer> iter = indexFn.iterator(srcPos, length); while (iter.hasNext()) { ddest[destIndex++] = storageF.get(iter.next()); } } } ArrayFloat(int[] shape);  ArrayFloat(int[] shape, Storage<Float> storageF); private  ArrayFloat(IndexFn indexFn, Storage<Float> storageF); }
ArrayFloat extends Array<Float> { @Override void arraycopy(int srcPos, Object dest, int destPos, long length) { if (indexFn.isCanonicalOrder()) { storageF.arraycopy(srcPos, dest, destPos, length); } else { float[] ddest = (float[]) dest; int destIndex = destPos; Iterator<Integer> iter = indexFn.iterator(srcPos, length); while (iter.hasNext()) { ddest[destIndex++] = storageF.get(iter.next()); } } } ArrayFloat(int[] shape);  ArrayFloat(int[] shape, Storage<Float> storageF); private  ArrayFloat(IndexFn indexFn, Storage<Float> storageF); @Override Iterator<Float> fastIterator(); @Override Iterator<Float> iterator(); @Override Float get(int... index); @Override Float get(Index index); }
ArrayFloat extends Array<Float> { @Override void arraycopy(int srcPos, Object dest, int destPos, long length) { if (indexFn.isCanonicalOrder()) { storageF.arraycopy(srcPos, dest, destPos, length); } else { float[] ddest = (float[]) dest; int destIndex = destPos; Iterator<Integer> iter = indexFn.iterator(srcPos, length); while (iter.hasNext()) { ddest[destIndex++] = storageF.get(iter.next()); } } } ArrayFloat(int[] shape);  ArrayFloat(int[] shape, Storage<Float> storageF); private  ArrayFloat(IndexFn indexFn, Storage<Float> storageF); @Override Iterator<Float> fastIterator(); @Override Iterator<Float> iterator(); @Override Float get(int... index); @Override Float get(Index index);  }