public class FloatPackingScheme extends java.lang.Object implements PackingScheme
FloatPackingScheme
class implements a scale and offset
packing scheme for primitive float data. Float values are packed as
integer = float/scale + offset
and then rounded to the nearest
integer. Various convenience methods are available for packing and unpacking
primitive data arrays.Modifier and Type | Field and Description |
---|---|
float |
offset
The offset for float data.
|
float |
scale
The scaling factor for float data.
|
Constructor and Description |
---|
FloatPackingScheme() |
Modifier and Type | Method and Description |
---|---|
void |
accept(PackingSchemeVisitor visitor)
Accepts a visitor in this scheme.
|
DataChunk.DataType |
getUnpackedType()
Gets the unpacked data type that values in this packing scheme will
be unpacked to.
|
static void |
main(java.lang.String[] argv)
Tests this class.
|
int |
packFloat(float value)
Packs a float value to an integer.
|
void |
packToByteData(float[] floatData,
byte[] byteData,
java.lang.Byte missing,
boolean isUnsigned)
Packs primitive data from a float array into a byte array.
|
void |
packToIntData(float[] floatData,
int[] intData,
java.lang.Integer missing)
Packs primitive data from a float array into a int array.
|
void |
packToShortData(float[] floatData,
short[] shortData,
java.lang.Short missing,
boolean isUnsigned)
Packs primitive data from a float array into a short array.
|
float |
unpackFloat(int packed)
Unpacks an integer value to a float.
|
void |
unpackFromByteData(byte[] byteData,
float[] floatData,
java.lang.Byte missing,
boolean isUnsigned)
Unpacks primitive data from a byte array into a float array.
|
void |
unpackFromIntData(int[] intData,
float[] floatData,
java.lang.Integer missing)
Unpacks primitive data from a int array into a float array.
|
void |
unpackFromShortData(short[] shortData,
float[] floatData,
java.lang.Short missing,
boolean isUnsigned)
Unpacks primitive data from a short array into a float array.
|
public float scale
public float offset
public DataChunk.DataType getUnpackedType()
PackingScheme
getUnpackedType
in interface PackingScheme
public void accept(PackingSchemeVisitor visitor)
PackingScheme
accept
in interface PackingScheme
visitor
- the visitor to accept.public void unpackFromByteData(byte[] byteData, float[] floatData, java.lang.Byte missing, boolean isUnsigned)
byteData
- the source array to unpack.floatData
- the destination array to unpack into.missing
- the missing value to detect (or null for none).
Values in the source array that match the missing value will be
assigned Float.NaN in the destination array.isUnsigned
- the unsigned flag, true if the data is unsigned
or false if not.public void packToByteData(float[] floatData, byte[] byteData, java.lang.Byte missing, boolean isUnsigned)
floatData
- the source array to pack.byteData
- the destination array to pack into.missing
- the missing value to detect (or null for none).
Non-finite (NaN and infinity values) in the source array will be
assigned the missing value in the destination array.isUnsigned
- the unsigned flag, true if the destination data is
unsigned or false if not.public void unpackFromShortData(short[] shortData, float[] floatData, java.lang.Short missing, boolean isUnsigned)
shortData
- the source array to unpack.floatData
- the destination array to unpack into.missing
- the missing value to detect (or null for none).
Values in the source array that match the missing value will be
assigned Float.NaN in the destination array.isUnsigned
- the unsigned flag, true if the data is unsigned
or false if not.public void packToShortData(float[] floatData, short[] shortData, java.lang.Short missing, boolean isUnsigned)
floatData
- the source array to pack.shortData
- the destination array to pack into.missing
- the missing value to detect (or null for none).
Non-finite (NaN and infinity values) in the source array will be
assigned the missing value in the destination array.isUnsigned
- the unsigned flag, true if the destination data is
unsigned or false if not.public void unpackFromIntData(int[] intData, float[] floatData, java.lang.Integer missing)
intData
- the source array to unpack.floatData
- the destination array to unpack into.missing
- the missing value to detect (or null for none).
Values in the source array that match the missing value will be
assigned Float.NaN in the destination array.public void packToIntData(float[] floatData, int[] intData, java.lang.Integer missing)
floatData
- the source array to pack.intData
- the destination array to pack into.missing
- the missing value to detect (or null for none).
Non-finite (NaN and infinity values) in the source array will be
assigned the missing value in the destination array.public int packFloat(float value)
value
- the float value to pack.public float unpackFloat(int packed)
packed
- the integer value to unpack.public static void main(java.lang.String[] argv) throws java.lang.Exception
argv
- the array of command line parameters.java.lang.Exception