Class SpecifiedIndex

  • All Implemented Interfaces:
    INDArrayIndex

    public class SpecifiedIndex
    extends Object
    implements INDArrayIndex
    A SpecifiedIndex refers to a concrete set of points to be selectively pulled from a given dimension. Note that using this index will always trigger a copy. Pulling random indices from an array wil not allow a view to be computed. Negative indices can also be specified allowing for dynamic resolution of dimensions/coordinates at runtime.
    Author:
    Adam Gibson
    • Constructor Detail

      • SpecifiedIndex

        public SpecifiedIndex​(int... indexes)
      • SpecifiedIndex

        public SpecifiedIndex​(long... indexes)
    • 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:
      • iterate

        public static net.ericaro.neoitertools.Generator<List<List<Long>>> iterate​(INDArrayIndex... indexes)
        Iterate over a cross product of the coordinates
        Parameters:
        indexes - the coordinates to iterate over. Each element of the array should be of opType SpecifiedIndex otherwise it will end up throwing an exception
        Returns:
        the generator for iterating over all the combinations of the specified indexes.
      • iterateOverSparse

        public static net.ericaro.neoitertools.Generator<List<List<Long>>> iterateOverSparse​(INDArrayIndex... indexes)
        Iterate over a cross product of the coordinates
        Parameters:
        indexes - the coordinates to iterate over. Each element of the array should be of opType SpecifiedIndex otherwise it will end up throwing an exception
        Returns:
        the generator for iterating over all the combinations of the specified indexes.
      • generator

        public net.ericaro.neoitertools.Generator<List<Long>> generator()
      • sparseGenerator

        public net.ericaro.neoitertools.Generator<List<Long>> sparseGenerator()