/** * Returns the float data * for this buffer. * If possible (the offset is 0 representing the whole buffer) * it will return a direct reference to the underlying array * @param buf the ndarray to get the data for * @return the double data for this ndarray */ public static float[] getFloatData(DataBuffer buf) { if (buf.allocationMode() == DataBuffer.AllocationMode.HEAP) { return buf.asFloat(); } else { float[] ret = new float[(int) buf.length()]; for (int i = 0; i < buf.length(); i++) ret[i] = buf.getFloat(i); return ret; } }
/** * Returns the double data * for this buffer. * If possible (the offset is 0 representing the whole buffer) * it will return a direct reference to the underlying array * @param buf the ndarray to get the data for * @return the double data for this buffer */ public static double[] getDoubleData(DataBuffer buf) { if (buf.allocationMode() == DataBuffer.AllocationMode.HEAP) return buf.asDouble(); else { double[] ret = new double[(int) buf.length()]; for (int i = 0; i < buf.length(); i++) ret[i] = buf.getDouble(i); return ret; } }
/** * Returns the double data * for this ndarray. * If possible (the offset is 0 representing the whole buffer) * it will return a direct reference to the underlying array * @param buf the ndarray to get the data for * @return the double data for this ndarray */ public static double[] getDoubleData(INDArray buf) { if (buf.data().dataType() != DataBuffer.Type.DOUBLE) throw new IllegalArgumentException("Double data must be obtained from a double buffer"); if (buf.data().allocationMode() == DataBuffer.AllocationMode.HEAP) { return buf.data().asDouble(); } else { double[] ret = new double[(int) buf.length()]; INDArray linear = buf.linearView(); for (int i = 0; i < buf.length(); i++) ret[i] = linear.getDouble(i); return ret; } }
/** * Returns the float data * for this ndarray. * If possible (the offset is 0 representing the whole buffer) * it will return a direct reference to the underlying array * @param buf the ndarray to get the data for * @return the float data for this ndarray */ public static float[] getFloatData(INDArray buf) { if (buf.data().dataType() != DataBuffer.Type.FLOAT) throw new IllegalArgumentException("Float data must be obtained from a float buffer"); if (buf.data().allocationMode() == DataBuffer.AllocationMode.HEAP) { return buf.data().asFloat(); } else { float[] ret = new float[(int) buf.length()]; INDArray linear = buf.linearView(); for (int i = 0; i < buf.length(); i++) ret[i] = linear.getFloat(i); return ret; } }
this.length = length; this.offset = offset; this.allocationMode = underlyingBuffer.allocationMode(); this.elementSize = (byte) underlyingBuffer.getElementSize(); this.underlyingLength = underlyingBuffer.underlyingLength();
if (toSet.data().allocationMode() == DataBuffer.AllocationMode.HEAP) { Object array = toSet.data().array();
if (toSet.data().allocationMode() == DataBuffer.AllocationMode.HEAP) { Object array = toSet.data().array();
/** * Returns the double data * for this buffer. * If possible (the offset is 0 representing the whole buffer) * it will return a direct reference to the underlying array * @param buf the ndarray to get the data for * @return the double data for this buffer */ public static double[] getDoubleData(DataBuffer buf) { if (buf.allocationMode() == DataBuffer.AllocationMode.HEAP) return buf.asDouble(); else { double[] ret = new double[(int) buf.length()]; for (int i = 0; i < buf.length(); i++) ret[i] = buf.getDouble(i); return ret; } }
/** * Returns the float data * for this buffer. * If possible (the offset is 0 representing the whole buffer) * it will return a direct reference to the underlying array * @param buf the ndarray to get the data for * @return the double data for this ndarray */ public static float[] getFloatData(DataBuffer buf) { if (buf.allocationMode() == DataBuffer.AllocationMode.HEAP) { return buf.asFloat(); } else { float[] ret = new float[(int) buf.length()]; for (int i = 0; i < buf.length(); i++) ret[i] = buf.getFloat(i); return ret; } }
/** * Returns the float data * for this ndarray. * If possible (the offset is 0 representing the whole buffer) * it will return a direct reference to the underlying array * @param buf the ndarray to get the data for * @return the float data for this ndarray */ public static float[] getFloatData(INDArray buf) { if (buf.data().dataType() != DataBuffer.Type.FLOAT) throw new IllegalArgumentException("Float data must be obtained from a float buffer"); if (buf.data().allocationMode() == DataBuffer.AllocationMode.HEAP) { return buf.data().asFloat(); } else { float[] ret = new float[buf.length()]; INDArray linear = buf.linearView(); for (int i = 0; i < buf.length(); i++) ret[i] = linear.getFloat(i); return ret; } }
/** * Returns the double data * for this ndarray. * If possible (the offset is 0 representing the whole buffer) * it will return a direct reference to the underlying array * @param buf the ndarray to get the data for * @return the double data for this ndarray */ public static double[] getDoubleData(INDArray buf) { if (buf.data().dataType() != DataBuffer.Type.DOUBLE) throw new IllegalArgumentException("Double data must be obtained from a double buffer"); if (buf.data().allocationMode() == DataBuffer.AllocationMode.HEAP) { return buf.data().asDouble(); } else { double[] ret = new double[buf.length()]; INDArray linear = buf.linearView(); for (int i = 0; i < buf.length(); i++) ret[i] = linear.getDouble(i); return ret; } }
if (toSet.data().allocationMode() == DataBuffer.AllocationMode.HEAP) { Object array = toSet.data().array();
if (toSet.data().allocationMode() == DataBuffer.AllocationMode.HEAP) { Object array = toSet.data().array();