/** * Pass in the shape to iterate over * @param shape the shape to iterate over */ public NdIndexIterator(char order, int... shape) { this(order, false, ArrayUtil.toLongArray(shape)); }
/** * * @param shape the shape of the linear index * @param ordering the ordering of the linear index */ public LinearIndexLookup(int[] shape, char ordering) { this(ArrayUtil.toLongArray(shape), ordering); }
/** * Adds an oup * * @param shape * @return */ public DynamicCustomOpsBuilder addOutputShape(int[] shape) { this.outputShapes.add(ArrayUtil.toLongArray(shape)); return this; }
@Deprecated public static boolean cOrFortranOrder(int[] shape, int[] stride, int elementStride) { return cOrFortranOrder(ArrayUtil.toLongArray(shape), ArrayUtil.toLongArray(stride), elementStride); }
public ShapeOp(SameDiff sameDiff, SDVariable i_v, int[] shape, boolean inPlace, Object[] extraArgs) { // FIXME: int cast this(sameDiff, i_v, ArrayUtil.toLongArray(shape), inPlace, extraArgs); }
@Override public INDArray reshape(char order, int... newShape) { // FIXME: int cast return reshape(order, ArrayUtil.toLongArray(newShape)); }
public BaseBroadcastOp(SameDiff sameDiff, SDVariable i_v, int[] shape, boolean inPlace, int[] dimension, Object[] extraArgs) { // FIXME: int cast this(sameDiff, i_v, ArrayUtil.toLongArray(shape), inPlace, dimension, extraArgs); }
/** * Creates an ndarray with the specified shape * * @param rows the rows of the ndarray * @param columns the columns of the ndarray * @param stride the stride for the ndarray * @return the instance */ @Override public INDArray create(long rows, long columns, int[] stride) { return create(new long[] {rows, columns}, ArrayUtil.toLongArray(stride)); }
public static long getOffset(LongBuffer shapeInformation, int[] indices) { // FIXME: int cast return getOffset(shapeInformation, ArrayUtil.toLongArray(indices)); }
public BaseTransformOp(SameDiff sameDiff, SDVariable i_v, int[] shape, boolean inPlace, Object[] extraArgs) { // FIXME: int cast ! this(sameDiff, i_v, ArrayUtil.toLongArray(shape), inPlace, extraArgs); }
@Override public INDArray dimShuffle(Object[] rearrange, int[] newOrder, boolean[] broadCastable) { // FIXME: int cast return dimShuffle(rearrange, ArrayUtil.toLongArray(newOrder), broadCastable); }
/** * Get the offset of the specified indices from the shape info buffer * * @param shapeInformation Shape information to get the offset for * @param indices Indices array to get the offset for (must be same length as array rank) * @return Buffer offset fo the specified indices */ public static long getOffset(IntBuffer shapeInformation, int[] indices) { // FIXME: int cast return getOffset(shapeInformation, ArrayUtil.toLongArray(indices)); }
@Override public INDArray put(int[] indexes, INDArray element) { if (!element.isScalar()) throw new IllegalArgumentException("Unable to insert anything but a scalar"); if (indexes.length != rank) throw new IllegalStateException( "Cannot use putScalar with indexes length " + indexes.length + " on rank " + rank); addOrUpdate(ArrayUtil.toLongArray(indexes), element.getDouble(0)); return this; }
/** * Initialize the given ndarray as the real component * * @param m the real component * @param stride the stride of the ndarray * @param ordering the ordering for the ndarray */ public BaseComplexNDArray(INDArray m, int[] stride, char ordering) { this(m.shape(), ArrayUtil.toLongArray(stride), ordering); copyFromReal(m); }
@Override public Pair<DataBuffer, long[]> createShapeInformation(int[] shape, int[] stride, long offset, int elementWiseStride, char order) { DataBuffer buffer = Shape.createShapeInformation(ArrayUtil.toLongArray(shape), ArrayUtil.toLongArray(stride), offset, (long) elementWiseStride, order); buffer.setConstant(true); return Pair.create(buffer, buffer.asLong()); }
/** * Variable initialization * with 1.0 * * @param name the opName of the variable * @param shape the shape of the array to be created * @return the created variable */ public SDVariable one(String name, int[] shape) { return var(name, ArrayUtil.toLongArray(shape), new ConstantInitScheme('f', 1.0)); }
public static List<Pair<INDArray, String>> get6dReshapedWithShape(int seed, int... shape) { Nd4j.getRandom().setSeed(seed); int[] shape3d = {shape[0] * shape[2], shape[4] * shape[5], shape[1] * shape[3]}; INDArray array3d = Nd4j.rand(shape3d); INDArray array6d = array3d.reshape(ArrayUtil.toLongArray(shape)); return Collections.singletonList(new Pair<>(array6d, "get6dReshapedWithShape(" + seed + "," + Arrays.toString(shape) + ").get(0)")); }
/** * Get a double based on the array and given indices * * @param arr the array to retrieve the double from * @param indices the indices to iterate over * @return the double at the specified index */ public static double getDouble(INDArray arr, int[] indices) { long offset = getOffset(arr.shapeInfo(), ArrayUtil.toLongArray(indices)); return arr.data().getDouble(offset); }
/** * Return the index of the value corresponding to the indexes * @param indexes * @return index of the value * */ public int reverseIndexes(int... indexes) { long[] idx = translateToPhysical(ArrayUtil.toLongArray(indexes)); sort(); // FIXME: int cast return indexesBinarySearch(0, (int) length(), ArrayUtil.toInts(idx)); }
@Override public void setStride(int[] stride) { setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape(), ArrayUtil.toLongArray(stride), 0, elementWiseStride(), ordering())); }