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

Class ASparseVector

    • Method Detail

      • nonSparseElementCount

        public abstract int nonSparseElementCount()
        Returns the number of non-sparse elements in the sparse vector. This will be greater or equal to the number of non-zero elements
        Returns:
      • nonSparseValues

        public abstract AVector nonSparseValues()
        Description copied from interface: ISparseVector
        Returns the non-sparse elements as a compacted vector. May or may not be a view.
        Specified by:
        nonSparseValues in interface ISparseVector
        Returns:
      • nonSparseIndex

        public abstract 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
        Overrides:
        nonSparseIndex in class AVector
        Returns:
      • visitNonZero

        public double visitNonZero(IndexedElementVisitor elementVisitor)
        Description copied from class: AVector
        Visits all non-zero elements of this vector. Visitor may return a non-zero value to terminate early, which will return the given value. Returns 0.0 otherwise.
        Overrides:
        visitNonZero in class ASizedVector
      • includesIndex

        public abstract boolean includesIndex(int i)
        Returns true iff the sparse vector contains the index i
        Parameters:
        i -
        Returns:
      • roundToZero

        public ASparseVector roundToZero(double precision)
        Returns a vector after replacing all elements with absolute values less-than-or-equal to precision with zeros. May return either this vector or a new vector. If this vector is return, it may have been mutated.
        Parameters:
        precision -
        Returns:
      • copyTo

        public void copyTo(int offset,
                           double[] destData,
                           int destOffset,
                           int length)
        Description copied from class: AVector
        Copies a subset of this vector to a specified destination array offset
        Overrides:
        copyTo in class AVector
      • copyTo

        public void copyTo(int offset,
                           double[] destData,
                           int destOffset,
                           int length,
                           int stride)
        Description copied from class: AVector
        Copies a subset of this vector to a specified destination array offset using the given stride. Unsafe operation: performs no bounds checking
        Overrides:
        copyTo in class AVector
      • 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 AVector
      • isView

        public boolean isView()
        Description copied from class: AVector
        Returns true if this vector is of a view type that references other vectors / data.
        Specified by:
        isView in interface INDArray
        Overrides:
        isView in class AVector
      • reduce

        public double reduce(Op2 op,
                             double init)
        Description copied from interface: INDArray
        Reduces over all elements of the array in row-major order. Applies the operator to the initial/previous result at each step. Returns the final result.
        Specified by:
        reduce in interface INDArray
        Overrides:
        reduce in class AVector
      • reduce

        public double reduce(Op2 op)
        Description copied from interface: INDArray
        Reduces over all elements of the array in row-major order. Applies the operator to the previous result at each step. Returns the final result.
        Specified by:
        reduce in interface INDArray
        Overrides:
        reduce in class AVector
      • reduceSlices

        public final AVector reduceSlices(Op2 op,
                                          double init)
        Description copied from interface: INDArray
        Reduces each slice of the array by the given binary operator. Results are returned in a vector with one element for each slice. Uses the specified initial value for reduction of each slice.
        Specified by:
        reduceSlices in interface INDArray
        Overrides:
        reduceSlices in class AVector
      • distanceSquared

        public double distanceSquared(AVector v)
        Description copied from class: AVector
        Returns the squared Euclidean distance to another vector.
        Overrides:
        distanceSquared in class AVector
        Returns:
      • dotProduct

        public abstract 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
        Overrides:
        dotProduct in class AVector
        Returns:
      • dotProduct

        public final double dotProduct(ADenseArrayVector v)
        Description copied from class: AVector
        Returns the dot product of this vector with a target ADenseArrayVector.
        Overrides:
        dotProduct in class AVector
        Returns:
      • innerProduct

        public AVector innerProduct(AMatrix m)
        Description copied from class: AVector
        Computes the inner product of this vector with a matrix
        Overrides:
        innerProduct in class AVector
        Returns:
        a vector representing the inner product
      • isSparse

        public final boolean isSparse()
        Description copied from interface: INDArray
        Returns true if the array is in a sparse format
        Specified by:
        isSparse in interface INDArray
        Overrides:
        isSparse in class AbstractArray<java.lang.Double>
      • add

        public void add(AVector v)
        Description copied from class: AVector
        Adds another vector to this one
        Overrides:
        add in class AVector
      • addMultiple

        public void addMultiple(AVector src,
                                double factor)
        Description copied from class: AVector
        Adds a scaled multiple of another vector to this vector
        Overrides:
        addMultiple in class AVector
      • getSlices

        public java.util.List<java.lang.Double> getSlices()
        Description copied from interface: INDArray
        Returns a list of all major slices of this array. Returns a list of Double values if a 1-dimensional array is sliced, otherwise a list of INDArray instances
        Specified by:
        getSlices in interface INDArray
        Overrides:
        getSlices in class AVector
      • sparse

        public ASparseVector sparse()
        Description copied from interface: INDArray
        Coerces this INDArray to a sparse format, without changing its element values. May return the same INDArray if already sparse. May also mutate the internal structure of the original NDArray, or create a view over parts of the original INDArray. You should take a defensive copy of the original NDArray if any of this concerns you. The returned sparse array may not be fully mutable in all elements.
        Specified by:
        sparse in interface INDArray
        Overrides:
        sparse in class AVector
      • clone

        public AVector 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 AVector
      • toDoubleArray

        public double[] toDoubleArray()
        Description copied from interface: INDArray
        Copies the elements of this array to a new double[] array.
        Specified by:
        toDoubleArray in interface INDArray
        Overrides:
        toDoubleArray in class AVector
      • nonZeroCount

        public long nonZeroCount()
        Description copied from interface: INDArray
        Returns the number of non-zero elements in the array.
        Specified by:
        nonZeroCount in interface INDArray
        Overrides:
        nonZeroCount in class AVector
      • density

        public double density()
        Description copied from interface: ISparse
        Computes the density ratio of this sparse array (proportion of non-zero elements)
        Specified by:
        density in interface ISparse
        Overrides:
        density in class AbstractArray<java.lang.Double>
        Returns:
      • equals

        public boolean equals(AVector v)
        Description copied from class: AbstractArray
        Returns true if this array is exactly equal to a vector.
        Overrides:
        equals in class AVector
        Returns:
      • hasUncountable

        public boolean hasUncountable()
        Description copied from class: AbstractArray
        Returns true if any element is this array is NaN or infinite
        Specified by:
        hasUncountable in interface INDArray
        Overrides:
        hasUncountable in class AVector
        Returns:
        True if any element is this array is NaN or infinite, false otherwise
      • elementPowSum

        public double elementPowSum(double p)
        Returns the sum of all the elements raised to a specified power
        Specified by:
        elementPowSum in interface INDArray
        Overrides:
        elementPowSum in class AVector
        Returns:
      • elementAbsPowSum

        public double elementAbsPowSum(double p)
        Returns the sum of the absolute values of all the elements raised to a specified power
        Specified by:
        elementAbsPowSum in interface INDArray
        Overrides:
        elementAbsPowSum in class AVector
        Returns:
      • elementSum

        public double elementSum()
        Description copied from class: AVector
        Returns the sum of all elements in a vector
        Specified by:
        elementSum in interface INDArray
        Overrides:
        elementSum in class AVector
      • distanceL1

        public double distanceL1(AVector v)
        Description copied from class: AVector
        Returns the distance from this vector to another vector according to the L1 (Taxicab) norm.
        Overrides:
        distanceL1 in class AVector
        Returns:
      • distanceLinf

        public double distanceLinf(AVector v)
        Description copied from class: AVector
        Returns the distance from this vector to another vector according to the Linf norm.
        Overrides:
        distanceLinf in class AVector
        Returns:

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.