@Override public DataBuffer createDouble(long offset, int[] data, boolean copy) { return new DoubleBuffer(ArrayUtil.toDoubles(data), true, offset); }
@Override public DataBuffer createDouble(long offset, float[] data) { return new DoubleBuffer(ArrayUtil.toDoubles(data), true, offset); }
@Override public DataBuffer createDouble(int[] data, boolean copy) { return new DoubleBuffer(ArrayUtil.toDoubles(data), copy); }
@Override public DataBuffer createDouble(long offset, float[] data, boolean copy) { return new DoubleBuffer(ArrayUtil.toDoubles(data), copy, offset); }
public static double[] toDoubles(int[][] ints) { return toDoubles(Ints.concat(ints)); }
/** * Array of evenly spaced values. * * @param begin the begin of the range * @param end the end of the range * @return the range vector */ @Override public INDArray arange(double begin, double end) { return Nd4j.create(ArrayUtil.toDoubles(ArrayUtil.range((int) begin, (int) end))); }
public static INDArray toNDArray(int[][] nums) { if (Nd4j.dataType() == DataBuffer.Type.DOUBLE) { double[] doubles = ArrayUtil.toDoubles(nums); INDArray create = Nd4j.create(doubles, new int[] {nums[0].length, nums.length}); return create; } else { float[] doubles = ArrayUtil.toFloats(nums); INDArray create = Nd4j.create(doubles, new int[] {nums[0].length, nums.length}); return create; } }
public static INDArray toNDArray(int[] nums) { if (Nd4j.dataType() == DataBuffer.Type.DOUBLE) { double[] doubles = ArrayUtil.toDoubles(nums); INDArray create = Nd4j.create(doubles, new int[] {1, nums.length}); return create; } else { float[] doubles = ArrayUtil.toFloats(nums); INDArray create = Nd4j.create(doubles, new int[] {1, nums.length}); return create; } }
public static INDArray toNDArray(long[] nums) { if (Nd4j.dataType() == DataBuffer.Type.DOUBLE) { double[] doubles = ArrayUtil.toDoubles(nums); INDArray create = Nd4j.create(doubles, new int[] {1, nums.length}); return create; } else { float[] doubles = ArrayUtil.toFloats(nums); INDArray create = Nd4j.create(doubles, new int[] {1, nums.length}); return create; } }
public static DataBuffer createBufferDetached(float[] data) { DataBuffer ret; if (dataType() == DataBuffer.Type.FLOAT) ret = DATA_BUFFER_FACTORY_INSTANCE.createFloat(data); else if (dataType() == DataBuffer.Type.HALF) ret = DATA_BUFFER_FACTORY_INSTANCE.createHalf(data); else ret = DATA_BUFFER_FACTORY_INSTANCE.createDouble(ArrayUtil.toDoubles(data)); logCreationIfNecessary(ret); return ret; }
/** * Create a buffer based on the data opType * * @param data the data to create the buffer with * @return the created buffer */ public static DataBuffer createBuffer(float[] data, long offset) { DataBuffer ret; if (dataType() == DataBuffer.Type.FLOAT) ret = Nd4j.getMemoryManager().getCurrentWorkspace() == null ? DATA_BUFFER_FACTORY_INSTANCE.createFloat(offset, data) : DATA_BUFFER_FACTORY_INSTANCE.createFloat(offset, data, Nd4j.getMemoryManager().getCurrentWorkspace()); else if (dataType() == DataBuffer.Type.HALF) ret = Nd4j.getMemoryManager().getCurrentWorkspace() == null ? DATA_BUFFER_FACTORY_INSTANCE.createHalf(offset, data) : DATA_BUFFER_FACTORY_INSTANCE.createHalf(offset, data, Nd4j.getMemoryManager().getCurrentWorkspace()); else ret = Nd4j.getMemoryManager().getCurrentWorkspace() == null ? DATA_BUFFER_FACTORY_INSTANCE.createDouble(offset, ArrayUtil.toDoubles(data)) : DATA_BUFFER_FACTORY_INSTANCE.createDouble(offset, ArrayUtil.toDoubles(data), Nd4j.getMemoryManager().getCurrentWorkspace()); logCreationIfNecessary(ret); return ret; }
/** * Create a buffer based on the data opType * * @param data the data to create the buffer with * @return the created buffer */ public static DataBuffer createBuffer(float[] data) { DataBuffer ret; if (dataType() == DataBuffer.Type.FLOAT) ret = Nd4j.getMemoryManager().getCurrentWorkspace() == null ? DATA_BUFFER_FACTORY_INSTANCE.createFloat(data) : DATA_BUFFER_FACTORY_INSTANCE.createFloat(data, Nd4j.getMemoryManager().getCurrentWorkspace()); else if (dataType() == DataBuffer.Type.HALF) ret = Nd4j.getMemoryManager().getCurrentWorkspace() == null ? DATA_BUFFER_FACTORY_INSTANCE.createHalf(data): DATA_BUFFER_FACTORY_INSTANCE.createHalf(data, Nd4j.getMemoryManager().getCurrentWorkspace()); else ret = Nd4j.getMemoryManager().getCurrentWorkspace() == null ? DATA_BUFFER_FACTORY_INSTANCE.createDouble(ArrayUtil.toDoubles(data)) : DATA_BUFFER_FACTORY_INSTANCE.createDouble(ArrayUtil.toDoubles(data), Nd4j.getMemoryManager().getCurrentWorkspace()) ; logCreationIfNecessary(ret); return ret; }
@Override public void setData(float[] data) { setData(ArrayUtil.toDoubles(data)); }
@Override public double[] asDouble() { return ArrayUtil.toDoubles(asFloat()); }
@Override public void setData(int[] data) { setData(ArrayUtil.toDoubles(data)); }
@Override public void setData(float[] data) { setData(ArrayUtil.toDoubles(data)); }
/** * Array of evenly spaced values. * * @param begin the begin of the range * @param end the end of the range * @return the range vector */ @Override public INDArray arange(double begin, double end) { return Nd4j.create(ArrayUtil.toDoubles(ArrayUtil.range((int) begin, (int) end))); }
public static INDArray toNDArray(int[][] nums) { if (Nd4j.dataType() == DataBuffer.Type.DOUBLE) { double[] doubles = ArrayUtil.toDoubles(nums); INDArray create = Nd4j.create(doubles, new int[] {1, nums.length}); return create; } else { float[] doubles = ArrayUtil.toFloats(nums); INDArray create = Nd4j.create(doubles, new int[] {1, nums.length}); return create; } }
public static INDArray toNDArray(int[] nums) { if (Nd4j.dataType() == DataBuffer.Type.DOUBLE) { double[] doubles = ArrayUtil.toDoubles(nums); INDArray create = Nd4j.create(doubles, new int[] {1, nums.length}); return create; } else { float[] doubles = ArrayUtil.toFloats(nums); INDArray create = Nd4j.create(doubles, new int[] {1, nums.length}); return create; } }
public static DataBuffer createBufferDetached(float[] data) { DataBuffer ret; if (dataType() == DataBuffer.Type.FLOAT) ret = DATA_BUFFER_FACTORY_INSTANCE.createFloat(data); else if (dataType() == DataBuffer.Type.HALF) ret = DATA_BUFFER_FACTORY_INSTANCE.createHalf(data); else ret = DATA_BUFFER_FACTORY_INSTANCE.createDouble(ArrayUtil.toDoubles(data)); logCreationIfNecessary(ret); return ret; }