Class HalfRealVector
- All Implemented Interfaces:
RealVector
DoubleRealVector is supported and
memoized.-
Field Summary
Fields inherited from class com.apple.foundationdb.linear.AbstractRealVector
hashCodeSupplier -
Constructor Summary
ConstructorsConstructorDescriptionHalfRealVector(double[] data) HalfRealVector(int[] intData) HalfRealVector(long[] longData) HalfRealVector(Half[] halfData) -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]Converts thisRealVectorofHalfprecision floating-point numbers into a byte array.static HalfRealVectorfromBytes(byte[] vectorBytes) Creates aHalfRealVectorfrom a byte array.Converts this vector into aDoubleRealVector.Converts this object into aRealVectorof single precision floating-point numbers.Converts this object into aRealVectorofHalfprecision floating-point numbers.withData(double[] data) Methods inherited from class com.apple.foundationdb.linear.AbstractRealVector
equals, fromInts, fromLongs, getComponent, getData, getNumDimensions, getRawData, hashCode, toString, toString
-
Constructor Details
-
HalfRealVector
-
HalfRealVector
public HalfRealVector(@Nonnull double[] data) -
HalfRealVector
public HalfRealVector(@Nonnull int[] intData) -
HalfRealVector
public HalfRealVector(@Nonnull long[] longData)
-
-
Method Details
-
toHalfRealVector
Description copied from interface:RealVectorConverts this object into aRealVectorofHalfprecision floating-point numbers.As this is an abstract method, implementing classes are responsible for defining the specific conversion logic from their internal representation to a
RealVectorusingHalfobjects to serialize and deserialize the vector. If this object already is aHalfRealVectorthis method should returnthis.- Returns:
- a non-null
HalfRealVectorcontaining theHalfprecision floating-point representation of this object.
-
toFloatRealVector
Description copied from interface:RealVectorConverts this object into aRealVectorof single precision floating-point numbers.As this is an abstract method, implementing classes are responsible for defining the specific conversion logic from their internal representation to a
RealVectorusing floating point numbers to serialize and deserialize the vector. If this object already is aFloatRealVectorthis method should returnthis.- Returns:
- a non-null
FloatRealVectorcontaining the single precision floating-point representation of this object.
-
toDoubleRealVector
Description copied from interface:RealVectorConverts this vector into aDoubleRealVector.This method provides a way to obtain a double-precision floating-point representation of the vector. If the vector is already an instance of
DoubleRealVector, this method may return the instance itself. Otherwise, it will create a newDoubleRealVectorcontaining the same elements, which may involve a conversion of the underlying data type.- Returns:
- a non-null
DoubleRealVectorrepresentation of this vector.
-
withData
-
computeRawData
@Nonnull protected byte[] computeRawData()Converts thisRealVectorofHalfprecision floating-point numbers into a byte array.This method iterates through the input vector, converting each
Halfelement into its 16-bit short representation. It then serializes this short into two bytes, placing them sequentially into the resulting byte array. The final array's length will be2 * vector.size().- Specified by:
computeRawDatain classAbstractRealVector- Returns:
- a new byte array representing the serialized vector data. This array is never null.
-
fromBytes
Creates aHalfRealVectorfrom a byte array.This method interprets the input byte array as a sequence of 16-bit half-precision floating-point numbers. Each consecutive pair of bytes is converted into a
Halfvalue, which then becomes a component of the resulting vector.- Parameters:
vectorBytes- the non-null byte array to convert- Returns:
- a new
HalfRealVectorinstance created from the byte array
-