Package ai.djl.ndarray.index
Class NDArrayIndexer
- java.lang.Object
-
- ai.djl.ndarray.index.NDArrayIndexer
-
public abstract class NDArrayIndexer extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description NDArrayIndexer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract NDArray
get(NDArray array, NDIndexFullPick fullPick)
Returns a subarray by picking the elements.abstract NDArray
get(NDArray array, NDIndexFullSlice fullSlice)
Returns a subarray at the slice.NDArray
get(NDArray array, NDIndex index)
Returns a subarray at the given index.void
set(NDArray array, NDIndexBooleans indices, NDArray value)
Sets the values of the array at the boolean locations with an array.abstract void
set(NDArray array, NDIndexFullSlice fullSlice, NDArray value)
Sets the values of the array at the fullSlice with an array.abstract void
set(NDArray array, NDIndexFullSlice fullSlice, java.lang.Number value)
Sets the values of the array at the fullSlice with a number.void
set(NDArray array, NDIndex index, NDArray value)
Sets the values of the array at the index locations with an array.void
set(NDArray array, NDIndex index, java.lang.Number value)
Sets the values of the array at the index locations with a number.void
setScalar(NDArray array, NDIndex index, java.lang.Number value)
Sets a scalar value in the array at the indexed location.
-
-
-
Method Detail
-
get
public abstract NDArray get(NDArray array, NDIndexFullPick fullPick)
Returns a subarray by picking the elements.- Parameters:
array
- the array to get fromfullPick
- the elements to pick- Returns:
- the subArray
-
get
public abstract NDArray get(NDArray array, NDIndexFullSlice fullSlice)
Returns a subarray at the slice.- Parameters:
array
- the array to get fromfullSlice
- the fullSlice index of the array- Returns:
- the subArray
-
get
public NDArray get(NDArray array, NDIndex index)
Returns a subarray at the given index.- Parameters:
array
- the array to get fromindex
- the index to get- Returns:
- the subarray
-
set
public abstract void set(NDArray array, NDIndexFullSlice fullSlice, NDArray value)
Sets the values of the array at the fullSlice with an array.- Parameters:
array
- the array to setfullSlice
- the fullSlice of the index to set in the arrayvalue
- the value to set with
-
set
public void set(NDArray array, NDIndexBooleans indices, NDArray value)
Sets the values of the array at the boolean locations with an array.- Parameters:
array
- the array to setindices
- a boolean array where true indicates values to updatevalue
- the value to set with when condition is true
-
set
public void set(NDArray array, NDIndex index, NDArray value)
Sets the values of the array at the index locations with an array.- Parameters:
array
- the array to setindex
- the index to set at in the arrayvalue
- the value to set with
-
set
public abstract void set(NDArray array, NDIndexFullSlice fullSlice, java.lang.Number value)
Sets the values of the array at the fullSlice with a number.- Parameters:
array
- the array to setfullSlice
- the fullSlice of the index to set in the arrayvalue
- the value to set with
-
set
public void set(NDArray array, NDIndex index, java.lang.Number value)
Sets the values of the array at the index locations with a number.- Parameters:
array
- the array to setindex
- the index to set at in the arrayvalue
- the value to set with
-
setScalar
public void setScalar(NDArray array, NDIndex index, java.lang.Number value)
Sets a scalar value in the array at the indexed location.- Parameters:
array
- the array to setindex
- the index to set at in the arrayvalue
- the value to set with- Throws:
java.lang.IllegalArgumentException
- if the index does not point to a scalar value in the array
-
-