@Override public void setData(float[] data) { for (int i = 0; i < data.length; i++) { put(i, data[i]); } }
@Override public void setData(double[] data) { for (int i = 0; i < data.length; i++) { put(i, data[i]); } }
@Override public void setData(int[] data) { for (int i = 0; i < data.length; i++) { put(i, data[i]); } }
public void putByGlobalType(long i, Number element, Type globalType) { if (globalType == Type.INT || type == Type.INT) { int anElement = element.intValue(); put(i, anElement); } else if (globalType == Type.FLOAT || globalType == Type.HALF) { float anElement = element.floatValue(); put(i, anElement); } else if (globalType == Type.DOUBLE) { double anElement = element.doubleValue(); put(i, anElement); } else if (globalType == Type.LONG) { long anElement = element.longValue(); put(i, anElement); } }
@Override public void assign(Number value, long offset) { //note here that the final put will take care of the offset for (long i = offset; i < length(); i++) put(i, value.doubleValue()); }
@Override public void copyAtStride(DataBuffer buf, long n, long stride, long yStride, long offset, long yOffset) { if (dataType() == Type.FLOAT) { for (int i = 0; i < n; i++) { put(offset + i * stride, buf.getFloat(yOffset + i * yStride)); } } else { for (int i = 0; i < n; i++) { put(offset + i * stride, buf.getDouble(yOffset + i * yStride)); } } }
@Override public void assign(long[] indices, double[] data, boolean contiguous, long inc) { if (indices.length != data.length) throw new IllegalArgumentException("Indices and data length must be the same"); if (indices.length > length()) throw new IllegalArgumentException("More elements than space to assign. This buffer is of length " + length() + " where the indices are of length " + data.length); for (int i = 0; i < indices.length; i += inc) { put(indices[i], data[i]); } }
@Override public void assign(long[] indices, float[] data, boolean contiguous, long inc) { if (indices.length != data.length) throw new IllegalArgumentException("Indices and data length must be the same"); if (indices.length > length()) throw new IllegalArgumentException("More elements than space to assign. This buffer is of length " + length() + " where the indices are of length " + data.length); for (int i = 0; i < indices.length; i++) { put(indices[i], data[i]); } }
@Override public void assign(long[] offsets, long[] strides, long n, DataBuffer... buffers) { if (offsets.length != strides.length || strides.length != buffers.length) throw new IllegalArgumentException( "Unable to assign buffers, please specify equal lengths strides, offsets, and buffers"); int count = 0; for (int i = 0; i < buffers.length; i++) { //note here that the final put will take care of the offset for (long j = offsets[i]; j < buffers[i].length(); j += strides[i]) { put(count++, buffers[i].getDouble(j)); } } if (count != n) throw new IllegalArgumentException("Strides and offsets didn't match up to length " + n); }
@Override public void assign(DataBuffer data) { if (data.length() != length()) throw new IllegalArgumentException("Unable to assign buffer of length " + data.length() + " to this buffer of length " + length()); for (int i = 0; i < data.length(); i++) { put(i, data.getDouble(i)); } }
@Override public void put(long i, float element) { allocator.synchronizeHostData(this); allocator.tickHostWrite(this); super.put(i, element); }
@Override public void put(long i, double element) { allocator.synchronizeHostData(this); allocator.tickHostWrite(this); super.put(i, element); }
@Override public void put(long i, int element) { allocator.synchronizeHostData(this); allocator.tickHostWrite(this); super.put(i, element); }
@Override public void put(long i, double element) { allocator.synchronizeHostData(this); allocator.tickHostWrite(this); super.put(i, element); }
@Override public void put(long i, int element) { allocator.synchronizeHostData(this); allocator.tickHostWrite(this); super.put(i, element); }
@Override public void put(long i, float element) { allocator.synchronizeHostData(this); allocator.tickHostWrite(this); super.put(i, element); }