/** @return {@code put(array, 0, array.length)} */ public DoublePointer put(double ... array) { return put(array, 0, array.length); } /**
/** * Allocates enough memory for the array and copies it. * * @param array the array to copy * @see #put(double[]) */ public DoublePointer(double ... array) { this(array.length); put(array); } /**
/** @return {@code put(0, d)} */ public DoublePointer put(double d) { return put(0, d); } /**
@Override public void release() { pointer.position(position).put(array); super.release(); } };
public BaseDataBuffer(double[] data, boolean copy, MemoryWorkspace workspace) { allocationMode = AllocUtil.getAllocationModeFromContext(); length = data.length; underlyingLength = data.length; attached = true; parentWorkspace = workspace; initTypeAndSize(); //log.info("Allocating FloatPointer from array of {} elements", data.length); pointer = workspace.alloc(data.length * getElementSize(), dataType(), false).asDoublePointer().put(data); workspaceGenerationId = workspace.getGenerationId(); indexer = DoubleIndexer.create((DoublePointer) pointer); //wrappedBuffer = pointer.asByteBuffer(); }
/** * For direct buffers, calls {@link Pointer#Pointer(Buffer)}, while for buffers * backed with an array, allocates enough memory for the array and copies it. * * @param buffer the Buffer to reference or copy * @see #put(double[]) */ public DoublePointer(DoubleBuffer buffer) { super(buffer); if (buffer != null && !buffer.isDirect() && buffer.hasArray()) { double[] array = buffer.array(); allocateArray(array.length - buffer.arrayOffset()); put(array, buffer.arrayOffset(), array.length - buffer.arrayOffset()); position(buffer.position()); limit(buffer.limit()); } } /**
/** * Sets specified value at specified index. * <pre> * {@code nativeArray[i] = v; } * </pre> * @param i index * @param v value * @return this for chaining */ @DoublePrecisionVersion public NativeRealArray set(long i, double v){ if(i >= this.length){ throw new ArrayIndexOutOfBoundsException( String.format("Cannot set value at %d, array is of length %d", i, this.length)); } pointer.position(0).put(i, v); return this; }
/** * Reads <i>length</i> number of elements from the specified * array starting at <i>offset</i> and puts them into this * native array starting at <i>i</i>. * <pre> * {@code for(j=0;j<length;j++) nativeArray[i+j]=values[offset+j]; } * </pre> * @param i offset into this native array * @param length number of values to be copied * @param offset into the specified array * @param values the array from which values will be copied * @return this for chaining * * @throws IllegalArgumentException when specified offset plus length exceeds the specified values array's length */ @DoublePrecisionVersion public NativeRealArray set(long i, int length, int offset, double[] values){ if(offset+length > values.length){ throw new IllegalArgumentException( String.format("Cannot read %d values starting from %d, argument array is only of length %d", length, offset, values.length)); } if(i+length > this.length){ throw new ArrayIndexOutOfBoundsException( String.format("Number of values to be set (%d) to insert at index %d exceed length of this array (%d)", length, i, this.length)); } pointer.position(i).put(values, offset, length); return this; }
tArgs.put(cnt++, (float) t);
DoubleBuffer b = (DoubleBuffer)samples[i]; if (samples_in[i] instanceof DoublePointer && samples_in[i].capacity() >= inputSize && b.hasArray()) { ((DoublePointer)samples_in[i]).position(0).put(b.array(), b.position(), inputSize); } else { samples_in[i] = new DoublePointer(b);
DoubleBuffer b = (DoubleBuffer)samples[i]; if (samples_in[i] instanceof DoublePointer && samples_in[i].capacity() >= inputSize && b.hasArray()) { ((DoublePointer)samples_in[i]).position(0).put(b.array(), b.position(), inputSize); } else { samples_in[i] = new DoublePointer(b);
for (int e = 0; e < op.getRealArguments().size(); e++) { idx = realPos + (i * op.maxRealArguments()); dPtr.put(idx + e, op.getRealArguments().get(e).doubleValue());
for (int e = 0; e < op.getRealArguments().size(); e++) { idx = realPos + (i * op.maxRealArguments()); dPtr.put(idx + e, op.getRealArguments().get(e).doubleValue());
tArgs.put(cnt++, t);