List of utility methods to do FloatBuffer Create
FloatBuffer | buildFloatBuffer(float[] buffer) build FloatBuffer: float[] -> FloatBuffer FloatBuffer ret = null;
if (buffer != null) {
ByteBuffer byteBuffer = ByteBuffer
.allocateDirect(buffer.length * 4);
byteBuffer.order(ByteOrder.nativeOrder());
ret = byteBuffer.asFloatBuffer();
ret.put(buffer);
ret.position(0);
...
|
FloatBuffer | asFloatBuffer(float[] array) as Float Buffer ByteBuffer bbuf = ByteBuffer.allocateDirect(array.length
* BYTES_PER_FLOAT);
bbuf.order(ByteOrder.nativeOrder());
FloatBuffer fbuf = bbuf.asFloatBuffer();
fbuf.put(array);
fbuf.position(0);
return fbuf;
|
FloatBuffer | wrap(float[] buffer) wrap return (FloatBuffer) ByteBuffer.allocateDirect(buffer.length * 4)
.order(ByteOrder.nativeOrder()).asFloatBuffer().put(buffer)
.position(0);
|
FloatBuffer | makeFloatBuffer(float[] array) make Float Buffer final int floatSize = Float.SIZE / 8; ByteBuffer byteBuffer = ByteBuffer.allocateDirect(array.length * floatSize); byteBuffer.order(ByteOrder.nativeOrder()); FloatBuffer floatBuffer = byteBuffer.asFloatBuffer(); floatBuffer.put(array); floatBuffer.position(0); return floatBuffer; ... |
FloatBuffer | makeFloatBuffer(float[][] array, int rows, int cols) make Float Buffer float[] result = new float[rows * cols]; for (int i = 0, k = 0; i < rows; i++) for (int j = 0; j < cols; j++) result[k++] = array[i][j]; return makeFloatBuffer(result); |
FloatBuffer | makeFloatBuffer(int length) make Float Buffer final int floatSize = Float.SIZE / 8; ByteBuffer byteBuffer = ByteBuffer.allocateDirect(length * floatSize); byteBuffer.order(ByteOrder.nativeOrder()); FloatBuffer floatBuffer = byteBuffer.asFloatBuffer(); floatBuffer.position(0); return floatBuffer; |
FloatBuffer | ConvToFloatBuffer(float buf[]) Conv To Float Buffer FloatBuffer ReturnBuffer;
ByteBuffer vbb = ByteBuffer.allocateDirect(buf.length * 4);
vbb.order(ByteOrder.nativeOrder());
ReturnBuffer = vbb.asFloatBuffer();
ReturnBuffer.put(buf);
ReturnBuffer.position(0);
return ReturnBuffer;
|
FloatBuffer | ConvToFloatBuffer(float buf[]) Conv To Float Buffer FloatBuffer ReturnBuffer;
ByteBuffer vbb = ByteBuffer.allocateDirect(buf.length * 4);
vbb.order(ByteOrder.nativeOrder());
ReturnBuffer = vbb.asFloatBuffer();
ReturnBuffer.put(buf);
ReturnBuffer.position(0);
return ReturnBuffer;
|
FloatBuffer | makeFloatBuffer(float[] arr) Make a direct NIO FloatBuffer from an array of floats ByteBuffer bb = ByteBuffer.allocateDirect(arr.length * 4);
bb.order(ByteOrder.nativeOrder());
FloatBuffer fb = bb.asFloatBuffer();
fb.put(arr);
fb.position(0);
return fb;
|
FloatBuffer | makeFloatBuffer(float[] i_arr) make Float Buffer ByteBuffer bb = ByteBuffer.allocateDirect(i_arr.length * 4);
bb.order(ByteOrder.nativeOrder());
FloatBuffer fb = bb.asFloatBuffer();
fb.put(i_arr);
fb.position(0);
return fb;
|