Documentation of 'jsat.linear.RandomVector' Java class
RandomVector
jsat.linear

Class RandomVector

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<IndexValue>


    public abstract class RandomVector
    extends Vec
    Stores a Vector full of random values in constant O(1) space by re-computing all matrix values on the fly as need. This allows memory reduction and use when it is necessary to use the matrix with a large sparse data set, where some matrix values may never even be used - or used very infrequently.

    Because the values of the random vector are computed on the fly, the Random Vector can not be altered. If attempted, an exception will be thrown.
    See Also:
    Serialized Form
    • Constructor Detail

      • RandomVector

        public RandomVector(int length)
        Creates a new Random Vector object
        Parameters:
        length - the length of the vector
      • RandomVector

        public RandomVector(int length,
                            long seedMult)
        Creates a new Random Vector object
        Parameters:
        length - the length of the vector
        seedMult - a value to multiply with the seed used for each individual index. It should be a large value
    • Method Detail

      • get

        public double get(int index)
        Description copied from class: Vec
        Gets the value stored at a specific index in the vector
        Specified by:
        get in class Vec
        Parameters:
        index - the index to access
        Returns:
        the double value in the vector
      • set

        public void set(int index,
                        double val)
        Description copied from class: Vec
        Sets the value stored at a specified index in the vector
        Specified by:
        set in class Vec
        Parameters:
        index - the index to access
        val - the value to store in the index
      • length

        public int length()
        Description copied from class: Vec
        Returns the length of this vector
        Specified by:
        length in class Vec
        Returns:
        the length of this vector
      • multiply

        public void multiply(double c,
                             Matrix A,
                             Vec b)
        Description copied from class: Vec
        If this is vector a, this this computes b = b + c aT*A
        Overrides:
        multiply in class Vec
        Parameters:
        c - the constant factor to multiply by
        A - the matrix to multiple by
        b - the vector to mutate by adding the result to
      • mutableAdd

        public void mutableAdd(double c)
        Description copied from class: Vec
        Alters this vector such that this = this + c

        This method should be overloaded for a serious implementation.
        Overrides:
        mutableAdd in class Vec
        Parameters:
        c - a scalar constant to add to each value in this vector
      • mutableAdd

        public void mutableAdd(double c,
                               Vec b)
        Description copied from class: Vec
        Alters this vector such that this = this + c * b

        This method should be overloaded for a serious implementation.
        Overrides:
        mutableAdd in class Vec
        Parameters:
        c - a scalar constant
        b - the vector to add to this
      • mutablePairwiseMultiply

        public void mutablePairwiseMultiply(Vec b)
        Description copied from class: Vec
        Mutates this by multiplying each value by the value in b that has the same index.

        This method should be overloaded for a serious implementation.
        Overrides:
        mutablePairwiseMultiply in class Vec
        Parameters:
        b - the vector to pairwise multiply by
      • mutableMultiply

        public void mutableMultiply(double c)
        Description copied from class: Vec
        Mutates this *= c

        This method should be overloaded for a serious implementation.
        Overrides:
        mutableMultiply in class Vec
        Parameters:
        c - the constant to multiply by
      • mutablePairwiseDivide

        public void mutablePairwiseDivide(Vec b)
        Description copied from class: Vec
        Mutates this by dividing each value by the value in b that has the same index

        This method should be overloaded for a serious implementation.
        Overrides:
        mutablePairwiseDivide in class Vec
        Parameters:
        b - the vector to pairwise divide by
      • mutableDivide

        public void mutableDivide(double c)
        Description copied from class: Vec
        Mutates this /= c

        This method should be overloaded for a serious implementation.
        Overrides:
        mutableDivide in class Vec
        Parameters:
        c - the constant to divide by
      • sortedCopy

        public Vec sortedCopy()
        Description copied from class: Vec
        Returns a copy of this array with the values moved around so that they are in sorted order
        Overrides:
        sortedCopy in class Vec
        Returns:
        a new array in sorted order
      • min

        public double min()
        Description copied from class: Vec
        Returns the minimum value stored in this vector
        Overrides:
        min in class Vec
        Returns:
        the minimum value in this vector
      • max

        public double max()
        Description copied from class: Vec
        Returns the maximum value stored in this vector
        Overrides:
        max in class Vec
        Returns:
        the maximum value in this vector
      • isSparse

        public boolean isSparse()
        Description copied from class: Vec
        Indicates whether or not this vector is optimized for sparce computation, meaning that most values in the vector are zero - and considered implicit. Only non-zero values are stored.
        Specified by:
        isSparse in class Vec
        Returns:
        true if the vector is sparce, false otherwise.
      • clone

        public abstract Vec clone()
        Specified by:
        clone in class Vec
      • dot

        public double dot(Vec v)
        Description copied from class: Vec
        Computes the dot product between two vectors, which is equivalent to
        Σ thisi*vi

        This method should be overloaded for a serious implementation.
        Overrides:
        dot in class Vec
        Parameters:
        v - the other vector
        Returns:
        the dot product of this vector and another
      • canBeMutated

        public boolean canBeMutated()
        Description copied from class: Vec
        Indicates whether or not this vector can be mutated. If false, any method that contains "mutate" will not work.

        By default, this returns true
        Overrides:
        canBeMutated in class Vec
        Returns:
        true if the vector supports being altered, false other wise.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.