Class ByteDenseNdArray

java.lang.Object
org.tensorflow.ndarray.impl.dense.AbstractDenseNdArray<Byte, ByteNdArray>
org.tensorflow.ndarray.impl.dense.ByteDenseNdArray
All Implemented Interfaces:
ByteNdArray, NdArray<Byte>, Shaped

public class ByteDenseNdArray extends AbstractDenseNdArray<Byte, ByteNdArray> implements ByteNdArray
  • Field Details

  • Constructor Details

  • Method Details

    • create

      public static ByteNdArray create(ByteDataBuffer buffer, Shape shape)
    • getByte

      public byte getByte(long... indices)
      Description copied from interface: ByteNdArray
      Returns the byte 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:

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

      public ByteNdArray setByte(byte value, long... indices)
      Description copied from interface: ByteNdArray
      Assigns the byte 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:

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

      public ByteNdArray copyTo(NdArray<Byte> 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 ByteNdArray
      Specified by:
      copyTo in interface NdArray<Byte>
      Parameters:
      dst - array to receive a copy of the content of this array
      Returns:
      this array
    • copyTo

      public ByteNdArray copyTo(ByteDataBuffer dst)
      Specified by:
      copyTo in interface ByteNdArray
    • copyFrom

      public ByteNdArray copyFrom(ByteDataBuffer src)
      Specified by:
      copyFrom in interface ByteNdArray
    • buffer

      protected ByteDataBuffer buffer()
      Specified by:
      buffer in class AbstractDenseNdArray<Byte, ByteNdArray>
    • dimensions

      public DimensionalSpace dimensions()
    • shape

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

      public NdArraySequence<ByteNdArray> 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)