@Generates private DoubleBuffer generateDoubleBuffer() { return DoubleBuffer.allocate(generateInt()); } }
/** * Creates a new DoubleBuffer with the same contents as the given * DoubleBuffer. The new DoubleBuffer is separate from the old one and * changes are not reflected across. If you want to reflect changes, * consider using Buffer.duplicate(). * * @param buf * the DoubleBuffer to copy * @return the copy */ public static DoubleBuffer clone(DoubleBuffer buf) { if (buf == null) { return null; } buf.rewind(); DoubleBuffer copy; if (isDirect(buf)) { copy = createDoubleBuffer(buf.limit()); } else { copy = DoubleBuffer.allocate(buf.limit()); } copy.put(buf); return copy; }
protected BufferVector(int length) { this(DoubleBuffer.allocate(length), length); }
protected BufferMatrix(int rows, int cols) { this(DoubleBuffer.allocate(rows*cols), rows, cols); }
protected BufferVector(int length) { this(DoubleBuffer.allocate(length), length); }
protected BufferMatrix(int rows, int cols) { this(DoubleBuffer.allocate(rows*cols), rows, cols); }
DoubleBuffer buf = DoubleBuffer.allocate([ ParseTree.class.getMethods().lenght);
public static BufferArray make(final int capacity) { return new DoubleBufferArray(DoubleBuffer.allocate(capacity), null); }
public static BufferArray make(final int capacity) { return new DoubleBufferArray(DoubleBuffer.allocate(capacity), null); }
protected DoubleBuffer get2dPoint( final GL2 gl, final double x, final double y, final double z ) { final DoubleBuffer model = DoubleBuffer.allocate(16); gl.glGetDoublev( GLMatrixFunc.GL_MODELVIEW_MATRIX, model ); final DoubleBuffer proj = DoubleBuffer.allocate(16); gl.glGetDoublev( GLMatrixFunc.GL_PROJECTION_MATRIX, proj ); final IntBuffer view = IntBuffer.allocate(4); gl.glGetIntegerv( GL.GL_VIEWPORT, view ); final DoubleBuffer winPos = DoubleBuffer.allocate(3); final boolean b = this.glu.gluProject( x, y, z, model, proj, view, winPos ); if( !b ) System.out.println( "FAIL "); return winPos; }
@Generates private DoubleBuffer generateDoubleBuffer() { return DoubleBuffer.allocate(generateInt()); } }
@Generates private DoubleBuffer freshDoubleBuffer() { return DoubleBuffer.allocate(freshInt()); } }
// Important! origBuf.rewind(); final DoubleBuffer newBuf = DoubleBuffer.allocate(origBuf.remaining() * 2); double value; while (origBuf.hasRemaining()) { value = origBuf.get(); newBuf.put(value).put(value); }
private void ensureCapacity() { int size = (int) Math.round((throughputProvider.getThroughput() * durationProvider.getDuration() + 1) * 3); if (events != null && events.capacity() >= size) { return; } events = DoubleBuffer.allocate(size); }
/** * Creates a indirect buffer of the specified size (in elements) and type.. * @param size size of the buffer in elements * @param bufferClass type of the buffer. Must be one of IntBuffer.class, LongBuffer.class, ShortBuffer.class, ByteBuffer.class, DoubleBuffer.class, FloatBuffer.class * @return view on new direct buffer */ @SuppressWarnings("unchecked") public static <B extends Buffer> B indirectBuffer(int size, Class<B> bufferClass) { if (IntBuffer.class.isAssignableFrom(bufferClass)) return (B)IntBuffer.allocate(size); if (LongBuffer.class.isAssignableFrom(bufferClass)) return (B)LongBuffer.allocate(size); if (ShortBuffer.class.isAssignableFrom(bufferClass)) return (B)ShortBuffer.allocate(size); if (ByteBuffer.class.isAssignableFrom(bufferClass)) return (B)ByteBuffer.allocate(size); if (DoubleBuffer.class.isAssignableFrom(bufferClass)) return (B)DoubleBuffer.allocate(size); if (FloatBuffer.class.isAssignableFrom(bufferClass)) return (B)FloatBuffer.allocate(size); if (CharBuffer.class.isAssignableFrom(bufferClass)) return (B)CharBuffer.allocate(size); throw new UnsupportedOperationException("Cannot create indirect buffers of type " + bufferClass.getName()); } /**
@Override protected DoubleBuffer deserialize(final ArrayNode input) throws JsonProcessingException { final DoubleBuffer result = DoubleBuffer.allocate(input.size()); for(final JsonNode node: input) result.put(node.asDouble()); return result; } }
static ExecResult<DoubleBuffer> testJava_double_aSinB(int loops, int dataSize) throws CLBuildException { DoubleBuffer aBuffer = DoubleBuffer.allocate(dataSize); DoubleBuffer bBuffer = DoubleBuffer.allocate(dataSize); DoubleBuffer outputBuffer = DoubleBuffer.allocate(dataSize); double[] a = aBuffer.array(), b = bBuffer.array(), output = outputBuffer.array(); if (warmup) { System.out.print("Warming up Java operations..."); for (int i = 0; i < 3000; i++) { java_aSinB(a, b, output, 100); } System.out.println(); } fillBuffersWithSomeDatad(aBuffer, bBuffer); gc(); long start = System.nanoTime(); for (int i = 0; i < loops; i++) { java_aSinB(a, b, output, dataSize); } long time = System.nanoTime() - start; System.out.println("Java operations : " + time + "ns"); return new ExecResult<DoubleBuffer>(outputBuffer, time / (loops * (double) dataSize)); }
/** * Creates a new DoubleBuffer with the same contents as the given * DoubleBuffer. The new DoubleBuffer is separate from the old one and * changes are not reflected across. If you want to reflect changes, * consider using Buffer.duplicate(). * * @param buf * the DoubleBuffer to copy * @return the copy */ public static DoubleBuffer clone(DoubleBuffer buf) { if (buf == null) { return null; } buf.rewind(); DoubleBuffer copy; if (isDirect(buf)) { copy = createDoubleBuffer(buf.limit()); } else { copy = DoubleBuffer.allocate(buf.limit()); } copy.put(buf); return copy; }
/** * Creates a new DoubleBuffer with the same contents as the given * DoubleBuffer. The new DoubleBuffer is seperate from the old one and * changes are not reflected across. If you want to reflect changes, * consider using Buffer.duplicate(). * * @param buf * the DoubleBuffer to copy * @return the copy */ public static DoubleBuffer clone(DoubleBuffer buf) { if (buf == null) { return null; } buf.rewind(); DoubleBuffer copy; if (buf.isDirect()) { copy = createDoubleBuffer(buf.limit()); } else { copy = DoubleBuffer.allocate(buf.limit()); } copy.put(buf); return copy; }
private void testBufferRoundTrip(INDArray a) { int len = (int) a.elementCount(); DoubleBuffer buf = DoubleBuffer.allocate(len); assertEquals(len, buf.remaining()); a.toDoubleBuffer(buf); assertEquals(0, buf.remaining()); buf.flip(); AVector vv = Vectorz.create(buf); assertEquals(a.asVector(), vv); assertEquals(a, vv.reshape(a.getShape())); }