Documentation of 'mikera.vectorz.impl.SparseHashedVector' Java class
SparseHashedVector
mikera.vectorz.impl

Class SparseHashedVector

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<java.lang.Double>, INDArray, ISparse, ISparseVector, IVector


    public class SparseHashedVector
    extends ASparseVector
    Hashed sparse vector, intended for large vectors with very few randomly positioned non-zero elements. Maintains hash elements for non-zero values only. This is useful (and maybe better than SparseIndexedVector) if random individual elements are likely to be changed, accessed or set back to zero on a frequent basis Mutable in all elements, but performance will be reduced if density is high. In general, if density is more than about 1% then a dense Vector is likely to be better.
    See Also:
    Serialized Form
    • Method Detail

      • create

        public static SparseHashedVector create(int length,
                                                Index index,
                                                Vector values)
        Create a SparseHashedVector with specified non-zero indexes and values.
      • createFromRow

        public static AVector createFromRow(AMatrix m,
                                            int row)
        Creates a SparseIndexedVector from a row of an existing matrix
      • nonSparseElementCount

        public int nonSparseElementCount()
        Description copied from class: ASparseVector
        Returns the number of non-sparse elements in the sparse vector. This will be greater or equal to the number of non-zero elements
        Specified by:
        nonSparseElementCount in class ASparseVector
        Returns:
      • isZero

        public boolean isZero()
        Description copied from class: AVector
        Returns true if this vector is a zero vector (all components zero)
        Specified by:
        isZero in interface INDArray
        Overrides:
        isZero in class ASparseVector
      • get

        public double get(int i)
        Description copied from interface: INDArray
        Returns the double value at the specified position in a 1D vector
        Specified by:
        get in interface INDArray
        Specified by:
        get in interface IVector
        Specified by:
        get in class AVector
      • unsafeGet

        public double unsafeGet(int i)
        Description copied from class: AVector
        Like get, but performs no bounds checking. Results are undefined if the index is out of range
        Overrides:
        unsafeGet in class AVector
      • isFullyMutable

        public boolean isFullyMutable()
        Description copied from class: AVector
        Returns true if this vector is fully mutable, i.e. can contain any unconstrained double values
        Specified by:
        isFullyMutable in interface INDArray
        Overrides:
        isFullyMutable in class AVector
      • isMutable

        public boolean isMutable()
        Description copied from class: AVector
        Returns true if this vector is mutable.
        Specified by:
        isMutable in interface INDArray
        Overrides:
        isMutable in class AVector
      • multiply

        public void multiply(double d)
        Description copied from class: AVector
        Multiplies the vector by a constant factor
        Specified by:
        multiply in interface INDArray
        Overrides:
        multiply in class AVector
        Parameters:
        d - Factor by which to multiply each component of the vector
      • dotProduct

        public double dotProduct(AVector v)
        Description copied from class: AVector
        Returns the dot product of this vector with another vector The vectors must have the same length: if not the result is undefined
        Specified by:
        dotProduct in class ASparseVector
        Returns:
      • dotProduct

        public double dotProduct(double[] data,
                                 int offset)
        Description copied from class: AVector
        Fast dot product with a double[] array. Performs no bounds checking. Likely to be faster than most other dot product operations
        Specified by:
        dotProduct in class AVector
      • dotProduct

        public double dotProduct(double[] data,
                                 int offset,
                                 int stride)
        Description copied from class: AVector
        Fast dot product with a double[] array and a stride. Performs no bounds checking. Likely to be faster than other dot product operations
        Overrides:
        dotProduct in class AVector
      • addMultipleToArray

        public void addMultipleToArray(double factor,
                                       int offset,
                                       double[] array,
                                       int arrayOffset,
                                       int length)
        Description copied from class: AVector
        Adds a multiple of a subvector of this vector into a double array at the specified offset
        Overrides:
        addMultipleToArray in class AVector
      • addToArray

        public void addToArray(int offset,
                               double[] array,
                               int arrayOffset,
                               int length)
        Description copied from class: AVector
        Adds a subvector of this vector into a double array at the specified offset
        Overrides:
        addToArray in class AVector
      • addToArray

        public void addToArray(double[] dest,
                               int offset,
                               int stride)
        Description copied from class: AVector
        Adds this vector to a double[] array, using the specified offset and stride into the destination array
        Overrides:
        addToArray in class AVector
      • addProductToArray

        public void addProductToArray(double factor,
                                      int offset,
                                      AVector other,
                                      int otherOffset,
                                      double[] array,
                                      int arrayOffset,
                                      int length)
        Overrides:
        addProductToArray in class AVector
      • addProductToArray

        public void addProductToArray(double factor,
                                      int offset,
                                      ADenseArrayVector other,
                                      int otherOffset,
                                      double[] array,
                                      int arrayOffset,
                                      int length)
        Description copied from class: AVector
        Adds the scaled elementwise product of this vector and another vector to the destimation array
        Overrides:
        addProductToArray in class AVector
      • getElements

        public void getElements(double[] array,
                                int offset)
        Description copied from interface: INDArray
        Copies all elements of this array a double array at the specified offset
        Specified by:
        getElements in interface INDArray
        Overrides:
        getElements in class AVector
      • copySparseValuesTo

        public void copySparseValuesTo(double[] array,
                                       int offset)
      • copyTo

        public void copyTo(AVector v,
                           int offset)
        Description copied from class: AVector
        Copies a the contents of a vector to a vector at the specified offset
        Overrides:
        copyTo in class AVector
      • set

        public void set(int i,
                        double value)
        Description copied from interface: INDArray
        Sets a value at a given position in a mutable 1D array
        Specified by:
        set in interface INDArray
        Specified by:
        set in interface IVector
        Specified by:
        set in class AVector
      • set

        public void set(AVector v)
        Description copied from class: AVector
        Sets the vector to equal the value of another vector
        Overrides:
        set in class AVector
      • unsafeSet

        public void unsafeSet(int i,
                              double value)
        Description copied from class: AVector
        Like set, but performs no bounds checking. Results are undefined if the index is out of range
        Overrides:
        unsafeSet in class AVector
      • addAt

        public void addAt(int i,
                          double value)
        Description copied from class: AVector
        Adds a value to a specific element of the vector This function does not perform bounds checking, i.e. is an unsafe operation
        Overrides:
        addAt in class AVector
      • maxAbsElement

        public double maxAbsElement()
        Description copied from class: AVector
        Returns the maximum absolute element value of a vector
        Overrides:
        maxAbsElement in class AVector
        Returns:
      • elementMax

        public double elementMax()
        Description copied from interface: INDArray
        Returns the maximum element value in this array. Throws an error if there are no elements.
        Specified by:
        elementMax in interface INDArray
        Overrides:
        elementMax in class AVector
      • elementMin

        public double elementMin()
        Description copied from interface: INDArray
        Returns the maximum element value in this array. Throws an error if there are no elements.
        Specified by:
        elementMin in interface INDArray
        Overrides:
        elementMin in class AVector
      • maxElementIndex

        public int maxElementIndex()
        Description copied from class: AVector
        Returns the index of the maximum element of a vector
        Overrides:
        maxElementIndex in class AVector
        Returns:
      • maxAbsElementIndex

        public int maxAbsElementIndex()
        Description copied from class: AVector
        Returns the index of the maximum absolute element of a vector
        Overrides:
        maxAbsElementIndex in class AVector
        Returns:
      • minElementIndex

        public int minElementIndex()
        Description copied from class: AVector
        Returns the index of the minimum element of a vector
        Overrides:
        minElementIndex in class AVector
      • nonZeroIndices

        public int[] nonZeroIndices()
        Description copied from class: AVector
        Return an int array specifying the positions in this vector which are non-zero
        Overrides:
        nonZeroIndices in class AVector
        Returns:
      • nonSparseIndex

        public Index nonSparseIndex()
        Description copied from class: AVector
        Returns an Index indicating which elements of this vector are defined as non-sparse. A sparse index must be zero. A non-sparse element may be zero, but is typically expected be non-zero.
        Specified by:
        nonSparseIndex in interface ISparseVector
        Specified by:
        nonSparseIndex in class ASparseVector
        Returns:
      • includesIndex

        public boolean includesIndex(int i)
        Description copied from class: ASparseVector
        Returns true iff the sparse vector contains the index i
        Specified by:
        includesIndex in class ASparseVector
        Returns:
      • equalsArray

        public boolean equalsArray(double[] data,
                                   int offset)
        Description copied from class: AVector
        Returns true if this vector exactly matches the elements in double[] array, starting from the specified offset
        Specified by:
        equalsArray in interface INDArray
        Overrides:
        equalsArray in class ASizedVector
        Parameters:
        data - Array of double element values to check for equality
        offset - Offset into the data array
        Returns:
      • clone

        public SparseIndexedVector clone()
        Description copied from class: AVector
        Clones the vector, creating a new mutable copy of all data. The clone is: - not guaranteed to be of the same type. - guaranteed to be fully mutable - guaranteed not to contain a reference (i.e. is a full deep copy)
        Specified by:
        clone in interface INDArray
        Specified by:
        clone in interface IVector
        Overrides:
        clone in class ASparseVector
      • validate

        public void validate()
        Description copied from interface: INDArray
        Validates the internal data structure of the INDArray. Throws an exception on failure. Failure indicates a serious bug and/or data corruption.
        Specified by:
        validate in interface INDArray
        Overrides:
        validate in class AVector

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.