Class DenseVector

java.lang.Object
it.unimi.dsi.law.vector.Vector
it.unimi.dsi.law.vector.DenseVector
All Implemented Interfaces:
Serializable

public class DenseVector
extends Vector
A mutable implementation of Vector optimized for dense vectors.
See Also:
Serialized Form
  • Method Details

    • getInstance

      public static DenseVector getInstance​(int size, int id)
      Returns an instance of given size with zero values.
      Parameters:
      size - the size.
      id - the id of description of this vector.
      Returns:
      a vector.
    • getInstance

      public static DenseVector getInstance​(double[] value, int id)
      Returns an instance from an array of values.
      Parameters:
      value - an array of values.
      id - the id of description of this vector.
      Returns:
      a vector.
    • set

      public void set​(int idx, double val)
      Description copied from class: Vector
      Sets the value val at index idx.
      Specified by:
      set in class Vector
      Parameters:
      idx - the index.
      val - the value.
    • get

      public double get​(int idx)
      Description copied from class: Vector
      Gets the value at index idx.
      Specified by:
      get in class Vector
      Parameters:
      idx - the index.
      Returns:
      the value at index idx.
    • add

      public void add​(double alpha, Vector v)
      Description copied from class: Vector
      Adds values in vector v scaled by alpha to this vector.
      Overrides:
      add in class Vector
      Parameters:
      alpha - the scaling factor.
      v - the vector to add.
    • scale

      public void scale​(double alpha)
      Description copied from class: Vector
      Scale values in this vector by a value alpha.
      Overrides:
      scale in class Vector
      Parameters:
      alpha - the scaling factor
    • zero

      public void zero()
      Description copied from class: Vector
      Reset (to zero) this vector.
      Overrides:
      zero in class Vector
    • dotProduct

      public double dotProduct​(Vector v)
      Description copied from class: Vector
      Returns the dot product between v and this vector.
      Overrides:
      dotProduct in class Vector
      Parameters:
      v - the vector.
      Returns:
      the dot product.
    • euclideanDistance

      public double euclideanDistance​(Vector v)
      Description copied from class: Vector
      Returns the euclidean distance between v and this vector.
      Overrides:
      euclideanDistance in class Vector
      Parameters:
      v - the vector.
      Returns:
      the euclidean distance.
    • ell2Norm

      public double ell2Norm()
      Description copied from class: Vector
      Returns the l2 norm of this vector.
      Overrides:
      ell2Norm in class Vector
      Returns:
      the l2 norm.
    • ell1Norm

      public double ell1Norm()
      Description copied from class: Vector
      Returns the l1 norm of this vector.
      Overrides:
      ell1Norm in class Vector