/** * Create a new DoubleBuffer of an appropriate size to hold the specified * number of doubles only if the given buffer if not already the right size. * * @param buf * the buffer to first check and rewind * @param size * number of doubles that need to be held by the newly created * buffer * @return the requested new DoubleBuffer */ public static DoubleBuffer createDoubleBuffer(DoubleBuffer buf, int size) { if (buf != null && buf.limit() == size) { buf.rewind(); return buf; } buf = createDoubleBuffer(size); return buf; }
/** * Creates a double array from the provided {@link DoubleBuffer}. * * @param buffer {@link DoubleBuffer} the data source. * @return double array containing the data of the buffer. */ public static double[] getDoubleArrayFromBuffer(DoubleBuffer buffer) { double[] array = null; if (buffer.hasArray()) { array = buffer.array(); } else { buffer.rewind(); array = new double[buffer.capacity()]; buffer.get(array); } return array; }
/** * 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; }
public void setFromBuffer(DoubleBuffer buffer) { buffer.rewind(); buffer.get(this.position); buffer.get(this.orientation); }
public void setFromBuffer(DoubleBuffer buffer) { buffer.rewind(); buffer.get(this.position); buffer.get(this.orientation); }
public void setFromBuffer(DoubleBuffer buffer) { buffer.rewind(); buffer.get(this.position); buffer.get(this.orientation); }
/** * {@inheritDoc} */ public double[][] toDenseArray() { if (matrixRegions.length > 1) throw new UnsupportedOperationException( "matrix is too large to fit into memory"); double[][] m = new double[rows][cols]; DoubleBuffer b = matrixRegions[0]; b.rewind(); for (int row = 0; row < rows; ++row) b.get(m[row]); return m; }
/** * {@inheritDoc} */ public double[][] toDenseArray() { if (matrixRegions.length > 1) throw new UnsupportedOperationException( "matrix is too large to fit into memory"); double[][] m = new double[rows][cols]; DoubleBuffer b = matrixRegions[0]; b.rewind(); for (int row = 0; row < rows; ++row) b.get(m[row]); return m; }
public static void setBufferToArray(DoubleBuffer buffer, double[] array) { buffer.rewind(); buffer.put(array); }
public void copyToBuffer(DoubleBuffer buffer) { buffer.rewind(); buffer.put(position); buffer.put(orientation); }
@Override void sort(TypedArrayObject typedArray) { DoubleBuffer data = asDoubleBuffer(typedArray); double[] ba = new double[data.remaining()]; data.get(ba); normalizeNaN(ba); Arrays.sort(ba); data.rewind(); data.put(ba); }
public void copyToBuffer(DoubleBuffer buffer) { buffer.rewind(); buffer.put(position); buffer.put(orientation); }
public void copyToBuffer(DoubleBuffer buffer) { buffer.rewind(); buffer.put(position); buffer.put(orientation); }
public static DoubleBuffer newDirectDoubleBuffer(final double[] values, final int offset, final int length) { return (DoubleBuffer)newDirectDoubleBuffer(length).put(values, offset, length).rewind(); }
public DoubleBuffer newDirectDoubleBuffer(final double[] values, final int offset, final int lenght) { return (DoubleBuffer)newDirectDoubleBuffer(lenght).put(values, offset, lenght).rewind(); }
@Override void sort(TypedArrayObject typedArray, Comparator<Number> comparator) { DoubleBuffer data = asDoubleBuffer(typedArray); double[] ba = new double[data.remaining()]; data.get(ba); // Canonicalize NaNs to ensure users only see a single distinct NaN value. normalizeNaN(ba); sortArray(ba, comparator); data.rewind(); data.put(ba); }
/** * Create a new DoubleBuffer of an appropriate size to hold the specified number of doubles only if the given buffer * if not already the right size. * * @param buf * the buffer to first check and rewind * @param size * number of doubles that need to be held by the newly created buffer * @return the requested new DoubleBuffer */ public static DoubleBuffer createDoubleBuffer(DoubleBuffer buf, final int size) { if (buf != null && buf.limit() == size) { buf.rewind(); return buf; } buf = createDoubleBuffer(size); return buf; }
/** * Create a new DoubleBuffer of an appropriate size to hold the specified * number of doubles only if the given buffer if not already the right size. * * @param buf * the buffer to first check and rewind * @param size * number of doubles that need to be held by the newly created * buffer * @return the requested new DoubleBuffer */ public static DoubleBuffer createDoubleBuffer(DoubleBuffer buf, int size) { if (buf != null && buf.limit() == size) { buf.rewind(); return buf; } buf = createDoubleBuffer(size); return buf; }
/** * Creates a double array from the provided {@link DoubleBuffer}. * * @param buffer {@link DoubleBuffer} the data source. * @return double array containing the data of the buffer. */ public static double[] getDoubleArrayFromBuffer(DoubleBuffer buffer) { double[] array = null; if (buffer.hasArray()) { array = buffer.array(); } else { buffer.rewind(); array = new double[buffer.capacity()]; buffer.get(array); } return array; }