@Test public void testArray() { assertThat(array.getDataType()).isEqualTo(DataType.DOUBLE); assertThat(array.getRank()).isEqualTo(3); assertThat(array.getShape()).isEqualTo(new int[] {1, 2, 3}); assertThat(array.length()).isEqualTo(6); assertThat(array.getSizeBytes()).isEqualTo(48); assertThat(array.getIndex().getCurrentIndex()).isEqualTo(new int[3]); assertThat(array.toString()).isEqualTo("1.0, 2.0, 3.0, 4.0, 5.0, 6.0"); Section expected = Section.builder().appendRange(1).appendRange(2).appendRange(3).build(); assertThat(array.getSection()).isEqualTo(expected); assertThat(array.get(0, 0, 0)).isEqualTo(1); assertThat(array.get(0, 0, 1)).isEqualTo(2); assertThat(array.get(0, 0, 2)).isEqualTo(3); assertThat(array.get(0, 1, 0)).isEqualTo(4); assertThat(array.get(0, 1, 1)).isEqualTo(5); assertThat(array.get(0, 1, 2)).isEqualTo(6); int count = 0; for (double val : array) { assertThat(val).isEqualTo(count + 1); count++; } try { assertThat(array.get(0, 2, 2)).isEqualTo(8); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalArgumentException.class); } try { assertThat(array.get(0, 1)).isEqualTo(4); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalArgumentException.class); } }
Array(DataType dataType, int[] shape) { this.dataType = dataType; this.rank = shape.length; this.indexFn = IndexFn.builder(shape).build(); }
Array implements Iterable<T> { Array(DataType dataType, int[] shape) { this.dataType = dataType; this.rank = shape.length; this.indexFn = IndexFn.builder(shape).build(); } }
Array implements Iterable<T> { Array(DataType dataType, int[] shape) { this.dataType = dataType; this.rank = shape.length; this.indexFn = IndexFn.builder(shape).build(); } Array(DataType dataType, int[] shape);   Array(DataType dataType, IndexFn indexFn); }
Array implements Iterable<T> { Array(DataType dataType, int[] shape) { this.dataType = dataType; this.rank = shape.length; this.indexFn = IndexFn.builder(shape).build(); } Array(DataType dataType, int[] shape);   Array(DataType dataType, IndexFn indexFn); @Override abstract Iterator<T> iterator(); abstract Iterator<T> fastIterator(); abstract T get(int... index); abstract T get(Index index); T getScalar(); DataType getDataType(); Index getIndex(); int getRank(); int[] getShape(); Section getSection(); long length(); long getSizeBytes(); String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
Array implements Iterable<T> { Array(DataType dataType, int[] shape) { this.dataType = dataType; this.rank = shape.length; this.indexFn = IndexFn.builder(shape).build(); } Array(DataType dataType, int[] shape);   Array(DataType dataType, IndexFn indexFn); @Override abstract Iterator<T> iterator(); abstract Iterator<T> fastIterator(); abstract T get(int... index); abstract T get(Index index); T getScalar(); DataType getDataType(); Index getIndex(); int getRank(); int[] getShape(); Section getSection(); long length(); long getSizeBytes(); String toString(); @Override boolean equals(Object o); @Override int hashCode();  }