Class VectorUtils


  • public final class VectorUtils
    extends Object
    This work is derived from the excellent work made by Jelmer Kuperus on https://github.com/jelmerk/hnswlib.

    Misc utility methods for dealing with vectors.

    • Method Detail

      • magnitude

        public static double magnitude​(double[] vector)
        Calculates the magnitude of the vector.
        Parameters:
        vector - The vector to calculate magnitude for.
        Returns:
        The magnitude.
      • normalize

        public static double[] normalize​(double[] vector)
        Turns vector to unit vector.
        Parameters:
        vector - The vector to normalize.
        Returns:
        the input vector as a unit vector
      • magnitude

        public static float magnitude​(float[] vector)
        Calculates the magnitude of the vector.
        Parameters:
        vector - The vector to calculate magnitude for.
        Returns:
        The magnitude.
      • normalize

        public static float[] normalize​(float[] vector)
        Turns vector to unit vector.
        Parameters:
        vector - The vector to normalize.
        Returns:
        the input vector as a unit vector