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

Class ShiftedVec

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


    public class ShiftedVec
    extends Vec
    A wrapper for a vector that represents the vector added with a scalar value. This allows for using and altering the value added by a constant factor quickly. Mutable operations will alter the underling vector, and all operations will automatically be adjusted on a per element basis as needed. The most significant performance difference is in representing a sparse input sifted by a constant factor. Note, that when using a sparse base vector - the ShiftedVec will always return true for isSparse(), even if shifting makes all values non-zero
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      ShiftedVec(Vec base, double shift)
      Creates a new vector represented as base+shift
    • Constructor Detail

      • ShiftedVec

        public ShiftedVec(Vec base,
                          double shift)
        Creates a new vector represented as base+shift
        Parameters:
        base - the base vector to represent
        shift - the scalar shift to add to the base vector
    • Method Detail

      • getBase

        public Vec getBase()
        Returns:
        the base vector used by this object
      • setShift

        public void setShift(double shift)
        Directly alters the shift value used for this vector. The old sift is "forgotten" immediately.
        Parameters:
        shift - the new value to use for the additive scalar
      • getShift

        public double getShift()
        Returns:
        the additive scalar used to shift over the base value
      • embedShift

        public void embedShift()
        Embeds the current shift scalar into the base vector, modifying it and then setting the new shit to zero. This makes the base vector have the value represented by this ShiftedVec
      • 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
      • 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
      • increment

        public void increment(int index,
                              double val)
        Description copied from class: Vec
        Increments the value stored at a specified index in the vector
        Overrides:
        increment in class Vec
        Parameters:
        index - the index to access
        val - the value to store in the index
      • mutableAdd

        public void mutableAdd(Vec b)
        Description copied from class: Vec
        Alters this vector such that this = this + b
        Overrides:
        mutableAdd in class Vec
        Parameters:
        b - the vector to add to this
      • 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
      • 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
      • 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
      • 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
      • 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
      • zeroOut

        public void zeroOut()
        Description copied from class: Vec
        Zeroes out all values in this vector

        This method should be overloaded for a serious implementation.
        Overrides:
        zeroOut in class Vec
      • pNorm

        public double pNorm(double p)
        Description copied from class: Vec
        Returns the p-norm of this vector.
        Overrides:
        pNorm in class Vec
        Parameters:
        p - the norm type. 2 is a common value
        Returns:
        the p-norm of this vector
      • mean

        public double mean()
        Description copied from class: Vec
        Computes the mean value of all values stored in this vector
        Overrides:
        mean in class Vec
        Returns:
        the mean value
      • variance

        public double variance()
        Description copied from class: Vec
        Computes the variance of the values in this vector, which is Vec.standardDeviation()2
        Overrides:
        variance in class Vec
        Returns:
        the variance
      • standardDeviation

        public double standardDeviation()
        Description copied from class: Vec
        Computes the standard deviation of the values in this vector
        Overrides:
        standardDeviation in class Vec
        Returns:
        the standard deviation
      • kurtosis

        public double kurtosis()
        Description copied from class: Vec
        Computes the kurtosis of this vector, which is the 4th moment.
        Overrides:
        kurtosis in class Vec
        Returns:
        the kurtosis
      • 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
      • 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
      • median

        public double median()
        Description copied from class: Vec
        Returns the median value in this vector
        Overrides:
        median in class Vec
        Returns:
        the median
      • getNonZeroIterator

        public java.util.Iterator<IndexValue> getNonZeroIterator(int start)
        Description copied from class: Vec
        Returns an iterator that will go over the non zero values starting from the specified index in the given vector. The iterator does not support the Iterator.remove() method.

        This method should be overloaded for a serious implementation.
        Overrides:
        getNonZeroIterator in class Vec
        Parameters:
        start - the first index (inclusive) to start returning non-zero values from
        Returns:
        an iterator for the non zero index value pairs
      • 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.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.