Class FloatBufferMdArray

java.lang.Object
com.itextpdf.pdfocr.onnxtr.FloatBufferMdArray

public class FloatBufferMdArray extends Object
Multidimensional array with a FloatBuffer backing storage.
  • Constructor Details

    • FloatBufferMdArray

      public FloatBufferMdArray (FloatBuffer data, long[] shape)
      Constructs a new FloatBufferMdArray with the specified data buffer and shape.
      Parameters:
      data - the FloatBuffer containing the data for this array
      shape - the shape of the multidimensional array, where each entry specifies the size of a dimension
      Throws:
      NullPointerException - if data or shape is null
      IllegalArgumentException - if shape is invalid or the number of elements in data does not match the element count derived from shape
  • Method Details

    • getData

      public FloatBuffer getData()
      Returns a duplicate of the backing FloatBuffer.
      Returns:
      a duplicate of the backing FloatBuffer
    • getShape

      public long[] getShape()
      Returns a copy of the shape array that defines the dimensions of this multidimensional array.
      Returns:
      a copy of the shape array
    • getDimensionCount

      public int getDimensionCount()
      Returns the number of dimensions of this multidimensional array.
      Returns:
      the number of dimensions
    • getDimension

      public int getDimension (int index)
      Returns the size of the specified dimension.
      Parameters:
      index - the zero-based index of the dimension to query
      Returns:
      the size of the dimension at the specified index
      Throws:
      IndexOutOfBoundsException - if index is negative or greater than or equal to the number of dimensions
    • getSubArray

      public FloatBufferMdArray getSubArray (int index)
      Returns a sub-array representing the slice at the specified index of the first dimension.
      Parameters:
      index - the index along the first dimension to retrieve
      Returns:
      a FloatBufferMdArray representing the specified sub-array
      Throws:
      IllegalStateException - if this array has no dimensions
      IndexOutOfBoundsException - if index is negative or exceeds the bounds of the first dimension
    • getScalar

      public float getScalar (int index)
      Returns the scalar value at the specified index.

      This method only works on one-dimensional arrays, where the total element count matches the size of the first dimension

      Parameters:
      index - the index of the scalar to retrieve
      Returns:
      the scalar float value at the specified index
      Throws:
      IllegalStateException - if this array is not properly shaped as a one-dimensional array
    • getArrayOffset

      public int getArrayOffset()
      Gets internal offset of the provided float buffer array.
      Returns:
      internal offset
    • getArraySize

      public int getArraySize()
      Gets number of available bytes for read from provided float buffer array.
      Returns:
      number of available bytes for read