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

Class GrowableIndexedVector

  • 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 GrowableIndexedVector
    extends AVector
    implements ISparseVector
    Implementation for a sparse indexed vector that can accumulate index/value pairs efficiently (in order) Length grows if elements are added beyond the end of the vector
    See Also:
    Serialized Form
    • Method Detail

      • create

        public static GrowableIndexedVector create(java.lang.Iterable<?> iterable)
        Creates a GrowableIndexedVector from the specified Iterable object
        Parameters:
        iterable - An Iterable containing java.lang.Number instances
        Returns:
      • create

        public static GrowableIndexedVector create(AVector v)
        Creates a GrowableIndexedVector from the specified Iterable object
        Parameters:
        iterable - An Iterable containing java.lang.Number instances
        Returns:
      • create

        public static GrowableIndexedVector create(java.util.Iterator<?> iterator)
        Creates a GrowableIndexedVector from the specified Iterator object
        Parameters:
        iterator - An Iterator over java.lang.Number instances
        Returns:
      • createLength

        public static GrowableIndexedVector createLength(int len)
        Creates a zero-filled GrowableIndexedVector with the specified initial length
        Parameters:
        len -
        Returns:
      • 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
      • append

        public void append(int i,
                           double value)
        Adds a value to this GrawableIndexedVector at the specified position. Grows the vector if required.
        Parameters:
        i -
        value -
      • 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
      • append

        public void append(double v)
      • 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
      • 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
      • exactClone

        public AVector exactClone()
        Description copied from class: AVector
        Returns an exact clone of this vector, i.e. of the same type
        Specified by:
        exactClone in interface INDArray
        Specified by:
        exactClone in class AVector
        Returns:
        A clone of the original array
      • sparse

        public SparseIndexedVector 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
      • nonSparseElementCount

        public int nonSparseElementCount()
      • nonSparseValues

        public 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 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:
      • includesIndex

        public boolean includesIndex(int i)
      • 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
      • length

        public int length()
        Description copied from interface: IVector
        Returns the length of a vector, in terms of the number of elements. For Euclidean length, use magnitude() instead
        Specified by:
        length in interface IVector
        Specified by:
        length in class AVector
        Returns:
      • setLength

        public void setLength(int length)
        Sets the length of this vector.
      • 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 AVector
        Parameters:
        data - Array of double element values to check for equality
        offset - Offset into the data array
        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.
        Specified by:
        visitNonZero in class AVector

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.