本文整理了Java中java.nio.ByteBuffer.asDoubleBuffer()
方法的一些代码示例,展示了ByteBuffer.asDoubleBuffer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuffer.asDoubleBuffer()
方法的具体详情如下:
包路径:java.nio.ByteBuffer
类名称:ByteBuffer
方法名:asDoubleBuffer
[英]Returns a double buffer which is based on the remaining content of this byte buffer.
The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by eight, and its mark is not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this byte buffer is direct.
The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
[中]
代码示例来源:origin: libgdx/libgdx
public static DoubleBuffer newDoubleBuffer (int numDoubles) {
ByteBuffer buffer = ByteBuffer.allocateDirect(numDoubles * 8);
buffer.order(ByteOrder.nativeOrder());
return buffer.asDoubleBuffer();
}
代码示例来源:origin: libgdx/libgdx
public static DoubleBuffer newDoubleBuffer (int numDoubles) {
ByteBuffer buffer = ByteBuffer.allocateDirect(numDoubles * 8);
buffer.order(ByteOrder.nativeOrder());
return buffer.asDoubleBuffer();
}
代码示例来源:origin: apache/incubator-druid
public EntireLayoutColumnarDoublesSupplier(int totalSize, ByteBuffer fromBuffer, ByteOrder byteOrder)
{
this.totalSize = totalSize;
this.buffer = fromBuffer.asReadOnlyBuffer().order(byteOrder).asDoubleBuffer();
}
代码示例来源:origin: bytedeco/javacpp
/** @return {@code asByteBuffer().asDoubleBuffer()} */
@Override public final DoubleBuffer asBuffer() {
return asByteBuffer().asDoubleBuffer();
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public TempBuffer() {
b16 = BufferUtils.createByteBuffer(16);
b16s = b16.asShortBuffer();
b16i = b16.asIntBuffer();
b16l = b16.asLongBuffer();
b16f = b16.asFloatBuffer();
b16d = b16.asDoubleBuffer();
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public TempBuffer() {
b16 = BufferUtils.createByteBuffer(16);
b16s = b16.asShortBuffer();
b16i = b16.asIntBuffer();
b16l = b16.asLongBuffer();
b16f = b16.asFloatBuffer();
b16d = b16.asDoubleBuffer();
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public TempBuffer() {
b16 = BufferUtils.createByteBuffer(16);
b16s = b16.asShortBuffer();
b16i = b16.asIntBuffer();
b16l = b16.asLongBuffer();
b16f = b16.asFloatBuffer();
b16d = b16.asDoubleBuffer();
}
}
代码示例来源:origin: robovm/robovm
@MarshalsArray
public static DoubleBuffer toDoubleBuffer(Class<?> cls, long handle, long flags, int d1) {
return VM.newDirectByteBuffer(handle, d1 << 3).order(ByteOrder.nativeOrder()).asDoubleBuffer();
}
@MarshalsArray
代码示例来源:origin: robovm/robovm
/**
* Returns a {@link DoubleBuffer} which reads and writes to the same memory
* location pointed to by this {@link DoublePtr}.
*
* @param n the maximum number of doubles the {@link DoubleBuffer} can
* read/write. This will be the {@link DoubleBuffer}'s
* <code>capacity</code>.
* @return the {@link DoubleBuffer}.
*/
public DoubleBuffer asDoubleBuffer(int n) {
return as(BytePtr.class).asByteBuffer(n << 3).order(ByteOrder.nativeOrder()).asDoubleBuffer();
}
代码示例来源:origin: apache/incubator-druid
protected void loadBuffer(int bufferNum)
{
CloseQuietly.close(holder);
holder = singleThreadedDoubleBuffers.get(bufferNum);
// asDoubleBuffer() makes the doubleBuffer's position = 0
doubleBuffer = holder.get().asDoubleBuffer();
currBufferNum = bufferNum;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Create a new DoubleBuffer of the specified size.
*
* @param size
* required number of double to store.
* @return the new DoubleBuffer
*/
public static DoubleBuffer createDoubleBuffer(int size) {
DoubleBuffer buf = allocator.allocate(8 * size).order(ByteOrder.nativeOrder()).asDoubleBuffer();
buf.clear();
onBufferAllocated(buf);
return buf;
}
代码示例来源:origin: deeplearning4j/nd4j
DoubleBuffer fromDouble = fromView.asDoubleBuffer();
DoubleBuffer toDouble = toView.asDoubleBuffer();
for (int i = 0; i < n; i++) {
toDouble.put(toOffset + i * toStride, fromDouble.get(fromOffset + i * fromStride));
代码示例来源:origin: h2oai/h2o-2
public double[] getA8d( ) {
_arys++;
int len = getInt(); if( len == -1 ) return null;
double[] buf = MemoryManager.malloc8d(len);
int sofar = 0;
while( sofar < len ) {
DoubleBuffer as = _bb.asDoubleBuffer();
int more = Math.min(as.remaining(), len - sofar);
as.get(buf, sofar, more);
sofar += more;
_bb.position(_bb.position() + as.position()*8);
if( sofar < len ) getSp(Math.min(_bb.capacity()-7, (len-sofar)*8));
}
return buf;
}
public byte[][] getAA1( ) {
代码示例来源:origin: robovm/robovm
/**
* Returns a {@link DoubleBuffer} which reads and writes to the same memory
* location pointed to by this {@link MachineSizedFloatPtr}. Must only be
* called on 64-bit platforms.
*
* @param n the maximum number of doubles the {@link DoubleBuffer} can
* read/write. This will be the {@link DoubleBuffer}'s
* <code>capacity</code>.
* @return the {@link DoubleBuffer}.
* @throws IllegalStateException if this isn't a 64-bit platform.
*/
public DoubleBuffer asDoubleBuffer(int n) {
if (_sizeOf() != 8) {
throw new IllegalStateException("Not a 64-bit platform");
}
return VM.newDirectByteBuffer(getHandle(), n << 3)
.order(ByteOrder.nativeOrder()).asDoubleBuffer();
}
代码示例来源:origin: Rajawali/Rajawali
public void setJoints(SkeletonJoint[] joints) {
if(joints == null)
return;
mJoints = joints;
if (mBoneMatrices == null) {
mBoneMatrices = ByteBuffer
.allocateDirect(joints.length * DOUBLE_SIZE_BYTES * 16)
.order(ByteOrder.nativeOrder()).asDoubleBuffer();
} else
mBoneMatrices.clear();
mBoneMatrices.put(uBoneMatrix);
mBoneMatrices.position(0);
mBoneMatricesBufferInfo.buffer = mBoneMatrices;
mGeometry.addBuffer(mBoneMatricesBufferInfo, BufferType.FLOAT_BUFFER, GLES20.GL_ARRAY_BUFFER);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public DoubleBuffer asNioDouble() {
if (offset() >= Integer.MAX_VALUE)
throw new IllegalStateException("Index out of bounds " + offset());
if (offset() == 0) {
return wrappedBuffer().asDoubleBuffer();
} else {
return (DoubleBuffer) wrappedBuffer().asDoubleBuffer().position((int) (offset()));
}
}
代码示例来源:origin: eclipsesource/J2V8
public int doubleLimit() {
v8.checkThread();
checkReleased();
return byteBuffer.asDoubleBuffer().limit();
}
代码示例来源:origin: h2oai/h2o-2
public AutoBuffer putA8d( double[] ary ) {
_arys++;
if( ary == null ) return putInt(-1);
putInt(ary.length);
int sofar = 0;
while( sofar < ary.length ) {
DoubleBuffer sb = _bb.asDoubleBuffer();
int len = Math.min(ary.length - sofar, sb.remaining());
sb.put(ary, sofar, len);
sofar += len;
_bb.position(_bb.position() + sb.position()*8);
if( sofar < ary.length ) sendPartial();
}
return this;
}
代码示例来源:origin: deeplearning4j/nd4j
switch (_dtype) {
case DOUBLE: {
val db = bb.order(_order).asDoubleBuffer();
for (int e = 0; e < prod; e++)
doubles[e] = db.get(e);
代码示例来源:origin: deeplearning4j/nd4j
/**
* Create a data buffer from
* the given length
*
* @param buffer
* @param length
*/
public BaseDataBuffer(ByteBuffer buffer, long length) {
if (length < 1)
throw new IllegalArgumentException("Length must be >= 1");
initTypeAndSize();
this.length = length;
allocationMode = AllocUtil.getAllocationModeFromContext();
if (dataType() == Type.DOUBLE) {
pointer = new DoublePointer(buffer.asDoubleBuffer());
setIndexer(DoubleIndexer.create((DoublePointer) pointer));
} else if (dataType() == Type.FLOAT) {
pointer = new FloatPointer(buffer.asFloatBuffer());
setIndexer(FloatIndexer.create((FloatPointer) pointer));
} else if (dataType() == Type.INT) {
pointer = new IntPointer(buffer.asIntBuffer());
setIndexer(IntIndexer.create((IntPointer) pointer));
} else if (dataType() == Type.LONG) {
pointer = new LongPointer(buffer.asLongBuffer());
setIndexer(LongIndexer.create((LongPointer) pointer));
}
// log.info("Creating new buffer of size: {}; dtype: {}; D", length, dataType());
}
内容来源于网络,如有侵权,请联系作者删除!