Class DoubleRealVector
- All Implemented Interfaces:
RealVector
HalfRealVector is supported and
memoized.-
Field Summary
Fields inherited from class com.apple.foundationdb.linear.AbstractRealVector
hashCodeSupplier -
Constructor Summary
ConstructorsConstructorDescriptionDoubleRealVector(double[] data) DoubleRealVector(int[] intData) DoubleRealVector(long[] longData) DoubleRealVector(Double[] doubleData) -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]Converts thisRealVectorofdoubleprecision floating-point numbers into a byte array.static DoubleRealVectorfromBytes(byte[] vectorBytes) Creates aDoubleRealVectorfrom 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
-
DoubleRealVector
-
DoubleRealVector
public DoubleRealVector(@Nonnull double[] data) -
DoubleRealVector
public DoubleRealVector(@Nonnull int[] intData) -
DoubleRealVector
public DoubleRealVector(@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 thisRealVectorofdoubleprecision floating-point numbers into a byte array.This method iterates through the input vector, converting each
doubleelement into its 16-bit short representation. It then serializes this short into eight bytes, placing them sequentially into the resulting byte array. The final array's length will be8 * vector.size().- Specified by:
computeRawDatain classAbstractRealVector- Returns:
- a new byte array representing the serialized vector data. This array is never null.
-
fromBytes
Creates aDoubleRealVectorfrom a byte array.This method interprets the input byte array as a sequence of 64-bit double-precision floating-point numbers. Each run of eight bytes is converted into a
doublevalue, which then becomes a component of the resulting vector.- Parameters:
vectorBytes- the non-null byte array to convert- Returns:
- a new
DoubleRealVectorinstance created from the byte array
-