-
public interface IndexAn 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Dimensionapply(Dimension dim)Applies this index to the given dimension.default longbegin()Get the start of the index, for strided slice style indexing.default booleanbeginMask()Get whether the Index should start at the beginning of the dimension, for strided slice style indexing.default longend()Get the end of the index, strided slice style indexing.default booleanendMask()Get whether the Index should end at the beginning of the dimension, for strided slice style indexing.default booleanisEllipsis()Returns true if this index is an ellipsis, expanding to take as many dimensions as possible (and applying all() to them)default booleanisNewAxis()Returns true if this index is a new axis, adding a dimension of size 1default booleanisPoint()Returns true if this index is a single point, reducing the number of dimensions by onedefault booleanisStridedSlicingCompliant()Get whether the Index supports strided slice style indexing (using start, end, stride, and flags, i.e.longmapCoordinate(long coordinate, Dimension dim)Transforms an element coordinate to a new coordinate by applying this index to the given dimension.longnumElements(Dimension dim)Returns the number of elements that can be retrieved using this index on the given dimension.default longstride()Get the stride of the index, for strided slice style indexing.
-
-
-
Method Detail
-
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
nelements on this dimension, then the returned value will ben-1.- Parameters:
coordinate- coordinate to transformdim- 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.
-
-