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

Class DenseVector

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


    public class DenseVector
    extends Vec
    A vector implementation that is dense, meaning all values are allocated - even if their values will be implicitly zero.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      DenseVector(double[] array)
      Creates a new Dense Vector that uses the given array as its values.
      DenseVector(double[] array, int start, int end)
      Creates a new Dense Vector that uses the given array as its values.
      DenseVector(int length)
      Creates a new Dense Vector of zeros
      DenseVector(java.util.List<java.lang.Double> list)
      Creates a new vector of the length of the given list, and values copied over in order.
      DenseVector(Vec toCopy)
      Creates a new Dense Vector that contains a copy of the values in the given vector
    • Constructor Detail

      • DenseVector

        public DenseVector(int length)
        Creates a new Dense Vector of zeros
        Parameters:
        length - the length of the vector
      • DenseVector

        public DenseVector(java.util.List<java.lang.Double> list)
        Creates a new vector of the length of the given list, and values copied over in order.
        Parameters:
        list - the list of values to copy into a new vector
      • DenseVector

        public DenseVector(double[] array)
        Creates a new Dense Vector that uses the given array as its values. Its values will not be copied, and raw access and mutations tot he given array may occur.
        Parameters:
        array - the backing array to use for a new vector of the same length
      • DenseVector

        public DenseVector(double[] array,
                           int start,
                           int end)
        Creates a new Dense Vector that uses the given array as its values. Its values will not be copied, and raw access and mutations tot he given array may occur.
        Parameters:
        array - the backing array to use for a new vector
        start - the first index in the array, inclusive, to mark the start of the vector.
        end - the last index in the array, exclusive, to mark the end of the vector.
      • DenseVector

        public DenseVector(Vec toCopy)
        Creates a new Dense Vector that contains a copy of the values in the given vector
        Parameters:
        toCopy - the vector to copy
    • Method Detail

      • 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
      • 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
      • sum

        public double sum()
        Description copied from class: Vec
        Computes the sum of the values in this vector
        Overrides:
        sum in class Vec
        Returns:
        the sum of this vector's values
      • median

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

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

        public DenseVector 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
      • 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
      • 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
      • 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
      • mutableSubtract

        public void mutableSubtract(double c)
        Description copied from class: Vec
        Alters this vector such that this = this - c
        Overrides:
        mutableSubtract in class Vec
        Parameters:
        c - the scalar constant to subtract from all values in this vector
      • 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
      • 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
      • pNormDist

        public double pNormDist(double p,
                                Vec y)
        Description copied from class: Vec
        Returns the p-norm distance between this and another vector y.
        Overrides:
        pNormDist in class Vec
        Parameters:
        p - the distance type. 2 is the common value
        y - the other vector to compare against
        Returns:
        the p-norm distance
      • 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
      • normalize

        public void normalize()
        Description copied from class: Vec
        Mutates this vector to be normalized by the L2 norm
        Overrides:
        normalize in class Vec
      • 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
      • 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
      • equals

        public boolean equals(java.lang.Object obj)
        Overrides:
        equals in class Vec
      • equals

        public boolean equals(java.lang.Object obj,
                              double range)
        Overrides:
        equals in class Vec
      • toDenseVec

        public static DenseVector toDenseVec(double... array)
        Returns a new dense vector backed by the given array. This is a weak reference, the given array should no longer be altered - as it will effect the values of the dense vector.
        Parameters:
        array - the array to use as the backing of a dense vector
        Returns:
        a Dense Vector that is backed using the given array
      • arrayCopy

        public double[] arrayCopy()
        Description copied from class: Vec
        Creates a new array that contains all the values of this vector in the appropriate indices
        Overrides:
        arrayCopy in class Vec
        Returns:
        a new array that is a copy of 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.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.