/** * Returns the shape(dimensions) of this array * * @return the shape of this matrix */ public long[] shape() { return Shape.shape(javaShapeInformation); }
/** * Get array shape from an int[] * @param buffer Buffer to get the shape from * @return Shape array */ public static int[] shape(int[] buffer) { int[] ret = new int[rank(buffer)]; for (int i = 0; i < ret.length; i++) ret[i] = buffer[1 + i]; return ret; }
/** * 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); }
@Override public char ordering() { return Shape.order(javaShapeInformation); }
/** * Returns whether the passed in shape is a matrix * * @param shapeInfo whether the passed in shape is a matrix * @return true if the shape is a matrix false otherwise */ public static boolean isMatrix(IntBuffer shapeInfo) { int rank = Shape.rank(shapeInfo); if (rank != 2) return false; return !isVector(shapeInfo); }
/** * Returns whether the passed in shape is a matrix * * @param shape whether the passed in shape is a matrix * @return true if the shape is a matrix false otherwise */ public static boolean isMatrix(int[] shape) { if (shape.length != 2) return false; return !isVector(shape); }
/** * Returns the shape information debugging * information * * @return the shape information debugging information */ @Override public String shapeInfoToString() { return Shape.shapeToString(this); }
/** * Returns the stride(indices along the linear index for which each slice is accessed) of this array * * @return the stride of this array */ @Override public long[] stride() { return Shape.stride(javaShapeInformation); }
/**Create a copy of the ndarray where the new offset is zero, and has specified order * @param arr the array to copy to offset 0 * @param order the order of the returned array * @return a copy of the array with elements set to zero offset, and with specified order */ public static INDArray toOffsetZeroCopy(INDArray arr, char order) { return toOffsetZeroCopyHelper(arr, order, false); }
@Override public int[] flags() { return Shape.flags(sparseInformation); }
@Override public int[] sparseOffsets() { return Shape.sparseOffsets(sparseInformation); }
@Override public long[] shape() { return Shape.shape(javaShapeInformation); }
/** * Returns whether the passed in shape is a matrix * * @param shapeInfo whether the passed in shape is a matrix * @return true if the shape is a matrix false otherwise */ public static boolean isMatrix(DataBuffer shapeInfo) { int rank = Shape.rank(shapeInfo); if (rank != 2) return false; return !isVector(shapeInfo); }
public static long[] stride(long[] buffer) { int rank = rank(buffer); long[] ret = new long[rank]; for (int i = 0; i < rank; i++) ret[i] = buffer[1 + rank + i]; return ret; }
public static boolean isMatrix(long[] shape) { if (shape.length != 2) return false; return !isVector(shape); }
public static long length(int[] buffer) { long ret = 1; int limit = Shape.rank(buffer) + 1; for (int i = 1; i < limit; i++) ret *= buffer[i]; return ret; }
public static long length(long[] buffer) { long ret = 1; int limit = Shape.rank(buffer) + 1; for (int i = 1; i < limit; i++) ret *= buffer[i]; return ret; }
public static long[] shape(long[] buffer) { long[] ret = new long[rank(buffer)]; for (int i = 0; i < ret.length; i++) ret[i] = buffer[1 + i]; return ret; }
public static int[] stride(int[] buffer) { int rank = rank(buffer); int[] ret = new int[rank]; for (int i = 0; i < rank; i++) ret[i] = buffer[1 + rank + i]; return ret; }
@Override public int rank() { return Shape.rank(shapeInformation); }