Search in sources :

Example 86 with ShortBuffer

use of java.nio.ShortBuffer in project ffx by mjschnie.

the class Unsigned16BitIntegerMatrixReductionBuf method receiveItems.

// Hidden operations.
/**
 * {@inheritDoc}
 *
 * Receive as many items as possible from the given byte buffer to this
 * buffer.
 * <P>
 * The <TT>receiveItems()</TT> method must not block the calling thread; if
 * it does, all message I/O in MP will be blocked.
 */
protected int receiveItems(int i, int num, ByteBuffer buffer) {
    ShortBuffer shortbuffer = buffer.asShortBuffer();
    num = Math.min(num, shortbuffer.remaining());
    int n = 0;
    int r = i2r(i);
    int row = r * myRowStride + myLowerRow;
    int c = i2c(i);
    int col = c * myColStride + myLowerCol;
    int ncols = Math.min(myColCount - c, num);
    while (r < myRowCount && ncols > 0) {
        int[] myMatrix_row = myMatrix[row];
        for (c = 0; c < ncols; ++c) {
            myMatrix_row[col] = myOp.op(myMatrix_row[col], shortbuffer.get()) & 0xFFFF;
            col += myColStride;
        }
        num -= ncols;
        n += ncols;
        ++r;
        row += myRowStride;
        col = myLowerCol;
        ncols = Math.min(myColCount, num);
    }
    buffer.position(buffer.position() + 2 * n);
    return n;
}
Also used : ShortBuffer(java.nio.ShortBuffer)

Example 87 with ShortBuffer

use of java.nio.ShortBuffer in project ffx by mjschnie.

the class Signed16BitIntegerMatrixBuf method receiveItems.

/**
 * {@inheritDoc}
 *
 * Receive as many items as possible from the given byte buffer to this
 * buffer.
 * <P>
 * The <TT>receiveItems()</TT> method must not block the calling thread; if
 * it does, all message I/O in MP will be blocked.
 */
protected int receiveItems(int i, int num, ByteBuffer buffer) {
    ShortBuffer shortbuffer = buffer.asShortBuffer();
    num = Math.min(num, shortbuffer.remaining());
    int n = 0;
    int r = i2r(i);
    int row = r * myRowStride + myLowerRow;
    int c = i2c(i);
    int col = c * myColStride + myLowerCol;
    int ncols = Math.min(myColCount - c, num);
    while (r < myRowCount && ncols > 0) {
        int[] myMatrix_row = myMatrix[row];
        for (c = 0; c < ncols; ++c) {
            myMatrix_row[col] = shortbuffer.get();
            col += myColStride;
        }
        num -= ncols;
        n += ncols;
        ++r;
        row += myRowStride;
        col = myLowerCol;
        ncols = Math.min(myColCount, num);
    }
    buffer.position(buffer.position() + 2 * n);
    return n;
}
Also used : ShortBuffer(java.nio.ShortBuffer)

Example 88 with ShortBuffer

use of java.nio.ShortBuffer in project ffx by mjschnie.

the class Signed16BitIntegerMatrixReductionBuf method receiveItems.

// Hidden operations.
/**
 * {@inheritDoc}
 *
 * Receive as many items as possible from the given byte buffer to this
 * buffer.
 * <P>
 * The <TT>receiveItems()</TT> method must not block the calling thread; if
 * it does, all message I/O in MP will be blocked.
 */
protected int receiveItems(int i, int num, ByteBuffer buffer) {
    ShortBuffer shortbuffer = buffer.asShortBuffer();
    num = Math.min(num, shortbuffer.remaining());
    int n = 0;
    int r = i2r(i);
    int row = r * myRowStride + myLowerRow;
    int c = i2c(i);
    int col = c * myColStride + myLowerCol;
    int ncols = Math.min(myColCount - c, num);
    while (r < myRowCount && ncols > 0) {
        int[] myMatrix_row = myMatrix[row];
        for (c = 0; c < ncols; ++c) {
            myMatrix_row[col] = myOp.op(myMatrix_row[col], shortbuffer.get());
            col += myColStride;
        }
        num -= ncols;
        n += ncols;
        ++r;
        row += myRowStride;
        col = myLowerCol;
        ncols = Math.min(myColCount, num);
    }
    buffer.position(buffer.position() + 2 * n);
    return n;
}
Also used : ShortBuffer(java.nio.ShortBuffer)

