@Test public void testGetCoord() { DataType type = DataType.INTEGER; Tensor tensor = new Tensor(type, new int[] {3, 2}, new int[][] { new int[] {1, 2}, new int[] {3, 4}, new int[] {5, 6}, }); assertEquals(1, tensor.getCoord(0, 0)); assertEquals(2, tensor.getCoord(0, 1)); assertEquals(3, tensor.getCoord(1, 0)); assertEquals(4, tensor.getCoord(1, 1)); assertEquals(5, tensor.getCoord(2, 0)); assertEquals(6, tensor.getCoord(2, 1)); }
public Object getCoord(int... coords) { int[] undefinedLength = checkNoMoreThanOneUndefinedCoords(coords); if (undefinedLength.length == 0) { Object last = this.data; for (int coord : coords) { last = Array.get(last, coord); } return convertIfString(last); } else { Object result = Array.newInstance(this.getType().getJavaClass(), undefinedLength[0]); for (int i = 0; i < undefinedLength[0]; i++) { Object last = this.data; for (int coord : coords) { if (coord < 0) { coord = i; } last = Array.get(last, coord); } last = convertIfString(last); Array.set(result, i, last); } return result; } }
Tensor { public Object getCoord(int... coords) { int[] undefinedLength = checkNoMoreThanOneUndefinedCoords(coords); if (undefinedLength.length == 0) { Object last = this.data; for (int coord : coords) { last = Array.get(last, coord); } return convertIfString(last); } else { Object result = Array.newInstance(this.getType().getJavaClass(), undefinedLength[0]); for (int i = 0; i < undefinedLength[0]; i++) { Object last = this.data; for (int coord : coords) { if (coord < 0) { coord = i; } last = Array.get(last, coord); } last = convertIfString(last); Array.set(result, i, last); } return result; } } }
Tensor { public Object getCoord(int... coords) { int[] undefinedLength = checkNoMoreThanOneUndefinedCoords(coords); if (undefinedLength.length == 0) { Object last = this.data; for (int coord : coords) { last = Array.get(last, coord); } return convertIfString(last); } else { Object result = Array.newInstance(this.getType().getJavaClass(), undefinedLength[0]); for (int i = 0; i < undefinedLength[0]; i++) { Object last = this.data; for (int coord : coords) { if (coord < 0) { coord = i; } last = Array.get(last, coord); } last = convertIfString(last); Array.set(result, i, last); } return result; } } Tensor(DataType type, int[] shape);  Tensor(DataType type, TensorShape shape);  Tensor(DataType type, int[] shape, Object data);  Tensor(DataType type, TensorShape shape, Object data);  Tensor(DataType type, TensorShape shape, Object data, boolean nullableValues); }
Tensor { public Object getCoord(int... coords) { int[] undefinedLength = checkNoMoreThanOneUndefinedCoords(coords); if (undefinedLength.length == 0) { Object last = this.data; for (int coord : coords) { last = Array.get(last, coord); } return convertIfString(last); } else { Object result = Array.newInstance(this.getType().getJavaClass(), undefinedLength[0]); for (int i = 0; i < undefinedLength[0]; i++) { Object last = this.data; for (int coord : coords) { if (coord < 0) { coord = i; } last = Array.get(last, coord); } last = convertIfString(last); Array.set(result, i, last); } return result; } } Tensor(DataType type, int[] shape);  Tensor(DataType type, TensorShape shape);  Tensor(DataType type, int[] shape, Object data);  Tensor(DataType type, TensorShape shape, Object data);  Tensor(DataType type, TensorShape shape, Object data, boolean nullableValues); DataType getType(); void setType(DataType type); Object getData(); void setData(Object data); TensorShape getShape(); int[] getShapeAsArray(); void setShape(TensorShape shape); boolean isNullable(); Tensor slice(TensorShape begin, TensorShape size); Tensor concat(Tensor value, int axis); Object getCoord(int... coords); void setOnCoord(Object value, int... coords); Tensor toVector(); Iterator<int[]> coordIterator(); Iterator<int[]> coordIterator(int indexRollingWindows, int rollingWindowSize); Tensor reshape(TensorShape newShape); Tensor reshape(int[] newShape); Tensor reshapeWithType(TensorShape newShape, DataType dataType); Tensor reshapeWithType(int[] newShape, DataType dataType); int getRank(); boolean isScalar(); boolean isVector(); boolean isMatrix(); boolean isOfRank(int rank); void checkTypeCompatible(DataType wantedType); Object getDataAsList(); Tensor simplifyShape(); static Tensor fromData(DataType type, Object data); Tensor roll(int shapeIndex, int windowsSize); static Tensor fromIntData(Object data); static Tensor fromStringData(Object data); static Tensor fromLongData(Object data); static Tensor fromFloatData(Object data); static Tensor fromDoubleData(Object data); static Tensor fromBooleanData(Object data); Object jsonData(boolean simplify); Tensor apply(Function<Object, T> func, DataType outputDataType); }
Tensor { public Object getCoord(int... coords) { int[] undefinedLength = checkNoMoreThanOneUndefinedCoords(coords); if (undefinedLength.length == 0) { Object last = this.data; for (int coord : coords) { last = Array.get(last, coord); } return convertIfString(last); } else { Object result = Array.newInstance(this.getType().getJavaClass(), undefinedLength[0]); for (int i = 0; i < undefinedLength[0]; i++) { Object last = this.data; for (int coord : coords) { if (coord < 0) { coord = i; } last = Array.get(last, coord); } last = convertIfString(last); Array.set(result, i, last); } return result; } } Tensor(DataType type, int[] shape);  Tensor(DataType type, TensorShape shape);  Tensor(DataType type, int[] shape, Object data);  Tensor(DataType type, TensorShape shape, Object data);  Tensor(DataType type, TensorShape shape, Object data, boolean nullableValues); DataType getType(); void setType(DataType type); Object getData(); void setData(Object data); TensorShape getShape(); int[] getShapeAsArray(); void setShape(TensorShape shape); boolean isNullable(); Tensor slice(TensorShape begin, TensorShape size); Tensor concat(Tensor value, int axis); Object getCoord(int... coords); void setOnCoord(Object value, int... coords); Tensor toVector(); Iterator<int[]> coordIterator(); Iterator<int[]> coordIterator(int indexRollingWindows, int rollingWindowSize); Tensor reshape(TensorShape newShape); Tensor reshape(int[] newShape); Tensor reshapeWithType(TensorShape newShape, DataType dataType); Tensor reshapeWithType(int[] newShape, DataType dataType); int getRank(); boolean isScalar(); boolean isVector(); boolean isMatrix(); boolean isOfRank(int rank); void checkTypeCompatible(DataType wantedType); Object getDataAsList(); Tensor simplifyShape(); static Tensor fromData(DataType type, Object data); Tensor roll(int shapeIndex, int windowsSize); static Tensor fromIntData(Object data); static Tensor fromStringData(Object data); static Tensor fromLongData(Object data); static Tensor fromFloatData(Object data); static Tensor fromDoubleData(Object data); static Tensor fromBooleanData(Object data); Object jsonData(boolean simplify); Tensor apply(Function<Object, T> func, DataType outputDataType);  }