类 Array

  • 直接已知子类:
    ArrayBoolean, ArrayByte, ArrayChar, ArrayComplex, ArrayDate, ArrayDouble, ArrayFloat, ArrayInt, ArrayLong, ArrayObject, ArrayRagged, ArrayScalar, ArrayShort, ArrayString, ArrayStructure, ArrayStructureBak

    public abstract class Array
    extends java.lang.Object
    Superclass for implementations of multidimensional arrays. An Array has a classType which gives the Class of its elements, and a shape which describes the number of elements in each index. The rank is the number of indices. A scalar Array has rank = 0. An Array may have arbitrary rank. The Array size is the total number of elements, which must be less than 2^31 (about 2x10^9).

    Actual data storage is done with Java 1D arrays and stride index calculations. This makes our Arrays rectangular, i.e. no "ragged arrays" where different elements can have different lengths as in Java multidimensional arrays, which are arrays of arrays.

    Each primitive Java type (boolean, byte, char, short, int, long, float, double) has a corresponding concrete implementation, e.g. ArrayBoolean, ArrayDouble. Reference types are all implemented using the ArrayObject class, with the exceptions of the reference types that correspond to the primitive types, eg Double.class is mapped to double.class.

    For efficiency, each Array type implementation has concrete subclasses for ranks 0-7, eg ArrayDouble.D0 is a double array of rank 0, ArrayDouble.D1 is a double array of rank 1, etc. These type and rank specific classes are convenient to work with when you know the type and rank of the Array. Ranks greater than 7 are handled by the type-specific superclass e.g. ArrayDouble. The Array class itself is used for fully general handling of any type and rank array. Use the Array.factory() methods to create Arrays in a general way.

    The stride index calculations allow logical views to be efficiently implemented, eg subset, transpose, slice, etc. These views use the same data storage as the original Array they are derived from. The index stride calculations are equally efficient for any composition of logical views.

    The type, shape and backing storage of an Array are immutable. The data itself is read or written using an Index or an IndexIterator, which stores any needed state information for efficient traversal. This makes use of Arrays thread-safe (as long as you dont share the Index or IndexIterator) except for the possibility of non-atomic read/write on long/doubles. If this is the case, you should probably synchronize your calls. Presumably 64-bit CPUs will make those operations atomic also.

    作者:
    caron
    另请参阅:
    Index, IndexIterator
    • 构造器概要

      构造器 
      限定符 构造器 说明
      protected Array​(DataType dataType, int[] shape)  
      protected Array​(DataType dataType, Index index)  
    • 方法概要

      所有方法 静态方法 实例方法 抽象方法 具体方法 已过时的方法 
      修饰符和类型 方法 说明
      static void arraycopy​(Array arraySrc, int srcPos, Array arrayDst, int dstPos, int len)
      Cover for System.arraycopy().
      Array copy()
      Create a copy of this Array, copying the data so that physical order is the same as logical order
      protected abstract void copyFrom1DJavaArray​(IndexIterator iter, java.lang.Object javaArray)  
      Array copyIfView()
      Create a copy of this Array if it's physical order is not the same as logical order
      java.lang.Object copyTo1DJavaArray()
      Copy this array to a 1D Java primitive array of type getElementType(), with the physical order of the result the same as logical order.
      protected abstract void copyTo1DJavaArray​(IndexIterator iter, java.lang.Object javaArray)  
      java.lang.Object copyToNDJavaArray()
      Copy this array to a n-Dimensional Java primitive array of type getElementType() and rank getRank().
      protected abstract Array createView​(Index index)
      create new Array with given Index and the same backing store
      static Array factory​(java.lang.Class classType, int[] shape)
      Generate new Array with given type and shape and zeroed storage.
      static Array factory​(java.lang.Class classType, int[] shape, java.lang.Object storage)
      Generate new Array with given type, shape, storage.
      static Array factory​(java.lang.Class classType, Index indexCalc, java.lang.Object storage)
      Create new array with given type, index, storage.
      static Array factory​(java.lang.Object javaArray)
      Generate a new Array from a java array of any rank and type.
      static Array factory​(DataType dataType, int[] shape)
      Generate new Array with given type and shape and zeroed storage.
      static Array factory​(DataType dataType, int[] shape, java.lang.Object storage)
      /** Generate new Array with given type, shape, storage.
      static Array factory​(DataType dtype, int[] shape, java.nio.ByteBuffer bb)
      Create an Array from a ByteBuffer
      static Array factory​(DataType dtype, Index index, java.lang.Object storage)  
      static Array factoryConstant​(java.lang.Class classType, int[] shape, java.lang.Object storage)
      Generate new Array with given type and shape and an Index that always return 0.
      Array flip​(int dim)
      Create a new Array using same backing store as this Array, by flipping the index so that it runs from shape[index]-1 to 0.
      java.lang.Object get1DJavaArray​(java.lang.Class wantType)
      This gets the equivalent java array of the wanted type, in correct order.
      abstract boolean getBoolean​(int elem)  
      abstract boolean getBoolean​(Index ima)
      Get the array element at the current element of ima, as a boolean.
      abstract byte getByte​(int elem)  
      abstract byte getByte​(Index ima)
      Get the array element at the current element of ima, as a byte.
      abstract char getChar​(int elem)  
      abstract char getChar​(Index ima)
      Get the array element at the current element of ima, as a char.
      abstract Complex getComplex​(int elem)  
      abstract Complex getComplex​(Index ima)
      Get the array element at the current element of ima, as a complex.
      java.nio.ByteBuffer getDataAsByteBuffer()
      This gets the data as a ByteBuffer, in correct order.
      java.nio.ByteBuffer getDataAsByteBuffer​(int capacity, java.nio.ByteOrder order)  
      java.nio.ByteBuffer getDataAsByteBuffer​(java.nio.ByteOrder order)  
      DataType getDataType()
      Return the computed datatype for this array
      abstract java.time.LocalDateTime getDate​(int elem)  
      abstract java.time.LocalDateTime getDate​(Index ima)
      Get the array element at the current element of ima, as a LocalDateTime.
      abstract double getDouble​(int elem)  
      abstract double getDouble​(Index ima)
      Get the array element at the current element of ima, as a double.
      abstract java.lang.Class getElementType()
      Get the element class type of this Array
      abstract float getFloat​(int elem)  
      abstract float getFloat​(Index ima)
      Get the array element at the current element of ima, as a float.
      Index getIndex()
      Get an Index object used for indexed access of this Array.
      IndexIterator getIndexIterator()
      Get an index iterator for traversing the array in canonical order.
      IndexIterator getIndexIteratorFast()
      已过时。
      use getIndexIterator
      Index getIndexPrivate()
      Get an Index object used for indexed access of this Array.
      abstract int getInt​(int elem)  
      abstract int getInt​(Index ima)
      Get the array element at the current element of ima, as a int.
      abstract long getLong​(int elem)  
      abstract long getLong​(Index ima)
      Get the array element at the current element of ima, as a long.
      abstract java.lang.Object getObject​(int elem)  
      abstract java.lang.Object getObject​(Index ima)
      Get the array element at index as an Object.
      IndexIterator getRangeIterator​(java.util.List<Range> ranges)
      Get an index iterator for traversing a section of the array in canonical order.
      int getRank()
      Get the number of dimensions of the array.
      int[] getShape()
      Get the shape: length of array in each dimension.
      abstract short getShort​(int elem)  
      abstract short getShort​(Index ima)
      Get the array element at the current element of ima, as a short.
      long getSize()
      Get the total number of elements in the array.
      long getSizeBytes()
      Get the total number of bytes in the array.
      abstract java.lang.Object getStorage()
      Get underlying primitive array storage.
      abstract java.lang.String getString​(int elem)  
      abstract java.lang.String getString​(Index ima)
      Get the array element at the current element of ima, as a string.
      boolean hasNext()
      Check if more elements in the local iterator.
      boolean isConstant()
      If this is a constant array
      boolean isUnsigned()
      Find whether the underlying data should be interpreted as unsigned.
      boolean isView()
      Get if the this Array is view - the physical order is not same as logical order
      static Array makeArray​(DataType dtype, boolean isUnsigned, java.util.List<java.lang.String> stringValues)
      Make an 1D array from a list of strings.
      static Array makeArray​(DataType dtype, int npts, double start, double incr)
      Make a 1D array from a start and inccr.
      static Array makeArray​(DataType dtype, java.lang.String[] stringValues)
      Make an 1D array from an array of strings.
      static Array makeArray​(DataType dtype, java.util.List<java.lang.String> stringValues)
      Make an 1D array from a list of strings.
      static Array makeArrayRankPlusOne​(Array org)
      Add extra dimension with len = 1.
      java.lang.Object next()
      Return the next object in the local iterator.
      boolean nextBoolean()
      Return the next boolean in the local iterator.
      byte nextByte()
      Return the next byte in the local iterator.
      char nextChar()
      Return the next char in the local iterator.
      double nextDouble()
      Return the next double in the local iterator.
      float nextFloat()
      Return the next float in the local iterator.
      int nextInt()
      Return the next int in the local iterator.
      long nextLong()
      Return the next long in the local iterator.
      short nextShort()
      Return the next short in the local iterator.
      Array permute​(int[] dims)
      Create a new Array using same backing store as this Array, by permuting the indices.
      Array reduce()
      Create a new Array using same backing store as this Array, by eliminating any dimensions with length one.
      Array reduce​(int dim)
      Create a new Array using same backing store as this Array, by eliminating the specified dimension.
      void resetLocalIterator()
      Reset the local iterator.
      Array reshape​(int[] shape)
      Create a new Array by copying this Array to a new one with given shape
      Array reshapeNoCopy​(int[] shape)
      Reshape this array without copying data
      Array reshapeVLen​(int[] shape)
      Reshape this array - the new shape total size may be different.
      Array section​(int[] origin, int[] shape)
      Create a new Array as a subsection of this Array, with rank reduction.
      Array section​(int[] origin, int[] shape, int[] stride)
      Create a new Array as a subsection of this Array, with rank reduction.
      Array section​(java.util.List<Range> ranges)
      Create a new Array as a subsection of this Array, with rank reduction.
      Array sectionNoReduce​(int[] origin, int[] shape, int[] stride)
      Create a new Array as a subsection of this Array, without rank reduction.
      Array sectionNoReduce​(java.util.List<Range> ranges)
      Create a new Array as a subsection of this Array, without rank reduction.
      abstract void setBoolean​(int elem, boolean value)  
      abstract void setBoolean​(Index ima, boolean value)
      Set the array element at the current element of ima.
      abstract void setByte​(int elem, byte value)  
      abstract void setByte​(Index ima, byte value)
      Set the array element at the current element of ima.
      abstract void setChar​(int elem, char value)  
      abstract void setChar​(Index ima, char value)
      Set the array element at the current element of ima.
      abstract void setComplex​(int elem, Complex value)  
      abstract void setComplex​(Index ima, Complex value)
      Set the array element at the current element of ima.
      abstract void setDate​(int elem, java.time.LocalDateTime value)  
      abstract void setDate​(Index ima, java.time.LocalDateTime value)
      Set the array element at the current element of ima.
      abstract void setDouble​(int elem, double val)  
      abstract void setDouble​(Index ima, double value)
      Set the array element at the current element of ima.
      abstract void setFloat​(int elem, float val)  
      abstract void setFloat​(Index ima, float value)
      Set the array element at the current element of ima.
      abstract void setInt​(int elem, int value)  
      abstract void setInt​(Index ima, int value)
      Set the array element at the current element of ima.
      abstract void setLong​(int elem, long value)  
      abstract void setLong​(Index ima, long value)
      Set the array element at the current element of ima.
      abstract void setObject​(int elem, java.lang.Object value)  
      abstract void setObject​(Index ima, java.lang.Object value)
      Set the array element at index to the specified value. the value must be passed wrapped in the appropriate Object (eg Double for double)
      abstract void setShort​(int elem, short value)  
      abstract void setShort​(Index ima, short value)
      Set the array element at the current element of ima.
      abstract void setString​(int elem, java.lang.String value)  
      abstract void setString​(Index ima, java.lang.String value)
      Set the array element at the current element of ima.
      java.lang.String shapeToString()
      Create a string representation of the shape of this Array.
      Array slice​(int dim, int value)
      Create a new Array using same backing store as this Array, by fixing the specified dimension at the specified index value.
      java.lang.String toString()  
      Array transpose​(int dim1, int dim2)
      Create a new Array using same backing store as this Array, by transposing two of the indices.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 字段详细资料

      • indexCalc

        protected final Index indexCalc
      • rank

        protected final int rank
    • 构造器详细资料

      • Array

        protected Array​(DataType dataType,
                        int[] shape)
    • 方法详细资料

      • factory

        public static Array factory​(DataType dataType,
                                    int[] shape)
        Generate new Array with given type and shape and zeroed storage.
        参数:
        dataType - instance of DataType.
        shape - shape of the array.
        返回:
        new Array or Array.D if 0 <= rank <= 7.
      • factory

        public static Array factory​(java.lang.Class classType,
                                    int[] shape)
        Generate new Array with given type and shape and zeroed storage.
        参数:
        classType - element Class type, eg double.class.
        shape - shape of the array.
        返回:
        new Array or Array.D if 0 <= rank <= 7.
      • factory

        public static Array factory​(DataType dataType,
                                    int[] shape,
                                    java.lang.Object storage)
        /** Generate new Array with given type, shape, storage.
        参数:
        dataType - DataType, eg DataType.DOUBLE.
        shape - shape of the array.
        storage - primitive array of correct type
        返回:
        new Array or Array.D if 0 <= rank <= 7.
      • factory

        public static Array factory​(DataType dtype,
                                    Index index,
                                    java.lang.Object storage)
      • factory

        public static Array factory​(java.lang.Class classType,
                                    int[] shape,
                                    java.lang.Object storage)
        Generate new Array with given type, shape, storage. This should be package private, but is exposed for efficiency. Normally use factory( Class classType, int [] shape) instead. storage must be 1D array of type classType. storage.length must equal product of shapes storage data needs to be in canonical order
        参数:
        classType - element class type, eg double.class. Corresponding Object types like Double.class are mapped to double.class. Any reference types use ArrayObject.
        shape - array shape
        storage - 1D java array of type classType, except object types like Double.class are mapped to their corresponding primitive type, eg double.class.
        返回:
        Array of given type, shape and storage
        抛出:
        java.lang.IllegalArgumentException - storage.length != product of shapes
        java.lang.ClassCastException - wrong storage type
      • factory

        public static Array factory​(java.lang.Class classType,
                                    Index indexCalc,
                                    java.lang.Object storage)
        Create new array with given type, index, storage.
        参数:
        classType - element class type, eg double.class.
        indexCalc - array index.
        storage - 1D java array of type classType.
        返回:
        Array of give type, index and storage.
      • factoryConstant

        public static Array factoryConstant​(java.lang.Class classType,
                                            int[] shape,
                                            java.lang.Object storage)
        Generate new Array with given type and shape and an Index that always return 0.
        参数:
        classType - element Class type, eg double.class.
        shape - shape of the array.
        storage - primitive array of correct type of length 1
        返回:
        new Array or Array.D if 0 <= rank <= 7.
      • factory

        public static Array factory​(java.lang.Object javaArray)
        Generate a new Array from a java array of any rank and type. This makes a COPY of the data values of javaArray. LOOK: not sure this works for reference types.
        参数:
        javaArray - scalar Object or a java array of any rank and type
        返回:
        Array of the appropriate rank and type, with the data copied from javaArray.
      • arraycopy

        public static void arraycopy​(Array arraySrc,
                                     int srcPos,
                                     Array arrayDst,
                                     int dstPos,
                                     int len)
        Cover for System.arraycopy(). Works with the underlying data arrays. ArraySrc and ArrayDst must be the same primitive type. Exposed for efficiency; use at your own risk.
        参数:
        arraySrc - copy from here : if not in canonical order, an extra copy will be done
        srcPos - starting at
        arrayDst - copy to here : must be in canonical order
        dstPos - starting at
        len - number of elements to copy
      • makeArray

        public static Array makeArray​(DataType dtype,
                                      int npts,
                                      double start,
                                      double incr)
        Make a 1D array from a start and inccr.
        参数:
        dtype - data type of result. must be convertible to double.
        npts - number of points
        start - starting values
        incr - increment
        返回:
        1D array
      • makeArray

        public static Array makeArray​(DataType dtype,
                                      boolean isUnsigned,
                                      java.util.List<java.lang.String> stringValues)
                               throws java.lang.NumberFormatException
        Make an 1D array from a list of strings.
        参数:
        dtype - data type of the array.
        isUnsigned - may be unsigned (byte, short, int, long)
        stringValues - list of strings.
        返回:
        resulting 1D array.
        抛出:
        java.lang.NumberFormatException - if string values not parseable to specified data type
      • makeArray

        public static Array makeArray​(DataType dtype,
                                      java.util.List<java.lang.String> stringValues)
                               throws java.lang.NumberFormatException
        Make an 1D array from a list of strings.
        参数:
        dtype - data type of the array. Assumed unsigned
        stringValues - list of strings.
        返回:
        resulting 1D array.
        抛出:
        java.lang.NumberFormatException - if string values not parseable to specified data type
      • makeArray

        public static Array makeArray​(DataType dtype,
                                      java.lang.String[] stringValues)
                               throws java.lang.NumberFormatException
        Make an 1D array from an array of strings.
        参数:
        dtype - data type of the array. Assumed unsigned
        stringValues - list of strings.
        返回:
        resulting 1D array.
        抛出:
        java.lang.NumberFormatException - if string values not parseable to specified data type
      • makeArrayRankPlusOne

        public static Array makeArrayRankPlusOne​(Array org)
        Add extra dimension with len = 1.
        参数:
        org - original array
        返回:
        rank1 array of rank + 1
      • getDataType

        public DataType getDataType()
        Return the computed datatype for this array
        返回:
        the data type
      • getIndex

        public Index getIndex()
        Get an Index object used for indexed access of this Array.
        返回:
        an Index for this Array
        另请参阅:
        Index
      • getIndexPrivate

        public Index getIndexPrivate()
        Get an Index object used for indexed access of this Array.
        返回:
        an Index for this Array
      • getIndexIterator

        public IndexIterator getIndexIterator()
        Get an index iterator for traversing the array in canonical order.
        返回:
        an IndexIterator for this Array
        另请参阅:
        IndexIterator
      • getRank

        public int getRank()
        Get the number of dimensions of the array.
        返回:
        number of dimensions of the array
      • getShape

        public int[] getShape()
        Get the shape: length of array in each dimension.
        返回:
        array whose length is the rank of this Array and whose elements represent the length of each of its indices.
      • getSize

        public long getSize()
        Get the total number of elements in the array.
        返回:
        total number of elements in the array
      • getSizeBytes

        public long getSizeBytes()
        Get the total number of bytes in the array.
        返回:
        total number of bytes in the array
      • getRangeIterator

        public IndexIterator getRangeIterator​(java.util.List<Range> ranges)
                                       throws InvalidRangeException
        Get an index iterator for traversing a section of the array in canonical order. This is equivalent to Array.section(ranges).getIterator();
        参数:
        ranges - list of Ranges that specify the array subset. Must be same rank as original Array. A particular Range: 1) may be a subset, or 2) may be null, meaning use entire Range.
        返回:
        an IndexIterator over the named range.
        抛出:
        InvalidRangeException - if ranges is invalid
      • getIndexIteratorFast

        public IndexIterator getIndexIteratorFast()
        已过时。
        use getIndexIterator
        Get an index iterator for traversing the array in arbitrary order. Use this if you dont care what order the elements are returned, eg if you are summing an Array. To get an iteration in order, use getIndexIterator(), which returns a fast iterator if possible.
        返回:
        an IndexIterator for traversing the array in arbitrary order.
      • getElementType

        public abstract java.lang.Class getElementType()
        Get the element class type of this Array
        返回:
        the class of the element
      • getStorage

        public abstract java.lang.Object getStorage()
        Get underlying primitive array storage. Exposed for efficiency, use at your own risk.
        返回:
        underlying primitive array storage
      • copyFrom1DJavaArray

        protected abstract void copyFrom1DJavaArray​(IndexIterator iter,
                                                    java.lang.Object javaArray)
      • copyTo1DJavaArray

        protected abstract void copyTo1DJavaArray​(IndexIterator iter,
                                                  java.lang.Object javaArray)
      • createView

        protected abstract Array createView​(Index index)
        create new Array with given Index and the same backing store
        参数:
        index - use this Index
        返回:
        a view of the Array using the given Index
      • section

        public Array section​(java.util.List<Range> ranges)
                      throws InvalidRangeException
        Create a new Array as a subsection of this Array, with rank reduction. No data is moved, so the new Array references the same backing store as the original.
        参数:
        ranges - list of Ranges that specify the array subset. Must be same rank as original Array. A particular Range: 1) may be a subset, or 2) may be null, meaning use entire Range. If Range[dim].length == 1, then the rank of the resulting Array is reduced at that dimension.
        返回:
        the new Array
        抛出:
        InvalidRangeException - if ranges is invalid
      • section

        public Array section​(int[] origin,
                             int[] shape)
                      throws InvalidRangeException
        Create a new Array as a subsection of this Array, with rank reduction. No data is moved, so the new Array references the same backing store as the original.

        参数:
        origin - int array specifying the starting index. Must be same rank as original Array.
        shape - int array specifying the extents in each dimension. This becomes the shape of the returned Array. Must be same rank as original Array. If shape[dim] == 1, then the rank of the resulting Array is reduced at that dimension.
        返回:
        the new Array
        抛出:
        InvalidRangeException - if ranges is invalid
      • section

        public Array section​(int[] origin,
                             int[] shape,
                             int[] stride)
                      throws InvalidRangeException
        Create a new Array as a subsection of this Array, with rank reduction. No data is moved, so the new Array references the same backing store as the original.

        参数:
        origin - int array specifying the starting index. Must be same rank as original Array.
        shape - int array specifying the extents in each dimension. This becomes the shape of the returned Array. Must be same rank as original Array. If shape[dim] == 1, then the rank of the resulting Array is reduced at that dimension.
        stride - int array specifying the strides in each dimension. If null, assume all ones.
        返回:
        the new Array
        抛出:
        InvalidRangeException - if ranges is invalid
      • sectionNoReduce

        public Array sectionNoReduce​(java.util.List<Range> ranges)
                              throws InvalidRangeException
        Create a new Array as a subsection of this Array, without rank reduction. No data is moved, so the new Array references the same backing store as the original. Vlen is transferred over unchanged.
        参数:
        ranges - list of Ranges that specify the array subset. Must be same rank as original Array. A particular Range: 1) may be a subset, or 2) may be null, meaning use entire Range.
        返回:
        the new Array
        抛出:
        InvalidRangeException - if ranges is invalid
      • sectionNoReduce

        public Array sectionNoReduce​(int[] origin,
                                     int[] shape,
                                     int[] stride)
                              throws InvalidRangeException
        Create a new Array as a subsection of this Array, without rank reduction. No data is moved, so the new Array references the same backing store as the original.
        参数:
        origin - int array specifying the starting index. Must be same rank as original Array.
        shape - int array specifying the extents in each dimension. This becomes the shape of the returned Array. Must be same rank as original Array.
        stride - int array specifying the strides in each dimension. If null, assume all ones.
        返回:
        the new Array
        抛出:
        InvalidRangeException - if ranges is invalid
      • slice

        public Array slice​(int dim,
                           int value)
        Create a new Array using same backing store as this Array, by fixing the specified dimension at the specified index value. This reduces rank by 1.
        参数:
        dim - which dimension to fix
        value - at what index value
        返回:
        a new Array
      • copy

        public Array copy()
        Create a copy of this Array, copying the data so that physical order is the same as logical order
        返回:
        the new Array
      • isView

        public boolean isView()
        Get if the this Array is view - the physical order is not same as logical order
        返回:
        Is view or not
      • copyIfView

        public Array copyIfView()
        Create a copy of this Array if it's physical order is not the same as logical order
        返回:
        the new Array
      • get1DJavaArray

        public java.lang.Object get1DJavaArray​(java.lang.Class wantType)
        This gets the equivalent java array of the wanted type, in correct order. It avoids copying if possible.
        参数:
        wantType - returned object will be an array of this type. This must be convertible to it.
        返回:
        java array of type want
      • getDataAsByteBuffer

        public java.nio.ByteBuffer getDataAsByteBuffer()
        This gets the data as a ByteBuffer, in correct order. It avoids copying if possible. Only for numeric types (byte, short, int, long, double, float)
        返回:
        equivilent data in a ByteBuffer
      • getDataAsByteBuffer

        public java.nio.ByteBuffer getDataAsByteBuffer​(java.nio.ByteOrder order)
      • getDataAsByteBuffer

        public java.nio.ByteBuffer getDataAsByteBuffer​(int capacity,
                                                       java.nio.ByteOrder order)
      • factory

        public static Array factory​(DataType dtype,
                                    int[] shape,
                                    java.nio.ByteBuffer bb)
        Create an Array from a ByteBuffer
        参数:
        dtype - type of data
        shape - shape of data; if null, then use int[]{bb.limit()}
        bb - data is in here
        返回:
        equivilent Array
      • copyTo1DJavaArray

        public java.lang.Object copyTo1DJavaArray()
        Copy this array to a 1D Java primitive array of type getElementType(), with the physical order of the result the same as logical order.
        返回:
        a Java 1D array of type getElementType().
      • copyToNDJavaArray

        public java.lang.Object copyToNDJavaArray()
        Copy this array to a n-Dimensional Java primitive array of type getElementType() and rank getRank(). Makes a copy of the data.
        返回:
        a Java ND array of type getElementType().
      • flip

        public Array flip​(int dim)
        Create a new Array using same backing store as this Array, by flipping the index so that it runs from shape[index]-1 to 0.
        参数:
        dim - dimension to flip
        返回:
        the new Array
      • transpose

        public Array transpose​(int dim1,
                               int dim2)
        Create a new Array using same backing store as this Array, by transposing two of the indices.
        参数:
        dim1 - transpose these two indices
        dim2 - transpose these two indices
        返回:
        the new Array
      • permute

        public Array permute​(int[] dims)
        Create a new Array using same backing store as this Array, by permuting the indices.
        参数:
        dims - the old index dims[k] becomes the new kth index.
        返回:
        the new Array
      • reshape

        public Array reshape​(int[] shape)
        Create a new Array by copying this Array to a new one with given shape
        参数:
        shape - the new shape
        返回:
        the new Array
        抛出:
        java.lang.IllegalArgumentException - new shape is not conformable
      • reshapeNoCopy

        public Array reshapeNoCopy​(int[] shape)
        Reshape this array without copying data
        参数:
        shape - the new shape
        返回:
        the new Array, using same backing object
        抛出:
        java.lang.IllegalArgumentException - new shape is not conformable
      • reshapeVLen

        public Array reshapeVLen​(int[] shape)
        Reshape this array - the new shape total size may be different.
        参数:
        shape - the new shape
        返回:
        the new Array
      • reduce

        public Array reduce()
        Create a new Array using same backing store as this Array, by eliminating any dimensions with length one.
        返回:
        the new Array, or the same array if no reduction was done
      • reduce

        public Array reduce​(int dim)
        Create a new Array using same backing store as this Array, by eliminating the specified dimension.
        参数:
        dim - dimension to eliminate: must be of length one, else IllegalArgumentException
        返回:
        the new Array
      • isUnsigned

        public boolean isUnsigned()
        Find whether the underlying data should be interpreted as unsigned. Only affects byte, short, and int. When true, conversions to wider types are handled correctly.
        返回:
        true if the data is unsigned integer type.
      • isConstant

        public boolean isConstant()
        If this is a constant array
        返回:
        If this is a constant array
      • getDouble

        public abstract double getDouble​(Index ima)
        Get the array element at the current element of ima, as a double.
        参数:
        ima - Index with current element set
        返回:
        value at index cast to double if necessary.
      • setDouble

        public abstract void setDouble​(Index ima,
                                       double value)
        Set the array element at the current element of ima.
        参数:
        ima - Index with current element set
        value - the new value; cast to underlying data type if necessary.
      • getFloat

        public abstract float getFloat​(Index ima)
        Get the array element at the current element of ima, as a float.
        参数:
        ima - Index with current element set
        返回:
        value at index cast to float if necessary.
      • setFloat

        public abstract void setFloat​(Index ima,
                                      float value)
        Set the array element at the current element of ima.
        参数:
        ima - Index with current element set
        value - the new value; cast to underlying data type if necessary.
      • getLong

        public abstract long getLong​(Index ima)
        Get the array element at the current element of ima, as a long.
        参数:
        ima - Index with current element set
        返回:
        value at index cast to long if necessary.
      • setLong

        public abstract void setLong​(Index ima,
                                     long value)
        Set the array element at the current element of ima.
        参数:
        ima - Index with current element set
        value - the new value; cast to underlying data type if necessary.
      • getInt

        public abstract int getInt​(Index ima)
        Get the array element at the current element of ima, as a int.
        参数:
        ima - Index with current element set
        返回:
        value at index cast to int if necessary.
      • setInt

        public abstract void setInt​(Index ima,
                                    int value)
        Set the array element at the current element of ima.
        参数:
        ima - Index with current element set
        value - the new value; cast to underlying data type if necessary.
      • getShort

        public abstract short getShort​(Index ima)
        Get the array element at the current element of ima, as a short.
        参数:
        ima - Index with current element set
        返回:
        value at index cast to short if necessary.
      • setShort

        public abstract void setShort​(Index ima,
                                      short value)
        Set the array element at the current element of ima.
        参数:
        ima - Index with current element set
        value - the new value; cast to underlying data type if necessary.
      • getByte

        public abstract byte getByte​(Index ima)
        Get the array element at the current element of ima, as a byte.
        参数:
        ima - Index with current element set
        返回:
        value at index cast to float if necessary.
      • setByte

        public abstract void setByte​(Index ima,
                                     byte value)
        Set the array element at the current element of ima.
        参数:
        ima - Index with current element set
        value - the new value; cast to underlying data type if necessary.
      • getChar

        public abstract char getChar​(Index ima)
        Get the array element at the current element of ima, as a char.
        参数:
        ima - Index with current element set
        返回:
        value at index cast to char if necessary.
      • setChar

        public abstract void setChar​(Index ima,
                                     char value)
        Set the array element at the current element of ima.
        参数:
        ima - Index with current element set
        value - the new value; cast to underlying data type if necessary.
      • getBoolean

        public abstract boolean getBoolean​(Index ima)
        Get the array element at the current element of ima, as a boolean.
        参数:
        ima - Index with current element set
        返回:
        value at index cast to boolean if necessary.
        抛出:
        ForbiddenConversionException - if underlying array not boolean
      • setBoolean

        public abstract void setBoolean​(Index ima,
                                        boolean value)
        Set the array element at the current element of ima.
        参数:
        ima - Index with current element set
        value - the new value; cast to underlying data type if necessary.
        抛出:
        ForbiddenConversionException - if underlying array not boolean
      • getString

        public abstract java.lang.String getString​(Index ima)
        Get the array element at the current element of ima, as a string.
        参数:
        ima - Index with current element set
        返回:
        value at index cast to string if necessary.
        抛出:
        ForbiddenConversionException - if underlying array not string
      • setString

        public abstract void setString​(Index ima,
                                       java.lang.String value)
        Set the array element at the current element of ima.
        参数:
        ima - Index with current element set
        value - the new value; cast to underlying data type if necessary.
        抛出:
        ForbiddenConversionException - if underlying array not string
      • getComplex

        public abstract Complex getComplex​(Index ima)
        Get the array element at the current element of ima, as a complex.
        参数:
        ima - Index with current element set
        返回:
        value at index cast to boolean if necessary.
        抛出:
        ForbiddenConversionException - if underlying array not complex
      • setComplex

        public abstract void setComplex​(Index ima,
                                        Complex value)
        Set the array element at the current element of ima.
        参数:
        ima - Index with current element set
        value - the new value; cast to underlying data type if necessary.
        抛出:
        ForbiddenConversionException - if underlying array not complex
      • getDate

        public abstract java.time.LocalDateTime getDate​(Index ima)
        Get the array element at the current element of ima, as a LocalDateTime.
        参数:
        ima - Index with current element set
        返回:
        value at index cast to boolean if necessary.
        抛出:
        ForbiddenConversionException - if underlying array not LocalDateTime
      • setDate

        public abstract void setDate​(Index ima,
                                     java.time.LocalDateTime value)
        Set the array element at the current element of ima.
        参数:
        ima - Index with current element set
        value - the new value; cast to underlying data type if necessary.
        抛出:
        ForbiddenConversionException - if underlying array not LocalDateTime
      • getObject

        public abstract java.lang.Object getObject​(Index ima)
        Get the array element at index as an Object. The returned value is wrapped in an object, eg Double for double
        参数:
        ima - element Index
        返回:
        Object value at index
        抛出:
        java.lang.ArrayIndexOutOfBoundsException - if index incorrect rank or out of bounds
      • setObject

        public abstract void setObject​(Index ima,
                                       java.lang.Object value)
        Set the array element at index to the specified value. the value must be passed wrapped in the appropriate Object (eg Double for double)
        参数:
        ima - Index with current element set
        value - the new value.
        抛出:
        java.lang.ArrayIndexOutOfBoundsException - if index incorrect rank or out of bounds
        java.lang.ClassCastException - if Object is incorrect type
      • getDouble

        public abstract double getDouble​(int elem)
      • setDouble

        public abstract void setDouble​(int elem,
                                       double val)
      • getFloat

        public abstract float getFloat​(int elem)
      • setFloat

        public abstract void setFloat​(int elem,
                                      float val)
      • getLong

        public abstract long getLong​(int elem)
      • setLong

        public abstract void setLong​(int elem,
                                     long value)
      • getInt

        public abstract int getInt​(int elem)
      • setInt

        public abstract void setInt​(int elem,
                                    int value)
      • getShort

        public abstract short getShort​(int elem)
      • setShort

        public abstract void setShort​(int elem,
                                      short value)
      • getByte

        public abstract byte getByte​(int elem)
      • setByte

        public abstract void setByte​(int elem,
                                     byte value)
      • getChar

        public abstract char getChar​(int elem)
      • setChar

        public abstract void setChar​(int elem,
                                     char value)
      • getBoolean

        public abstract boolean getBoolean​(int elem)
      • setBoolean

        public abstract void setBoolean​(int elem,
                                        boolean value)
      • getString

        public abstract java.lang.String getString​(int elem)
      • setString

        public abstract void setString​(int elem,
                                       java.lang.String value)
      • getComplex

        public abstract Complex getComplex​(int elem)
      • setComplex

        public abstract void setComplex​(int elem,
                                        Complex value)
      • getDate

        public abstract java.time.LocalDateTime getDate​(int elem)
      • setDate

        public abstract void setDate​(int elem,
                                     java.time.LocalDateTime value)
      • getObject

        public abstract java.lang.Object getObject​(int elem)
      • setObject

        public abstract void setObject​(int elem,
                                       java.lang.Object value)
      • toString

        public java.lang.String toString()
        覆盖:
        toString 在类中 java.lang.Object
      • shapeToString

        public java.lang.String shapeToString()
        Create a string representation of the shape of this Array.
        返回:
        string representation of the shape
      • hasNext

        public boolean hasNext()
        Check if more elements in the local iterator. Uses the local iterator, which is not thread-safe. Use getIndexIterator if you need thread-safety. You cannot call any of the array.nextXXX() methods without calling hasNext() first. If you are not sure of the state of the iterator, you must reset it before use. Example:
         arr.resetLocalIterator();
         while (arr.hasNext()) {
         double val = mdata.nextDouble();
         ..
         }
         <.pre>
        返回:
        true if there are more elements in the iteration
      • next

        public java.lang.Object next()
        Return the next object in the local iterator. Uses the local iterator, which is not thread-safe. Use getIndexIterator if you need thread-safety.
        返回:
        next element as an Object, same as IndexIterator.getObjectNext().
      • nextDouble

        public double nextDouble()
        Return the next double in the local iterator. Uses the local iterator, which is not thread-safe. Use getIndexIterator if you need thread-safety.
        返回:
        next element as a double, same as IndexIterator.getDoubleNext().
      • nextFloat

        public float nextFloat()
        Return the next float in the local iterator. Uses the local iterator, which is not thread-safe. Use getIndexIterator if you need thread-safety.
        返回:
        next element as a float, same as IndexIterator.getFloatNext().
      • nextByte

        public byte nextByte()
        Return the next byte in the local iterator. Uses the local iterator, which is not thread-safe. Use getIndexIterator if you need thread-safety.
        返回:
        next element as a byte, same as IndexIterator.getByteNext().
      • nextShort

        public short nextShort()
        Return the next short in the local iterator. Uses the local iterator, which is not thread-safe. Use getIndexIterator if you need thread-safety.
        返回:
        next element as a short, same as IndexIterator.getShortNext().
      • nextInt

        public int nextInt()
        Return the next int in the local iterator. Uses the local iterator, which is not thread-safe. Use getIndexIterator if you need thread-safety.
        返回:
        next element as a int, same as IndexIterator.getIntNext().
      • nextLong

        public long nextLong()
        Return the next long in the local iterator. Uses the local iterator, which is not thread-safe. Use getIndexIterator if you need thread-safety.
        返回:
        next element as a long, same as IndexIterator.getLongNext().
      • nextChar

        public char nextChar()
        Return the next char in the local iterator. Uses the local iterator, which is not thread-safe. Use getIndexIterator if you need thread-safety.
        返回:
        next element as a char, same as IndexIterator.getCharNext().
      • nextBoolean

        public boolean nextBoolean()
        Return the next boolean in the local iterator. Uses the local iterator, which is not thread-safe. Use getIndexIterator if you need thread-safety.
        返回:
        next element as a boolean, same as IndexIterator.getBooleanNext().
      • resetLocalIterator

        public void resetLocalIterator()
        Reset the local iterator. Uses the local iterator, which is not thread-safe. Use getIndexIterator if you need thread-safety.