Class DoubleRealVector

java.lang.Object
com.apple.foundationdb.linear.AbstractRealVector
com.apple.foundationdb.linear.DoubleRealVector
All Implemented Interfaces:
RealVector

public class DoubleRealVector extends AbstractRealVector
A vector class encoding a vector over double components. Conversion to HalfRealVector is supported and memoized.
  • Constructor Details

    • DoubleRealVector

      public DoubleRealVector(@Nonnull Double[] doubleData)
    • DoubleRealVector

      public DoubleRealVector(@Nonnull double[] data)
    • DoubleRealVector

      public DoubleRealVector(@Nonnull int[] intData)
    • DoubleRealVector

      public DoubleRealVector(@Nonnull long[] longData)
  • Method Details

    • toHalfRealVector

      @Nonnull public HalfRealVector toHalfRealVector()
      Description copied from interface: RealVector
      Converts this object into a RealVector of Half 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 RealVector using Half objects to serialize and deserialize the vector. If this object already is a HalfRealVector this method should return this.

      Returns:
      a non-null HalfRealVector containing the Half precision floating-point representation of this object.
    • computeHalfRealVector

      @Nonnull public HalfRealVector computeHalfRealVector()
    • toFloatRealVector

      @Nonnull public FloatRealVector toFloatRealVector()
      Description copied from interface: RealVector
      Converts this object into a RealVector of 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 RealVector using floating point numbers to serialize and deserialize the vector. If this object already is a FloatRealVector this method should return this.

      Returns:
      a non-null FloatRealVector containing the single precision floating-point representation of this object.
    • toDoubleRealVector

      @Nonnull public DoubleRealVector toDoubleRealVector()
      Description copied from interface: RealVector
      Converts this vector into a DoubleRealVector.

      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 new DoubleRealVector containing the same elements, which may involve a conversion of the underlying data type.

      Returns:
      a non-null DoubleRealVector representation of this vector.
    • withData

      @Nonnull public RealVector withData(@Nonnull double[] data)
    • computeRawData

      @Nonnull protected byte[] computeRawData()
      Converts this RealVector of double precision floating-point numbers into a byte array.

      This method iterates through the input vector, converting each double element 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 be 8 * vector.size().

      Specified by:
      computeRawData in class AbstractRealVector
      Returns:
      a new byte array representing the serialized vector data. This array is never null.
    • fromBytes

      @Nonnull public static DoubleRealVector fromBytes(@Nonnull byte[] vectorBytes)
      Creates a DoubleRealVector from 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 double value, which then becomes a component of the resulting vector.

      Parameters:
      vectorBytes - the non-null byte array to convert
      Returns:
      a new DoubleRealVector instance created from the byte array