@Override public List<IRange> getSectionRanges() { int rank = orignalShape.getRank(); List<IRange> list = new ArrayList<IRange>(); int[] origin = orignalShape.getOrigin(); int[] shape = orignalShape.getShape(); long[] stride = orignalShape.getStride(); for (int i = 0; i < rank; i++) { try { list.add(new DefaultRange("", origin[i], shape[i] * stride[i], stride[i])); } catch (InvalidRangeException e) { e.printStackTrace(); } } return list; }
@Override public IArray getData(int[] origin, int[] shape) throws IOException, InvalidRangeException { IArray array = getData().copy(false); IIndex index = array.getIndex(); if (shape == null || shape.length != array.getRank()) { throw new InvalidRangeException("Shape must be of same rank as the array!"); } if (origin == null || origin.length != array.getRank()) { throw new InvalidRangeException("Origin must be of same rank as the array!"); } int str = 1; long[] stride = new long[array.getRank()]; for (int i = array.getRank() - 1; i >= 0; i--) { stride[i] = str; str *= shape[i]; } index.setStride(stride); index.setShape(shape); index.setOrigin(origin); array.setIndex(index); return array; }