Interface Index


public interface Index
An index used for slicing a view out of an N-dimensional array.

A slice, i.e. a reduced view, of an N-dimensional array is obtain by calling NdArray.slice(Index...), given a list of indices that select which elements on a given dimension should be included/excluded from that view.

  • Method Summary

    Modifier and Type
    Method
    Description
    default Dimension
    Applies this index to the given dimension.
    default long
    Get the start of the index, for strided slice style indexing.
    default boolean
    Get whether the Index should start at the beginning of the dimension, for strided slice style indexing.
    default long
    end()
    Get the end of the index, strided slice style indexing.
    default boolean
    Get whether the Index should end at the beginning of the dimension, for strided slice style indexing.
    default boolean
    Returns true if this index is an ellipsis, expanding to take as many dimensions as possible (and applying all() to them)
    default boolean
    Returns true if this index is a new axis, adding a dimension of size 1
    default boolean
    Returns true if this index is a single point, reducing the number of dimensions by one
    default boolean
    Get whether the Index supports strided slice style indexing (using start, end, stride, and flags, i.e.
    long
    mapCoordinate(long coordinate, Dimension dim)
    Transforms an element coordinate to a new coordinate by applying this index to the given dimension.
    long
    Returns the number of elements that can be retrieved using this index on the given dimension.
    default long
    Get the stride of the index, for strided slice style indexing.
  • Method Details

    • numElements

      long numElements(Dimension dim)
      Returns the number of elements that can be retrieved using this index on the given dimension.

      An index that maps one-by-one all elements of the dimensions will return a value equal to dim.numElements(), while an index that only maps a subset of these will return a smaller value.

      Parameters:
      dim - the indexed dimension
      Returns:
      number of elements accessible
    • mapCoordinate

      long mapCoordinate(long coordinate, Dimension dim)
      Transforms an element coordinate to a new coordinate by applying this index to the given dimension.

      For example, if the coordinate is 0 and this index flips the n elements on this dimension, then the returned value will be n-1.

      Parameters:
      coordinate - coordinate to transform
      dim - dimension the indexed dimension
      Returns:
      transformed coordinate
    • apply

      default Dimension apply(Dimension dim)
      Applies this index to the given dimension.

      When accessing the elements from the returned dimension, this index will automatically apply and may transform the original position.

      Parameters:
      dim - dimension to apply this index to
      Returns:
      an indexed dimension
    • isPoint

      default boolean isPoint()
      Returns true if this index is a single point, reducing the number of dimensions by one
    • isNewAxis

      default boolean isNewAxis()
      Returns true if this index is a new axis, adding a dimension of size 1
    • isEllipsis

      default boolean isEllipsis()
      Returns true if this index is an ellipsis, expanding to take as many dimensions as possible (and applying all() to them)
    • isStridedSlicingCompliant

      default boolean isStridedSlicingCompliant()
      Get whether the Index supports strided slice style indexing (using start, end, stride, and flags, i.e. TensorFlow's).
    • begin

      default long begin()
      Get the start of the index, for strided slice style indexing.
    • end

      default long end()
      Get the end of the index, strided slice style indexing.
    • stride

      default long stride()
      Get the stride of the index, for strided slice style indexing.
    • beginMask

      default boolean beginMask()
      Get whether the Index should start at the beginning of the dimension, for strided slice style indexing.
    • endMask

      default boolean endMask()
      Get whether the Index should end at the beginning of the dimension, for strided slice style indexing.