Package com.itextpdf.pdfocr.onnxtr
Class FloatBufferMdArray
java.lang.Object
com.itextpdf.pdfocr.onnxtr.FloatBufferMdArray
Multidimensional array with a
FloatBuffer backing storage.
-
Constructor Summary
ConstructorsConstructorDescriptionFloatBufferMdArray(FloatBuffer data, long[] shape) Constructs a newFloatBufferMdArraywith the specified data buffer and shape. -
Method Summary
Modifier and TypeMethodDescriptionintGets internal offset of the provided float buffer array.intGets number of available bytes for read from provided float buffer array.getData()Returns a duplicate of the backingFloatBuffer.intgetDimension(int index) Returns the size of the specified dimension.intReturns the number of dimensions of this multidimensional array.floatgetScalar(int index) Returns the scalar value at the specified index.long[]getShape()Returns a copy of the shape array that defines the dimensions of this multidimensional array.getSubArray(int index) Returns a sub-array representing the slice at the specified index of the first dimension.
-
Constructor Details
-
FloatBufferMdArray
Constructs a newFloatBufferMdArraywith the specified data buffer and shape.- Parameters:
-
data- theFloatBuffercontaining the data for this array -
shape- the shape of the multidimensional array, where each entry specifies the size of a dimension - Throws:
-
NullPointerException- ifdataorshapeisnull -
IllegalArgumentException- ifshapeis invalid or the number of elements indatadoes not match the element count derived fromshape
-
-
Method Details
-
getData
Returns a duplicate of the backingFloatBuffer.- 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- ifindexis negative or greater than or equal to the number of dimensions
-
getSubArray
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
FloatBufferMdArrayrepresenting the specified sub-array - Throws:
-
IllegalStateException- if this array has no dimensions -
IndexOutOfBoundsException- ifindexis 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
-