Class NDArrayIndexer

java.lang.Object
ai.djl.ndarray.index.NDArrayIndexer

public abstract class NDArrayIndexer extends Object
A helper class for NDArray implementations for operations with an NDIndex.
  • Constructor Details

    • NDArrayIndexer

      public NDArrayIndexer()
  • Method Details

    • get

      public abstract NDArray get(NDArray array, NDIndexFullPick fullPick)
      Returns a subarray by picking the elements.
      Parameters:
      array - the array to get from
      fullPick - the elements to pick
      Returns:
      the subArray
    • get

      public abstract NDArray get(NDArray array, NDIndexFullTake fullTake)
      Returns a subarray by taken the elements from one axis.
      Parameters:
      array - the array to get from
      fullTake - 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 from
      fullSlice - 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 from
      index - the index to get
      Returns:
      the subarray
    • set

      public void set(NDArray array, NDIndex index, Object value)
      Sets the entries of array at the indexed locations with the parameter value. The value can be only Number or NDArray.
      Parameters:
      array - the array to set
      index - the index to set at in the array
      value - the value to set with
    • 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 set
      fullSlice - the fullSlice of the index to set in the array
      value - 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 set
      indices - a boolean array where true indicates values to update
      value - the value to set with when condition is true
    • set

      public abstract void set(NDArray array, NDIndexFullSlice fullSlice, Number value)
      Sets the values of the array at the fullSlice with a number.
      Parameters:
      array - the array to set
      fullSlice - the fullSlice of the index to set in the array
      value - the value to set with
    • setScalar

      public void setScalar(NDArray array, NDIndex index, Number value)
      Sets a scalar value in the array at the indexed location.
      Parameters:
      array - the array to set
      index - the index to set at in the array
      value - the value to set with
      Throws:
      IllegalArgumentException - if the index does not point to a scalar value in the array