/** * Returns the total number of elements in the ndarray * * @return the number of elements in the ndarray */ @Override public long length() { return Shape.length(javaShapeInformation); }
/** * Returns the total number of elements in the ndarray * * @return the number of elements in the ndarray */ @Override @Deprecated public long lengthLong() { return Shape.length(javaShapeInformation); }
/** * Returns whether the given shape is a vector * * @param shapeInfo the shapeinfo to test * @return whether the given shape is a vector */ public static boolean isVector(IntBuffer shapeInfo) { int rank = Shape.rank(shapeInfo); if (rank > 2 || rank < 1) return false; else { int len = Shape.length(shapeInfo); IntBuffer shape = Shape.shapeOf(shapeInfo); return shape.get(0) == len || shape.get(1) == len; } }
/** * Read in an ndarray from a data input stream * * @param dis the data input stream to read from * @return the ndarray * @throws IOException */ public static INDArray read(DataInputStream dis) throws IOException { DataBuffer shapeInformation = Nd4j.createBufferDetached(new long[1], DataBuffer.Type.LONG); shapeInformation.read(dis); int length = Shape.length(shapeInformation); DataBuffer data = CompressedDataBuffer.readUnknown(dis, length); return createArrayFromShapeBuffer(data, shapeInformation); }
/** * Returns whether the given shape is a vector * * @param shapeInfo the shapeinfo to test * @return whether the given shape is a vector */ public static boolean isVector(DataBuffer shapeInfo) { int rank = Shape.rank(shapeInfo); if (rank > 2 || rank < 1) return false; else { int len = Shape.length(shapeInfo); DataBuffer shape = Shape.shapeOf(shapeInfo); return shape.getInt(0) == len || shape.getInt(1) == len; } }
ByteBuffer slice = byteBuffer.slice(); DataBuffer buff = Nd4j.createBuffer(slice, type, Shape.length(shapeBuff));
/** * Returns the total number of elements in the ndarray * * @return the number of elements in the ndarray */ @Override public long lengthLong() { return Shape.length(shapeInformation); }
/** * Returns the total number of elements in the ndarray * * @return the number of elements in the ndarray */ @Override public int length() { return Shape.length(shapeInformation); }
/** * Returns whether the given shape is a vector * * @param shapeInfo the shapeinfo to test * @return whether the given shape is a vector */ public static boolean isVector(IntBuffer shapeInfo) { int rank = Shape.rank(shapeInfo); if (rank > 2 || rank < 1) return false; else { int len = Shape.length(shapeInfo); IntBuffer shape = Shape.shapeOf(shapeInfo); return shape.get(0) == len || shape.get(1) == len; } }
/** * Read in an ndarray from a data input stream * * @param dis the data input stream to read from * @return the ndarray * @throws IOException */ public static INDArray read(DataInputStream dis) throws IOException { DataBuffer shapeInformation = Nd4j.createBufferDetached(new int[1], DataBuffer.Type.INT); shapeInformation.read(dis); int length = Shape.length(shapeInformation); DataBuffer data = CompressedDataBuffer.readUnknown(dis, length); return createArrayFromShapeBuffer(data, shapeInformation); }
/** * Returns whether the given shape is a vector * * @param shapeInfo the shapeinfo to test * @return whether the given shape is a vector */ public static boolean isVector(DataBuffer shapeInfo) { int rank = Shape.rank(shapeInfo); if (rank > 2 || rank < 1) return false; else { int len = Shape.length(shapeInfo); DataBuffer shape = Shape.shapeOf(shapeInfo); return shape.getInt(0) == len || shape.getInt(1) == len; } }
ByteBuffer slice = byteBuffer.slice(); DataBuffer buff = Nd4j.createBuffer(slice, type, Shape.length(shapeBuff));
dataPointer.limit(dataBufferElementSize * Shape.length(shapeBuffer)); dataPointer.capacity(dataBufferElementSize * Shape.length(shapeBuffer)); data = Nd4j.createBuffer(dataPointer, DataBuffer.Type.FLOAT, Shape.length(shapeBuffer), FloatIndexer.create(new FloatPointer(dataPointer))); data = Nd4j.createBuffer(dataPointer, DataBuffer.Type.DOUBLE, Shape.length(shapeBuffer), DoubleIndexer.create(new DoublePointer(dataPointer)));