Documentation of 'mikera.vectorz.GrowableVector' Java class
GrowableVector
mikera.vectorz

Class GrowableVector

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


    public final class GrowableVector
    extends AVector
    Implements a growable vector, intended for incrementally building vectors Supports the following operations which etend the vector's length: - set (when used beyond array length) - append (adds a value to the end of the vector, extending length by one) Note that getting the underlying array or a subVector is unsafe, since the underlying array may be discarded as the vector is grown.
    See Also:
    Serialized Form
    • Constructor Detail

      • GrowableVector

        public GrowableVector(AVector v)
      • GrowableVector

        public GrowableVector(int initialCapacity)
      • GrowableVector

        public GrowableVector()
    • Method Detail

      • ofInitialCapacity

        public static GrowableVector ofInitialCapacity(int capacity)
        Returns a new, empty GrowableVector with the specified initial capacity
      • create

        public static GrowableVector create(java.lang.Iterable<java.lang.Number> iterable)
        Creates a GrowableVector by consuming all numbers in the given iterable object
        Parameters:
        iterable - An Iterable instance over java.lang.Number instances
        Returns:
      • create

        public static GrowableVector create(AVector values)
        Creates a GrowableVector containing a copy of the elements of a given vector
        Parameters:
        values -
        Returns:
      • wrap

        public static GrowableVector wrap(double[] values)
        Creates a GrowableVector initialised with the given double[] values
      • create

        public static GrowableVector create(java.util.Iterator<java.lang.Number> iterator)
        Creates a GrowableVector by consuming all numbers in the given iterator
        Parameters:
        iterable - An Iterable instance over java.lang.Number instances
        Returns:
      • 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:
      • currentCapacity

        public int currentCapacity()
      • ensureCapacity

        public void ensureCapacity(int capacity)
      • 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
      • 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
      • 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
      • 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
      • 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
      • append

        public void append(double v)
      • append

        public void append(double... vs)
      • append

        public void append(AVector v)
      • build

        public AVector build()
        Function to build a fixed-size vector containing a copy of data once the GrowableVector is constructed
        Returns:
      • clone

        public GrowableVector 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
      • clear

        public void clear()
      • exactClone

        public GrowableVector 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
      • 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
      • toVector

        public Vector toVector()
        Description copied from class: AVector
        Coerces this vector to the standard dense Vector format. May return the same vector is this is already a dense Vector, otherwise returns a Vector containing a new clone of the vector elements.
        Specified by:
        toVector in interface INDArray
        Overrides:
        toVector 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
      • getElements

        public void getElements(double[] dest,
                                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
      • 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
      • 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:
      • insert

        public void insert(int pos,
                           double value)
        Inserts a double value at the specified position in this GrowableVector. Increases the vector length by 1
        Parameters:
        pos -
        value -
      • create

        public static java.lang.Object create(double[] nonZeroValues)
      • 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.