Class IntervalIndex

  • All Implemented Interfaces:
    INDArrayIndex
    Direct Known Subclasses:
    NDArrayIndexAll

    public class IntervalIndex
    extends Object
    implements INDArrayIndex
    And indexing representing an interval. An interval over a given dimension will create a view similar to a PointIndex starting from a position and ending at one. Negative indices can also be specified allowing for dynamic resolution of dimensions/coordinates at runtime.
    Author:
    Adam Gibson
    • Field Detail

      • begin

        protected long begin
      • end

        protected long end
      • inclusive

        protected boolean inclusive
      • stride

        protected long stride
      • index

        protected long index
      • length

        protected long length
      • initialized

        protected boolean initialized
    • Constructor Detail

      • IntervalIndex

        public IntervalIndex​(boolean inclusive,
                             long stride)
        Parameters:
        inclusive - whether to include the last number
        stride - the stride for the interval
    • Method Detail

      • end

        public long end()
        Description copied from interface: INDArrayIndex
        The ending for this index
        Specified by:
        end in interface INDArrayIndex
        Returns:
      • offset

        public long offset()
        Description copied from interface: INDArrayIndex
        The start of this index
        Specified by:
        offset in interface INDArrayIndex
        Returns:
      • length

        public long length()
        Description copied from interface: INDArrayIndex
        The total length of this index (end - start)
        Specified by:
        length in interface INDArrayIndex
        Returns:
      • stride

        public long stride()
        Description copied from interface: INDArrayIndex
        The stride for the index (most of the time will be 1)
        Specified by:
        stride in interface INDArrayIndex
        Returns:
      • isInterval

        public boolean isInterval()
        Description copied from interface: INDArrayIndex
        Returns true if the index is an interval
        Specified by:
        isInterval in interface INDArrayIndex
        Returns:
      • init

        public void init​(INDArray arr,
                         long begin,
                         int dimension)
        Description copied from interface: INDArrayIndex
        Init the index wrt the dimension and the given nd array
        Specified by:
        init in interface INDArrayIndex
        Parameters:
        arr - the array to initialize on
        begin - the beginning index
        dimension - the dimension to initialize on
      • init

        public void init​(INDArray arr,
                         int dimension)
        Description copied from interface: INDArrayIndex
        Init the index wrt the dimension and the given nd array
        Specified by:
        init in interface INDArrayIndex
        Parameters:
        arr - the array to initialize on
        dimension - the dimension to initialize on
      • init

        public void init​(long begin,
                         long end,
                         long max)
        Specified by:
        init in interface INDArrayIndex
      • init

        public void init​(long begin,
                         long end)
        Description copied from interface: INDArrayIndex
        Initialize based on the specified begin and end
        Specified by:
        init in interface INDArrayIndex
      • initialized

        public boolean initialized()
        Description copied from interface: INDArrayIndex
        Returns true if this index has been initialized. Sometimes indices may define certain constraints such as negative indices that may not be resolved until use. INDArray.get(INDArrayIndex...) will check for when an index is initialized and if not initialize it upon use.
        Specified by:
        initialized in interface INDArrayIndex
        Returns:
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object