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 newFloatBufferMdArray
with the specified data buffer and shape. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets internal offset of the provided float buffer array.int
Gets number of available bytes for read from provided float buffer array.getData()
Returns a duplicate of the backingFloatBuffer
.int
getDimension
(int index) Returns the size of the specified dimension.int
Returns the number of dimensions of this multidimensional array.float
getScalar
(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 newFloatBufferMdArray
with the specified data buffer and shape.- Parameters:
-
data
- theFloatBuffer
containing the data for this array -
shape
- the shape of the multidimensional array, where each entry specifies the size of a dimension - Throws:
-
NullPointerException
- ifdata
orshape
isnull
-
IllegalArgumentException
- ifshape
is invalid or the number of elements indata
does 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
- ifindex
is 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
FloatBufferMdArray
representing the specified sub-array - Throws:
-
IllegalStateException
- if this array has no dimensions -
IndexOutOfBoundsException
- ifindex
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
-