Class Vector


  • public final class Vector
    extends Object
    An opaque vector of floating point values.
    Author:
    Netherlands Forensic Institute
    • Method Detail

      • of

        public static Vector of​(float... values)
        Creates a Vector from an array of floating point values.
        Parameters:
        values - the values to use
        Returns:
        a vector
      • of

        public static Vector of​(Collection<Float> values)
        Creates a Vector from a collection of numbers. Note that all numbers are converted to floats internally, so loss of precision may occur when doubles or longs are offered.
        Parameters:
        values - the values to use
        Returns:
        a vector
      • ofBase64

        public static Vector ofBase64​(String base64)
        Creates a Vector from a base64 encoded string.
        Parameters:
        base64 - the base64 encoded string to use
        Returns:
        a vector
      • asVector

        public static Vector asVector​(byte[] bytes)
        Creates a vector from a binary representation. Vector.asBinary() can be used to obtain a binary representation. Note that this directly sets the internal state of the Vector, use {code asVector(bytes.clone()} to store a safe, immutable copy.
        Parameters:
        bytes - the bytes to convert to a vector.
        Returns:
        a vector
      • asBinary

        public byte[] asBinary()
        Returns the binary representation of the Vector. Vector.asVector(byte[]) can be used to convert the binary representation back to the original vector. The format of the returned bytes is a sequence of the floating point values of the vector, stored as big-endian IEEE 754 encoded 32-bit floating point values. Note that this exposes the internal state of the Vector, use {code asBinary().clone()} to obtain a safely mutable copy.
        Returns:
        a binary representation of the vector.
      • size

        public int size()
        Returns the number of dimensions of the vector.
        Returns:
        the number of dimensions of the vector.
      • values

        public float[] values()
        Returns the values of the Vector as an array of floats.
        Returns:
        the values of the Vector as an array of floats.
      • toBase64

        public String toBase64()
        Returns a base64 encoded string of the Vector. Vector.ofBase64() can be used to convert the return base64 encoded string back to a Vector.
        Returns:
        a base64 encoded string of the Vector.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object