Example 89 with ShortBuffer

use of java.nio.ShortBuffer in project ffx by mjschnie.

the class ShortMatrixBuf method receiveItems.

/**
 * {@inheritDoc}
 *
 * Receive as many items as possible from the given byte buffer to this
 * buffer.
 * <P>
 * The <TT>receiveItems()</TT> method must not block the calling thread; if
 * it does, all message I/O in MP will be blocked.
 */
protected int receiveItems(int i, int num, ByteBuffer buffer) {
    ShortBuffer shortbuffer = buffer.asShortBuffer();
    num = Math.min(num, shortbuffer.remaining());
    int n = 0;
    int r = i2r(i);
    int row = r * myRowStride + myLowerRow;
    int c = i2c(i);
    int col = c * myColStride + myLowerCol;
    int ncols = Math.min(myColCount - c, num);
    while (r < myRowCount && ncols > 0) {
        short[] myMatrix_row = myMatrix[row];
        for (c = 0; c < ncols; ++c) {
            myMatrix_row[col] = shortbuffer.get();
            col += myColStride;
        }
        num -= ncols;
        n += ncols;
        ++r;
        row += myRowStride;
        col = myLowerCol;
        ncols = Math.min(myColCount, num);
    }
    buffer.position(buffer.position() + 2 * n);
    return n;
}
Also used : ShortBuffer(java.nio.ShortBuffer)

Example 90 with ShortBuffer

use of java.nio.ShortBuffer in project ffx by mjschnie.

the class ShortMatrixReductionBuf method receiveItems.

// Hidden operations.
/**
 * {@inheritDoc}
 *
 * Receive as many items as possible from the given byte buffer to this
 * buffer.
 * <P>
 * The <TT>receiveItems()</TT> method must not block the calling thread; if
 * it does, all message I/O in MP will be blocked.
 */
protected int receiveItems(int i, int num, ByteBuffer buffer) {
    ShortBuffer shortbuffer = buffer.asShortBuffer();
    num = Math.min(num, shortbuffer.remaining());
    int n = 0;
    int r = i2r(i);
    int row = r * myRowStride + myLowerRow;
    int c = i2c(i);
    int col = c * myColStride + myLowerCol;
    int ncols = Math.min(myColCount - c, num);
    while (r < myRowCount && ncols > 0) {
        short[] myMatrix_row = myMatrix[row];
        for (c = 0; c < ncols; ++c) {
            myMatrix_row[col] = myOp.op(myMatrix_row[col], shortbuffer.get());
            col += myColStride;
        }
        num -= ncols;
        n += ncols;
        ++r;
        row += myRowStride;
        col = myLowerCol;
        ncols = Math.min(myColCount, num);
    }
    buffer.position(buffer.position() + 2 * n);
    return n;
}
Also used : ShortBuffer(java.nio.ShortBuffer)

Aggregations

ShortBuffer (java.nio.ShortBuffer)227 ByteBuffer (java.nio.ByteBuffer)78 FloatBuffer (java.nio.FloatBuffer)54 IntBuffer (java.nio.IntBuffer)45 DoubleBuffer (java.nio.DoubleBuffer)23 LongBuffer (java.nio.LongBuffer)16 Test (org.junit.Test)14 Buffer (java.nio.Buffer)11 BufferOverflowException (java.nio.BufferOverflowException)11 CharBuffer (java.nio.CharBuffer)11 VertexBuffer (com.jme3.scene.VertexBuffer)8 BufferUnderflowException (java.nio.BufferUnderflowException)7 BytePointer (org.bytedeco.javacpp.BytePointer)7 IndexBuffer (com.jme3.scene.mesh.IndexBuffer)6 IOException (java.io.IOException)5 Vector3f (com.jme3.math.Vector3f)4 ArrayList (java.util.ArrayList)4 Bitmap (android.graphics.Bitmap)3 Mesh (com.jme3.scene.Mesh)3 InvalidMarkException (java.nio.InvalidMarkException)3