Package java.nio

Examples of java.nio.ByteBuffer.asFloatBuffer()


            final ByteBuffer f223bb = MyJapi.f223bb().order(ByteOrder.nativeOrder());
            final float nf223bb = f223bb.asFloatBuffer().get();
            MyJapi.f323bb(f223bb);
            assert (nf223bb == f223bb.asFloatBuffer().get());
            MyJapi.f323bb(MyJapi.f223bb());
            assert (nf223bb + 1 == f223bb.asFloatBuffer().get());

            out.println("\ncalling f324bb(f224bb())");
            final ByteBuffer f224bb = MyJapi.f224bb().order(ByteOrder.nativeOrder());
            final double nf224bb = f224bb.asDoubleBuffer().get();
            MyJapi.f324bb(f224bb);
View Full Code Here


            MyJapi.f342bb(f242bb);
            assert (nf242bb + 1 == f242bb.asLongBuffer().get());

            out.println("\ncalling f343bb(f243bb())");
            final ByteBuffer f243bb = MyJapi.f243bb().order(ByteOrder.nativeOrder());
            final float nf243bb = f243bb.asFloatBuffer().get();
            MyJapi.f343bb(f243bb);
            assert (nf243bb + 1 == f243bb.asFloatBuffer().get());

            out.println("\ncalling f344bb(f244bb())");
            final ByteBuffer f244bb = MyJapi.f244bb().order(ByteOrder.nativeOrder());
View Full Code Here

            out.println("\ncalling f343bb(f243bb())");
            final ByteBuffer f243bb = MyJapi.f243bb().order(ByteOrder.nativeOrder());
            final float nf243bb = f243bb.asFloatBuffer().get();
            MyJapi.f343bb(f243bb);
            assert (nf243bb + 1 == f243bb.asFloatBuffer().get());

            out.println("\ncalling f344bb(f244bb())");
            final ByteBuffer f244bb = MyJapi.f244bb().order(ByteOrder.nativeOrder());
            final double nf244bb = f244bb.asDoubleBuffer().get();
            MyJapi.f344bb(f244bb);
View Full Code Here

        if (BinaryImporter.canUseFastBuffers()){
            ByteBuffer value = BufferUtils.createByteBuffer(length * 4);
            value.put(content, index, length * 4).rewind();
            index += length * 4;
            return value.asFloatBuffer();
        }else{
            FloatBuffer value = BufferUtils.createFloatBuffer(length);
            for (int x = 0; x < length; x++) {
                value.put(readFloatForBuffer(content));
            }
View Full Code Here

    }
    public void testFloatBufferPut() {
        final float MAGIC = 1234.5678f;
        Memory m = new Memory(8);
        ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder());
        FloatBuffer fb = buf.asFloatBuffer();
        fb.put(MAGIC).flip();
        assertEquals("Int not written to memory", MAGIC,
                m.getFloat(0));
    }
    public void testDoubleBufferPut() {
View Full Code Here

    }
    public void testFloatBufferGet() {
        final float MAGIC = 1234.5678f;
        Memory m = new Memory(8);
        ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder());
        FloatBuffer fb = buf.asFloatBuffer();
        m.setFloat(0, MAGIC);
        assertEquals("Float not read from memory", MAGIC,
                fb.get(0));
    }
    public void testDoubleBufferGet() {
View Full Code Here

        assertEquals("IntBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asIntBuffer()));
        assertEquals("LongBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asLongBuffer()));
        assertEquals("FloatBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asFloatBuffer()));
        assertEquals("DoubleBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asDoubleBuffer()));

        assertEquals("Wrong direct buffer address",
                     p, Native.getDirectBufferPointer(b));
View Full Code Here

  public static byte[] FloatArraytoByteArray(float floatArray[]) {
    byte byteArray[] = new byte[floatArray.length*4];
   
    ByteBuffer byteBuf = ByteBuffer.wrap(byteArray);
   
    FloatBuffer floatBuf = byteBuf.asFloatBuffer();
   
    floatBuf.put (floatArray);
   
    return byteArray;
  }
View Full Code Here

  public static float[] ByteArraytoFloatArray(byte byteArray[]) {
    float floatArray[] = new float[byteArray.length/4];

    ByteBuffer byteBuf = ByteBuffer.wrap(byteArray);

    FloatBuffer floatBuf = byteBuf.asFloatBuffer();

    floatBuf.get (floatArray);

    return floatArray;
  }
View Full Code Here

            // create little endian store
            final ByteBuffer buf = ByteBuffer.allocate(array.length).order(ByteOrder.LITTLE_ENDIAN);

            // place buffer into store.
            value.rewind();
            buf.asFloatBuffer().put(value);
            buf.rewind();

            // Pull out store as array
            buf.get(array);
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.