Refine search
public static FloatBuffer newFloatBuffer (int numFloats) { ByteBuffer buffer = ByteBuffer.allocateDirect(numFloats * 4); buffer.order(ByteOrder.nativeOrder()); return buffer.asFloatBuffer(); }
public EntireLayoutColumnarFloatsSupplier(int totalSize, ByteBuffer fromBuffer, ByteOrder order) { this.totalSize = totalSize; this.buffer = fromBuffer.asReadOnlyBuffer().order(order).asFloatBuffer(); }
private static byte[] floatArrayToByteArray(float[] input) { final ByteBuffer buffer = ByteBuffer.allocate(Float.BYTES * input.length); buffer.asFloatBuffer().put(input); return buffer.array(); }
/** Allocates a FloatBuffer with the given data. */ public static FloatBuffer createBuffer(float[] data) { ByteBuffer bb = ByteBuffer.allocateDirect(data.length * C.BYTES_PER_FLOAT); bb.order(ByteOrder.nativeOrder()); FloatBuffer buffer = bb.asFloatBuffer(); buffer.put(data); buffer.position(0); return buffer; }
public static byte[] floatToByteArray(Float inFloat) { byte[] bArray = new byte[4]; ByteBuffer bBuffer = ByteBuffer.wrap(bArray); bBuffer.order(ByteOrder.LITTLE_ENDIAN); FloatBuffer lBuffer = bBuffer.asFloatBuffer(); lBuffer.put(inFloat); return bArray; }
private static FloatBuffer nativeFloatBuffer(float... array) { FloatBuffer buffer = ByteBuffer.allocateDirect(array.length * 4).order( ByteOrder.nativeOrder()).asFloatBuffer(); buffer.put(array); buffer.flip(); return buffer; }
public static FloatBuffer newFloatBuffer (int numFloats) { ByteBuffer buffer = ByteBuffer.allocateDirect(numFloats * 4); buffer.order(ByteOrder.nativeOrder()); return buffer.asFloatBuffer(); }
switch (_dtype) { case DOUBLE: { val db = bb.order(_order).asDoubleBuffer(); for (int e = 0; e < prod; e++) doubles[e] = db.get(e); val fb = bb.order(_order).asFloatBuffer(); for (int e = 0; e < prod; e++) doubles[e] = (double) fb.get(e); val sb = bb.order(_order).asShortBuffer(); for (int e = 0; e < prod; e++) doubles[e] = (double) HalfIndexer.toFloat((int) sb.get(e));
public static byte[] floatArrayToByteArray(float[] vertices) { if (vertices == null) { return null; } ByteBuffer buffer = ByteBuffer.wrap(new byte[vertices.length * 4]); buffer.order(ByteOrder.LITTLE_ENDIAN); FloatBuffer asFloatBuffer = buffer.asFloatBuffer(); for (float f : vertices) { asFloatBuffer.put(f); } return buffer.array(); }
@Override public byte[] getCacheKey() { byte[] fieldNameBytes = StringUtils.toUtf8(fieldName); ByteBuffer buf = ByteBuffer .allocate(1 + fieldNameBytes.length + Float.BYTES * breaks.length) .put(AggregatorUtil.HIST_CACHE_TYPE_ID) .put(fieldNameBytes) .put((byte) 0xFF); buf.asFloatBuffer().put(breaks); return buf.array(); }
public GPUImageRenderer(final GPUImageFilter filter) { this.filter = filter; runOnDraw = new LinkedList<>(); runOnDrawEnd = new LinkedList<>(); glCubeBuffer = ByteBuffer.allocateDirect(CUBE.length * 4) .order(ByteOrder.nativeOrder()) .asFloatBuffer(); glCubeBuffer.put(CUBE).position(0); glTextureBuffer = ByteBuffer.allocateDirect(TEXTURE_NO_ROTATION.length * 4) .order(ByteOrder.nativeOrder()) .asFloatBuffer(); setRotation(Rotation.NORMAL, false, false); }
static FloatBuffer allocateDirect(int size) { return ByteBuffer.allocateDirect(size * Float.BYTES) .order(ByteOrder.nativeOrder()) .asFloatBuffer(); } }
public static float[] toFloatArray(byte[] data) { ByteBuffer buffer = ByteBuffer.wrap(data); buffer.order(ByteOrder.LITTLE_ENDIAN); FloatBuffer floatBuffer = buffer.asFloatBuffer(); float[] result = new float[data.length / 4]; for (int i=0; i<data.length / 4; i++) { result[i] = floatBuffer.get(); } return result; }
@Override public byte[] getCacheKey() { ByteBuffer minCoordsBuffer = ByteBuffer.allocate(minCoords.length * Float.BYTES); minCoordsBuffer.asFloatBuffer().put(minCoords); final byte[] minCoordsCacheKey = minCoordsBuffer.array(); ByteBuffer maxCoordsBuffer = ByteBuffer.allocate(maxCoords.length * Float.BYTES); maxCoordsBuffer.asFloatBuffer().put(maxCoords); final byte[] maxCoordsCacheKey = maxCoordsBuffer.array(); final ByteBuffer cacheKey = ByteBuffer .allocate(1 + minCoordsCacheKey.length + maxCoordsCacheKey.length + Integer.BYTES) .put(minCoordsCacheKey) .put(maxCoordsCacheKey) .putInt(limit) .put(CACHE_TYPE_ID); return cacheKey.array(); } }
private FloatBuffer alocateBuffer(FloatBuffer buffer, float[] data) { if (buffer == null) { buffer = ByteBuffer .allocateDirect(data.length * Geometry3D.FLOAT_SIZE_BYTES * 4) .order(ByteOrder.nativeOrder()).asFloatBuffer(); buffer.put(data); buffer.position(0); } else { buffer.put(data); } return buffer; }
@MarshalsArray public static FloatBuffer toFloatBuffer(Class<?> cls, long handle, long flags, int d1) { return VM.newDirectByteBuffer(handle, d1 << 2).order(ByteOrder.nativeOrder()).asFloatBuffer(); } @MarshalsArray
private boolean matchExactlyTheSame(GeometryData geometryDate, GeometryData d) { ByteBuffer bb1 = ByteBuffer.wrap(geometryDate.getVertices().getData()); bb1.order(ByteOrder.LITTLE_ENDIAN); FloatBuffer buffer1 = bb1.asFloatBuffer(); ByteBuffer bb2 = ByteBuffer.wrap(d.getVertices().getData()); bb2.order(ByteOrder.LITTLE_ENDIAN); FloatBuffer buffer2 = bb2.asFloatBuffer(); if (buffer1.capacity() != buffer2.capacity()) { return false; } for (int i=0; i<buffer1.capacity(); i++) { float a = buffer1.get(); float b = buffer1.get(); if (b != a) { return false; } } return true; } }
@Override public byte[] getCacheKey() { final ByteBuffer minCoordsBuffer = ByteBuffer.allocate(coords.length * Float.BYTES); minCoordsBuffer.asFloatBuffer().put(coords); final byte[] minCoordsCacheKey = minCoordsBuffer.array(); final ByteBuffer cacheKey = ByteBuffer .allocate(1 + minCoordsCacheKey.length + Integer.BYTES + Float.BYTES) .put(minCoordsCacheKey) .putFloat(radius) .putInt(getLimit()) .put(CACHE_TYPE_ID); return cacheKey.array(); } }
public void setColors(float[] colors, boolean override) { final BufferInfo colorInfo = mBuffers.get(COLOR_BUFFER_KEY); if (colorInfo.buffer == null || override == true) { colorInfo.buffer = ByteBuffer .allocateDirect(colors.length * FLOAT_SIZE_BYTES) .order(ByteOrder.nativeOrder()).asFloatBuffer(); ((FloatBuffer) colorInfo.buffer).put(colors); colorInfo.buffer.position(0); } else { ((FloatBuffer) colorInfo.buffer).put(colors); colorInfo.buffer.position(0); } }
/** * Returns a {@link FloatBuffer} which reads and writes to the same memory * location pointed to by this {@link FloatPtr}. * * @param n the maximum number of floats the {@link FloatBuffer} can * read/write. This will be the {@link FloatBuffer}'s * <code>capacity</code>. * @return the {@link FloatBuffer}. */ public FloatBuffer asFloatBuffer(int n) { return as(BytePtr.class).asByteBuffer(n << 2).order(ByteOrder.nativeOrder()).asFloatBuffer(); }