Documentation of 'medusa.georgios.enhanced_mcl.SparseVector' Java class
SparseVector
medusa.georgios.enhanced_mcl

Class SparseVector

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Integer,java.lang.Double>


    public class SparseVector
    extends java.util.HashMap<java.lang.Integer,java.lang.Double>
    SparseVector represents a sparse vector.

    Conventions: except for the inherited methods and normalise(double), operations leave this ummodified (immutable) if there is a return value. Within operations, no pruning of values close to zero is done. Pruning can be controlled via the prune() method.

    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K,V>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void add(int i, double a)
      mutable add
      void add(SparseVector v)
      mutable add
      SparseVector copy()
      copy the contents of the sparse vector
      double expSum(int p)
      exponential sum, i.e., sum (elements^p)
      void factor(double a)
      mutable factorisation
      java.lang.Double get(java.lang.Object key)
      get ensures it returns 0 for empty hash values or if index exceeds length.
      double[] getDense()
      get dense represenation
      int getLength()
      get the length of the vector
      void hadamardPower(double s)
      mutable Hadamard power
      void hadamardProduct(SparseVector v)
      mutable Hadamard product (elementwise multiplication)
      double max()
      maximum element value
      void mult(int i, double a)
      mutable mult
      void normalise()
      normalises the vector to 1.
      double normalise(double newsum)
      normalises the vector to newsum
      void prune(double threshold)
      remove all elements whose magnitude is < threshold
      java.lang.Double put(java.lang.Integer key, java.lang.Double value)
      put increases the matrix size if the index exceeds the current size.
      void setLength(int length)
      set the new length of the vector (regardless of the maximum index).
      double sum(double s)
      power sum of the elements
      double times(SparseVector v)
      immutable scalar product
      java.lang.String toString() 
      java.lang.String toStringDense()
      create string representation of dense equivalent.
      • Methods inherited from class java.util.HashMap

        clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        equals, hashCode
    • Constructor Detail

      • SparseVector

        public SparseVector()
        create empty vector
      • SparseVector

        public SparseVector(int i)
        create empty vector with length
      • SparseVector

        public SparseVector(double[] x)
        create vector from dense vector
        Parameters:
        x -
      • SparseVector

        public SparseVector(SparseVector v)
        copy constructor
        Parameters:
        v -
    • Method Detail

      • get

        public java.lang.Double get(java.lang.Object key)
        get ensures it returns 0 for empty hash values or if index exceeds length.
        Specified by:
        get in interface java.util.Map<java.lang.Integer,java.lang.Double>
        Overrides:
        get in class java.util.HashMap<java.lang.Integer,java.lang.Double>
        Parameters:
        key -
        Returns:
        val
      • put

        public java.lang.Double put(java.lang.Integer key,
                                    java.lang.Double value)
        put increases the matrix size if the index exceeds the current size.
        Specified by:
        put in interface java.util.Map<java.lang.Integer,java.lang.Double>
        Overrides:
        put in class java.util.HashMap<java.lang.Integer,java.lang.Double>
        Parameters:
        key -
        value -
        Returns:
      • normalise

        public void normalise()
        normalises the vector to 1.
      • normalise

        public double normalise(double newsum)
        normalises the vector to newsum
        Parameters:
        the - value to which the element sum
        Returns:
        the old element sum
      • sum

        public double sum(double s)
        power sum of the elements
        Returns:
      • add

        public void add(SparseVector v)
        mutable add
        Parameters:
        v -
      • mult

        public void mult(int i,
                         double a)
        mutable mult
        Parameters:
        i - index
        a - value
      • factor

        public void factor(double a)
        mutable factorisation
        Parameters:
        a -
      • times

        public double times(SparseVector v)
        immutable scalar product
        Parameters:
        v -
        Returns:
        scalar product
      • hadamardProduct

        public void hadamardProduct(SparseVector v)
        mutable Hadamard product (elementwise multiplication)
        Parameters:
        v -
      • hadamardPower

        public void hadamardPower(double s)
        mutable Hadamard power
        Parameters:
        s -
      • add

        public void add(int i,
                        double a)
        mutable add
        Parameters:
        i -
        a -
      • getLength

        public final int getLength()
        get the length of the vector
        Returns:
      • setLength

        public final void setLength(int length)
        set the new length of the vector (regardless of the maximum index).
        Parameters:
        length -
      • copy

        public SparseVector copy()
        copy the contents of the sparse vector
        Returns:
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.AbstractMap<java.lang.Integer,java.lang.Double>
      • toStringDense

        public java.lang.String toStringDense()
        create string representation of dense equivalent.
        Returns:
      • getDense

        public double[] getDense()
        get dense represenation
        Returns:
      • max

        public double max()
        maximum element value
        Returns:
      • expSum

        public double expSum(int p)
        exponential sum, i.e., sum (elements^p)
        Parameters:
        p -
        Returns:
      • prune

        public void prune(double threshold)
        remove all elements whose magnitude is < threshold
        Parameters:
        threshold -

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.