Java Code Examples for org.bytedeco.javacpp.IntPointer#limit()
The following examples show how to use
org.bytedeco.javacpp.IntPointer#limit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntIndexer.java From tapir with MIT License | 6 votes |
/** * Creates a int indexer to access efficiently the data of a pointer. * * @param pointer data to access via a buffer or to copy to an array * @param direct {@code true} to use a direct buffer, see {@link Indexer} for details * @return the new int array backed by a buffer or an array */ public static IntIndexer create(final IntPointer pointer, int[] sizes, int[] strides, boolean direct) { if (direct) { return new IntBufferIndexer(pointer.asBuffer(), sizes, strides); } else { final int position = pointer.position(); int[] array = new int[pointer.limit() - position]; pointer.get(array); return new IntArrayIndexer(array, sizes, strides) { @Override public void release() { pointer.position(position).put(array); super.release(); } }; } }
Example 2
Source File: ALEMDP.java From deeplearning4j with Apache License 2.0 | 6 votes |
public ALEMDP(String romFile, boolean render, Configuration configuration) { this.romFile = romFile; this.configuration = configuration; this.render = render; ale = new ALEInterface(); setupGame(); // Get the vector of minimal or legal actions IntPointer a = (getConfiguration().minimalActionSet ? ale.getMinimalActionSet() : ale.getLegalActionSet()); actions = new int[(int)a.limit()]; a.get(actions); int height = (int)ale.getScreen().height(); int width = (int)(int)ale.getScreen().width(); discreteSpace = new DiscreteSpace(actions.length); int[] shape = {3, height, width}; observationSpace = new ArrayObservationSpace<>(shape); screenBuffer = new byte[shape[0] * shape[1] * shape[2]]; }
Example 3
Source File: DefaultDataBufferFactory.java From nd4j with Apache License 2.0 | 5 votes |
/** * @param intPointer * @param length * @return */ @Override public DataBuffer create(IntPointer intPointer, long length) { intPointer.capacity(length); intPointer.limit(length); intPointer.position(0); return new IntBuffer(intPointer, IntIndexer.create(intPointer), length); }
Example 4
Source File: DefaultDataBufferFactory.java From deeplearning4j with Apache License 2.0 | 5 votes |
/** * @param intPointer * @param length * @return */ @Override public DataBuffer create(IntPointer intPointer, long length) { intPointer.capacity(length); intPointer.limit(length); intPointer.position(0); return new IntBuffer(intPointer, IntIndexer.create(intPointer), length); }