Class IntDenseNdArray

All Implemented Interfaces:
IntNdArray, NdArray<Integer>, Shaped

public class IntDenseNdArray extends AbstractDenseNdArray<Integer, IntNdArray> implements IntNdArray
  • Field Details

  • Constructor Details

  • Method Details

    • create

      public static IntNdArray create(IntDataBuffer buffer, Shape shape)
    • getInt

      public int getInt(long... indices)
      Description copied from interface: IntNdArray
      Returns the integer value of the scalar found at the given coordinates.

      To access the scalar element, the number of coordinates provided must be equal to the number of dimensions of this array (i.e. its rank). For example:

       IntNdArray matrix = NdArrays.ofInts(shape(2, 2));  // matrix rank = 2
       matrix.getInt(0, 1);  // succeeds, returns 0
       matrix.getInt(0);  // throws IllegalRankException
      
       IntNdArray scalar = matrix.get(0, 1);  // scalar rank = 0
       scalar.getInt();  // succeeds, returns 0
      
      Specified by:
      getInt in interface IntNdArray
      Parameters:
      indices - coordinates of the scalar to resolve
      Returns:
      value of that scalar
    • setInt

      public IntNdArray setInt(int value, long... indices)
      Description copied from interface: IntNdArray
      Assigns the integer value of the scalar found at the given coordinates.

      To access the scalar element, the number of coordinates provided must be equal to the number of dimensions of this array (i.e. its rank). For example:

       IntNdArray matrix = NdArrays.ofInts(shape(2, 2));  // matrix rank = 2
       matrix.setInt(10, 0, 1);  // succeeds
       matrix.setInt(10, 0);  // throws IllegalRankException
      
       IntNdArray scalar = matrix.get(0, 1);  // scalar rank = 0
       scalar.setInt(10);  // succeeds
      
      Specified by:
      setInt in interface IntNdArray
      Parameters:
      value - value to assign
      indices - coordinates of the scalar to assign
      Returns:
      this array
    • copyTo

      public IntNdArray copyTo(NdArray<Integer> dst)
      Description copied from interface: NdArray
      Copy the content of this array to the destination array.

      The Shaped.shape() of the destination array must be equal to the shape of this array, or an exception is thrown. After the copy, the content of both arrays can be altered independently, without affecting each other.

      Specified by:
      copyTo in interface IntNdArray
      Specified by:
      copyTo in interface NdArray<Integer>
      Parameters:
      dst - array to receive a copy of the content of this array
      Returns:
      this array
    • copyTo

      public IntNdArray copyTo(IntDataBuffer dst)
      Specified by:
      copyTo in interface IntNdArray
    • copyFrom

      public IntNdArray copyFrom(IntDataBuffer src)
      Specified by:
      copyFrom in interface IntNdArray
    • buffer

      protected IntDataBuffer buffer()
      Specified by:
      buffer in class AbstractDenseNdArray<Integer, IntNdArray>
    • dimensions

      public DimensionalSpace dimensions()
    • shape

      public Shape shape()
      Specified by:
      shape in interface Shaped
      Returns:
      the shape of this container
    • scalars

      public NdArraySequence<IntNdArray> scalars()
      Description copied from interface: NdArray
      Returns a sequence of all scalars in this array.

      This is equivalent to call elements(shape().numDimensions() - 1)

      Specified by:
      scalars in interface NdArray<T>
      Returns:
      an NdArray sequence
    • slowHashCode

      protected int slowHashCode()
    • slowEquals

      protected boolean slowEquals(NdArray<?> array)