List of usage examples for java.nio FloatBuffer put
public abstract FloatBuffer put(int index, float f);
From source file:Main.java
public static void main(String[] args) { FloatBuffer floatBuffer = FloatBuffer.allocate(10); floatBuffer.put(0, 1.23F); floatBuffer.rewind();// ww w .java 2 s .com FloatBuffer floatBuffer1 = floatBuffer.duplicate(); System.out.println(floatBuffer.equals(floatBuffer1)); }
From source file:Main.java
public static void main(String[] args) { FloatBuffer floatBuffer = FloatBuffer.allocate(10); floatBuffer.put(0, 1.23F); floatBuffer.rewind();//w w w. j a va 2s . c om FloatBuffer floatBuffer1 = floatBuffer.slice(); System.out.println(floatBuffer.equals(floatBuffer1)); }
From source file:Main.java
public static void main(String[] args) { FloatBuffer floatBuffer = FloatBuffer.allocate(10); floatBuffer.put(0, 1.23F); floatBuffer.rewind();/*from ww w .j a va 2s . c o m*/ FloatBuffer floatBuffer1 = floatBuffer.compact(); System.out.println(floatBuffer.equals(floatBuffer1)); }
From source file:Main.java
public static void main(String[] args) { FloatBuffer floatBuffer = FloatBuffer.allocate(10); floatBuffer.put(0, 1.23F); floatBuffer.rewind();/*from w w w . j a v a2 s.c o m*/ FloatBuffer floatBuffer1 = floatBuffer.compact(); System.out.println(floatBuffer.compareTo(floatBuffer1)); }
From source file:Main.java
public static void main(String[] args) { FloatBuffer floatBuffer = FloatBuffer.allocate(10); floatBuffer.put(0, 1.23F); floatBuffer.rewind();//from ww w. ja v a 2 s.c om FloatBuffer floatBuffer1 = FloatBuffer.allocate(10); floatBuffer1.put(floatBuffer); System.out.println(floatBuffer.arrayOffset()); }
From source file:Main.java
public static void main(String[] args) { FloatBuffer floatBuffer = FloatBuffer.allocate(10); floatBuffer.put(0, 1.23F); floatBuffer.rewind();//w w w . ja va 2s . co m float[] floatArray = new float[10]; floatBuffer.get(floatArray); System.out.println(Arrays.toString(floatArray)); }
From source file:Main.java
public static void main(String[] args) { FloatBuffer floatBuffer = FloatBuffer.allocate(10); floatBuffer.put(0, 1.23F); floatBuffer.rewind();/*from w ww . j a v a2 s.c o m*/ float[] floatArray = new float[10]; floatBuffer.get(floatArray, 0, 3); System.out.println(Arrays.toString(floatArray)); }
From source file:org.apache.sysml.runtime.matrix.data.LibMatrixNative.java
private static FloatBuffer toFloatBuffer(double[] input, ThreadLocal<FloatBuffer> buff, boolean copy) { //maintain thread-local buffer (resized on demand) FloatBuffer ret = buff.get(); if (ret == null || ret.capacity() < input.length) { ret = ByteBuffer.allocateDirect(4 * input.length).order(ByteOrder.nativeOrder()).asFloatBuffer(); buff.set(ret);// w w w . j av a 2s.co m } //copy to direct byte buffer final FloatBuffer ret2 = ret; if (copy) { IntStream.range(0, input.length).parallel().forEach(i -> ret2.put(i, (float) input[i])); } return ret2; }
From source file:ummisco.gama.opengl.vaoGenerator.GeomMathUtils.java
static public FloatBuffer getFloatBuffer(final Matrix4f matrix) { final FloatBuffer result = FloatBuffer.allocate(16); result.put(0, matrix.m00); result.put(1, matrix.m01);//from ww w. ja v a 2 s . c o m result.put(2, matrix.m02); result.put(3, matrix.m03); result.put(4, matrix.m10); result.put(5, matrix.m11); result.put(6, matrix.m12); result.put(7, matrix.m13); result.put(8, matrix.m20); result.put(9, matrix.m21); result.put(10, matrix.m22); result.put(11, matrix.m23); result.put(12, matrix.m30); result.put(13, matrix.m31); result.put(14, matrix.m32); result.put(15, matrix.m33); return result; }
From source file:BufferTest.java
private long singleIndexedPut(float[] data, int elements, FloatBuffer target, int testTime) { long start = System.currentTimeMillis(); long elapsed = 0; int reps = 0; target.clear();//from www . java 2 s .c o m do { for (int i = 0; i < elements; i++) { target.put(i, data[i]); } reps++; elapsed = System.currentTimeMillis() - start; } while (elapsed < testTime); long bytes = (long) elements * (long) reps * 4; return bytes / elapsed / 1024; }