Class FloatRealVector
- All Implemented Interfaces:
RealVector
-
Field Summary
Fields inherited from class com.apple.foundationdb.linear.AbstractRealVector
hashCodeSupplier -
Constructor Summary
ConstructorsConstructorDescriptionFloatRealVector(double[] data) FloatRealVector(float[] floatData) FloatRealVector(int[] intData) FloatRealVector(long[] longData) FloatRealVector(Float[] floatData) -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]Converts thisRealVectorof single precision floating-point numbers into a byte array.static FloatRealVectorfromBytes(byte[] vectorBytes) Creates aFloatRealVectorfrom 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
-
FloatRealVector
-
FloatRealVector
public FloatRealVector(@Nonnull float[] floatData) -
FloatRealVector
public FloatRealVector(@Nonnull double[] data) -
FloatRealVector
public FloatRealVector(@Nonnull int[] intData) -
FloatRealVector
public FloatRealVector(@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.
-
computeHalfRealVector
-
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 thisRealVectorof single precision 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 aFloatRealVectorfrom 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
FloatRealVectorinstance created from the byte array
-