Interface RealVector

All Known Implementing Classes:
AbstractRealVector, DoubleRealVector, EncodedRealVector, FloatRealVector, HalfRealVector

public interface RealVector
An abstract base class representing a mathematical vector.

This class provides a generic framework for vectors of different numerical types, where R is a subtype of Number. It includes common operations and functionalities like size, component access, equality checks, and conversions. Concrete implementations must provide specific logic for data type conversions and raw data representation.

  • Method Details

    • getNumDimensions

      int getNumDimensions()
      Returns the number of elements in the vector, i.e. the number of dimensions.
      Returns:
      the number of dimensions
    • getComponent

      double getComponent(int dimension)
      Gets the component of this object at the specified dimension.

      The dimension is a zero-based index. For a 3D vector, for example, dimension 0 might correspond to the x-component, 1 to the y-component, and 2 to the z-component. This method provides direct access to the underlying data element.

      Parameters:
      dimension - the zero-based index of the component to retrieve.
      Returns:
      the component at the specified dimension, which is guaranteed to be non-null.
      Throws:
      IndexOutOfBoundsException - if the dimension is negative or greater than or equal to the number of dimensions of this object.
    • getData

      @Nonnull double[] getData()
      Returns the underlying data array.

      The returned array is guaranteed to be non-null. Note that this method returns a direct reference to the internal array, not a copy.

      Returns:
      the data array of type R[], never null.
    • withData

      @Nonnull RealVector withData(@Nonnull double[] data)
    • getRawData

      @Nonnull byte[] getRawData()
      Gets the raw byte data representation of this object.

      This method provides a direct, unprocessed view of the object's underlying data. The format of the byte array is implementation-specific and should be documented by the concrete class that implements this method.

      Returns:
      a non-null byte array containing the raw data.
    • toHalfRealVector

      @Nonnull HalfRealVector toHalfRealVector()
      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.
    • toFloatRealVector

      @Nonnull FloatRealVector toFloatRealVector()
      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 DoubleRealVector toDoubleRealVector()
      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.
    • dot

      default double dot(@Nonnull RealVector other)
    • l2Norm

      default double l2Norm()
    • normalize

      @Nonnull default RealVector normalize()
    • add

      @Nonnull default RealVector add(@Nonnull RealVector other)
    • add

      @Nonnull default RealVector add(double scalar)
    • subtract

      @Nonnull default RealVector subtract(@Nonnull RealVector other)
    • subtract

      @Nonnull default RealVector subtract(double scalar)
    • multiply

      @Nonnull default RealVector multiply(double scalarFactor)