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

Class AVector

    • Constructor Summary

      Constructors 
      Constructor and Description
      AVector() 
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      void abs()
      Replaces all elements of this array with their absolute values, according to Math.abs(double)
      AVector absCopy()
      Returns a copy of the array with the abs operator applied to each element
      void absDiff(AVector a) 
      void absDiff(double v) 
      void absDiff(INDArray a)
      Sets this array to the absolute values of the difference between this array and another
      INDArray absDiffCopy(INDArray a)
      Returns an array containing the absolute values of the difference between this array and another
      void add(ADenseArrayVector v)
      Add a DenseArrayVector to this vector
      void add(AVector v)
      Adds another vector to this one
      void add(AVector src, int srcOffset)
      Adds part another vector to this one, starting at the specified offset in the source vector
      void add(double constant)
      Adds a double value to all elements in this array.
      void add(double[] data)
      Adds the values from a double[] array to this vector
      void add(double[] data, int offset)
      Adds to this vector from a given double array.
      void add(INDArray a)
      Adds all the elements of another array to this array, in an elementwise order.
      void add(int offset, AVector src)
      Adds another vector into this one, at the specified offset
      void add(int offset, AVector src, int srcOffset, int length)
      Adds a segment of another vector into this one, at the specified offset
      void addAt(int i, double v)
      Adds a value to a specific element of the vector This function does not perform bounds checking, i.e.
      void addAt(long i, double v)
      Adds to a mutable array, indexed by element position in row major order.
      AVector addCopy(AVector a)
      Adds a vector element-wise to this vector, returning a new vector.
      AVector addCopy(double a)
      Creates a new array equal to this array with a constant value added to every element
      INDArray addCopy(INDArray a)
      Creates a new array equal to the sum of this array with another array.
      void addInnerProduct(AMatrix a, AVector b)
      Adds the inner product of the arguments (matrix a and vector b) to this vector.
      void addInnerProduct(AMatrix a, INDArray b)
      Adds the inner product of a matrix and an array to this array
      void addInnerProduct(AVector a, AMatrix b)
      Adds the inner product of the arguments (vector a and matrix b) to this vector.
      void addInnerProduct(INDArray a, INDArray b)
      Adds the inner product of two arrays to this array.
      void addMultiple(AVector src, double factor)
      Adds a scaled multiple of another vector to this vector
      void addMultiple(AVector source, Index sourceToDest, double factor)
      Adds a source vector to this vector at the specified indexes which should map from source->this
      void addMultiple(AVector src, int srcOffset, double factor)
      Adds a multiple of a subvector of another vector to this vector.
      void addMultiple(INDArray src, double factor)
      Adds a scaled multiple of another array to this array
      void addMultiple(int offset, AVector v, double factor) 
      void addMultiple(int offset, AVector src, int srcOffset, int length, double factor) 
      void addMultiple(SparseIndexedVector src, double factor)
      Adds a scaled multiple of a sparse indexed vector to this vector
      void addMultiple(Vector source, Index sourceToDest, double factor)
      Adds source vector to this vector at the specified indexes which should map from source->this
      AVector addMultipleCopy(AVector src, double factor)
      Returns the sum of this vector with a scaled multiple of a second vector.
      void addMultipleSparse(AVector v, double factor)
      Adds a multiple of a source vector to the non-sparse elements of this vector only
      void addMultipleSparse(INDArray a, double factor)
      Adds a multiple of the source array to the non-sparse elements of this array
      void addMultipleToArray(double factor, double[] array, int arrayOffset)
      Adds a multiple of this vector into a double array at the specified offset
      void addMultipleToArray(double factor, int offset, double[] array, int arrayOffset, int length)
      Adds a multiple of a subvector of this vector into a double array at the specified offset
      void addPower(INDArray src, double exponent)
      Adds an array with all elements of the source array raised to the specified power
      void addPower(INDArray src, double exponent, double factor)
      Adds an array with all elements raised to the specified power and scaled by the given factor
      void addProduct(AVector a, AVector b)
      Adds the element-wise product of two vectors to this vector.
      void addProduct(AVector a, AVector b, double factor)
      Adds the element-wise product of two vectors and a constant factor to this vector.
      void addProduct(AVector a, int aOffset, AVector b, int bOffset, double factor)
      Adds the scaled elementwise product of two vectors to this vector
      AVector addProductCopy(AVector a, AVector b)
      Adds the element-wise product of two vectors to this vector.
      AVector addProductCopy(AVector a, AVector b, double factor)
      Adds the element-wise product of two vectors and a constant factor to this vector.
      void addProductToArray(double factor, int offset, ADenseArrayVector other, int otherOffset, double[] dest, int destOffset, int length)
      Adds the scaled elementwise product of this vector and another vector to the destimation array
      void addProductToArray(double factor, int offset, AVector other, int otherOffset, double[] array, int arrayOffset, int length) 
      void addSparse(AVector v)
      Adds the corresponding elements of the source vector to the non-sparse elements of this vector
      void addSparse(double c)
      Adds to the non-sparse elements of this array
      void addToArray(double[] array, int offset)
      Adds this vector to a double[] array, starting at the specified offset.
      void addToArray(double[] dest, int destOffset, int destStride)
      Adds this vector to a double[] array, using the specified offset and stride into the destination array
      void addToArray(int offset, double[] array, int arrayOffset, int length)
      Adds a subvector of this vector into a double array at the specified offset
      void addWeighted(AVector v, double factor)
      Updates a weighted average of this vector with another vector
      double angle(AVector v)
      Returns the Euclidean angle between this vector and another vector
      void applyOp(IOperator op)
      Applies a unary operator to all elements of the array (in-place)
      void applyOp(Op op)
      Applies a unary operator to all elements of the array (in-place)
      void applyOp(Op2 op, AVector b)
      Applies a binary operator to this vector and a second vector
      void applyOp(Op2 op, double b)
      Applies a binary operator to this array and a double value.
      void applyOp(Op2 op, INDArray b)
      Applies a binary operator to this array and a second array.
      AVector applyOpCopy(Op op)
      Applies a unary operator to all elements of the array (creating a new array)
      double[] asDoubleArray()
      Returns the underlying double array representing the densely packed elements of this array.
      java.util.List<java.lang.Double> asElementList()
      Returns a List containing all elements of this array
      AVector asVector()
      Constructs a view of all elements in the array as a single vector in row-major order.
      INDArray broadcast(int... targetShape)
      Returns a view of this array broadcasted up to a larger shape
      AMatrix broadcastLike(AMatrix target)
      Broadcasts an array to match the shape of the target matrix
      AVector broadcastLike(AVector target)
      Broadcasts an array to match the shape of the target vector
      INDArray broadcastLike(INDArray target)
      Broadcasts an array to match the shape of the target
      int checkIndex(int i)
      Utility function to check an index and throw an exception in not in bounds.
      int checkLength(int length)
      Checks that a vector is the specified length, throws an exception if not.
      int checkRange(int offset, int length)
      Utility function to check vector range and throw an exception if not valid.
      void clamp(double min, double max)
      Clamps all values in the vector to a given range
      void clampMax(double max) 
      void clampMin(double min) 
      AVector clone()
      Clones the vector, creating a new mutable copy of all data.
      int compareTo(AVector a)
      Compares this vector to another vector
      int compareTo(INDArray a) 
      AVector copy()
      Returns a defensive copy of the array data.
      void copyTo(ADenseArrayVector dest, int destOffset)
      Copies a the contents of a vector to a vector at the specified offset
      void copyTo(AVector dest, int destOffset)
      Copies a the contents of a vector to a vector at the specified offset
      void copyTo(int offset, AVector dest, int destOffset, int length)
      Copies a subset of this vector to a vector at the specified offset
      void copyTo(int offset, double[] dest, int destOffset, int length)
      Copies a subset of this vector to a specified destination array offset
      void copyTo(int offset, double[] dest, int destOffset, int length, int stride)
      Copies a subset of this vector to a specified destination array offset using the given stride.
      void crossProduct(AVector a)
      Computes the crossProduct of this vector with another vector, and stores the result in this vector.
      void crossProduct(Vector3 a)
      Computes the crossProduct of this vector with another vector, and stores the result in this vector.
      AVector dense()
      Coerces this INDArray to a dense format, without changing its element values.
      Vector denseClone()
      Creates a fully mutable dense clone of this array.
      int dimensionality()
      Returns the dimensionality of the array (i.e.
      double distance(AVector v)
      Returns the Euclidean distance to another vector.
      double distanceL1(AVector v)
      Returns the distance from this vector to another vector according to the L1 (Taxicab) norm.
      double distanceLinf(AVector v)
      Returns the distance from this vector to another vector according to the Linf norm.
      double distanceSquared(AVector v)
      Returns the squared Euclidean distance to another vector.
      void divide(AVector v) 
      void divide(double factor)
      Divides all elements by a given factor
      void divide(double[] data, int offset)
      Divides the elements in this vector by corresponding elements in the target array
      void divide(INDArray a)
      Divides all elements in place by the equivalent elements in a second array
      AVector divideCopy(AVector a)
      Divides this vector element-wise by another vector, returning a new vector.
      AVector divideCopy(double d)
      Returns a copy of the array with all elements divided by a single constant value
      INDArray divideCopy(INDArray a)
      Divides all elements by the equivalent elements in a second array.
      void divideTo(double[] data, int offset)
      Divides the elements in the target array by corresponding elements in this vector
      double dotProduct(ADenseArrayVector v)
      Returns the dot product of this vector with a target ADenseArrayVector.
      double dotProduct(AVector v)
      Returns the dot product of this vector with another vector The vectors must have the same length: if not the result is undefined
      double dotProduct(AVector v, Index ix)
      Returns the dotProduct of this vector with the elements of another vector mapped to specified indexes in this vector.
      abstract double dotProduct(double[] data, int offset)
      Fast dot product with a double[] array.
      double dotProduct(double[] data, int offset, int stride)
      Fast dot product with a double[] array and a stride.
      double elementAbsPowSum(double exponent)
      Returns the sum of the absolute values of all the elements raised to a specified power
      long elementCount()
      Returns the total number of elements in this array.
      java.util.Iterator<java.lang.Double> elementIterator()
      Returns an iterator over all elements in this array, in row-major order
      double elementMax()
      Returns the maximum element value in this array.
      double elementMaxAbs()
      Returns the maximum absolute element value in this vector.
      double elementMin()
      Returns the maximum element value in this array.
      double elementPowSum(double exponent)
      Returns the sum of all the elements raised to a specified power
      double elementProduct()
      Returns the product of all elements in the array.
      boolean elementsEqual(double value)
      Returns true if all elements are equal to a specific value
      double elementSquaredSum()
      Returns the sum of squared elements in this array.
      double elementSum()
      Returns the sum of all elements in a vector
      boolean epsilonEquals(AVector v)
      Returns true if this vector is approximately equal to another vector.
      boolean epsilonEquals(AVector v, double tolerance) 
      boolean epsilonEquals(INDArray a, double tolerance)
      Tests is this array is approximately equal to another array, up to a given tolerance (epsilon) The arrays must have the same shape
      boolean equals(AVector v)
      Returns true if this array is exactly equal to a vector.
      boolean equals(INDArray v)
      Checks if two arrays are equal exactly in terms of both value and shape Element equality checks are consistent with compareTo
      boolean equals(java.lang.Object o)
      Test for equality on vectors.
      boolean equalsArray(double[] data)
      Returns true if this vector exactly matches a double[] array.
      boolean equalsArray(double[] data, int offset)
      Returns true if this vector exactly matches the elements in double[] array, starting from the specified offset
      abstract AVector exactClone()
      Returns an exact clone of this vector, i.e.
      void fill(double value)
      Fills the entire vector with a given value
      void fillRange(int offset, int length, double value) 
      double get()
      Returns the double value of a scalar array
      double get(AIndex ix)
      Returns the double value at the specified position in the array
      double get(int... indexes)
      Returns the double value at the specified index position in an array
      abstract double get(int i)
      Returns the double value at the specified position in a 1D vector
      double get(int x, int y)
      Returns the double value at the specified position in a 2D matrix
      double get(long i)
      Returns the double value at the specified position in a 1D vector
      double get(long[] indexes)
      Returns the double value at the specified index position in an array
      double getElement(long i)
      Gets a specific element of this array, indexed in row-major order
      void getElements(double[] dest, int offset)
      Copies all elements of this array a double array at the specified offset
      void getElements(double[] dest, int destOffset, int[] indices)
      Gets the elements in this vector from the specified indices, storing at the specified offset in the destination array
      void getElements(java.lang.Object[] dest, int offset)
      Copies all elements of this array into an object array at the specified offset
      long[] getLongShape()
      Returns the shape of the array as an array of longs.
      int[] getShape()
      Returns the shape of the array as an array of ints.
      int getShape(int dim)
      Returns the dimension size for a specific dimension in the array's shape
      int[] getShapeClone()
      Returns the shape of the array as an array of ints, guaranteed to be a new array i.e.
      java.util.List<java.lang.Double> getSlices()
      Returns a list of all major slices of this array.
      AVector getTranspose()
      Returns the transpose of this array.
      AVector getTransposeCopy()
      Returns a transposed copy of the array.
      AVector getTransposeView()
      Returns a transposed view of the array.
      int hashCode()
      Computes the hashcode of a vector.
      boolean hasUncountable()
      Returns true if any element is this array is NaN or infinite
      AVector immutable()
      Creates an immutable copy of a vector
      Scalar innerProduct(ADenseArrayVector v)
      Overloaded inner product for dense array vector argument
      AVector innerProduct(AMatrix m)
      Computes the inner product of this vector with a matrix
      AVector innerProduct(AScalar s)
      Computes the inner product of this vector with a scalar
      AScalar innerProduct(AVector v)
      Computes the inner product of this vector with another vector
      AVector innerProduct(double a)
      Calculates the inner product of this array with a double value
      INDArray innerProduct(INDArray a)
      Calculates the inner product of this array with another array.
      void interpolate(AVector v, double alpha)
      Interpolates between this vector and a second vector, according to the ratio alpha.
      boolean isElementConstrained()
      Returns true if this array has some constraints on element values
      boolean isFullyMutable()
      Returns true if this vector is fully mutable, i.e.
      boolean isMutable()
      Returns true if this vector is mutable.
      boolean isRangeZero(int start, int length)
      Returns true if a sub-vector range is completely zero.
      boolean isSameShape(AVector a)
      Returns true if this vector is exactly the same shape as another vector.
      boolean isSameShape(INDArray a)
      Returns true if this array is the same shape as another array
      boolean isUnitLengthVector()
      Returns true if the vector has unit length
      boolean isUnitLengthVector(double tolerance)
      Returns true if the vector has unit length with the given tolerance
      boolean isView()
      Returns true if this vector is of a view type that references other vectors / data.
      boolean isZero()
      Returns true if this vector is a zero vector (all components zero)
      java.util.Iterator<java.lang.Double> iterator() 
      AVector join(AVector second) 
      AVector join(INDArray b)
      Returns a new vector that refers to this vector joined to a second vector.
      INDArray join(INDArray a, int dimension)
      Joins an array with another array along a specified dimension.
      abstract int length()
      Returns the length of a vector, in terms of the number of elements.
      void log()
      Computes the natural logarithm (in-place) for all array elements
      void logistic()
      Computes the logistic function for every element in this vector.
      double magnitude()
      Returns the magnitude (Euclidean length) of the vector
      double magnitudeSquared()
      Computes the squared magnitude (sum of squares) for this vector
      double maxAbsElement()
      Returns the maximum absolute element value of a vector
      int maxAbsElementIndex()
      Returns the index of the maximum absolute element of a vector
      double maxElement()
      Returns the maximum element value in a vector.
      int maxElementIndex()
      Returns the index of the maximum element of a vector
      double minElement()
      Returns the minimum element value in a vector.
      int minElementIndex()
      Returns the index of the minimum element of a vector
      void multiply(ADenseArrayVector v) 
      void multiply(AVector v)
      Multiplies this vector by another vector, elementwise.
      void multiply(double factor)
      Multiplies the vector by a constant factor
      void multiply(double[] data, int offset)
      Multiplies the elements in this vector by corresponding elements in the target array
      void multiply(INDArray a)
      Multiplies all elements by the equivalent elements in a second array, i.e.
      AVector multiplyCopy(AVector a)
      Multiplies a vector element-wise with this vector, returning a new vector.
      AVector multiplyCopy(double d)
      Returns a copy of the array with all elements multiplied by a single constant value
      INDArray multiplyCopy(INDArray a)
      Multiplies all elements by the equivalent elements in a second array, i.e.
      void multiplyTo(double[] dest, int offset)
      Multiplies the elements in the target array by corresponding elements in this vector
      AVector mutable()
      Coerces to a mutable version of a vector.
      void negate()
      Negates all emlements of this vector in place.
      AVector negateCopy()
      Negates all elements in the array, returning a new array
      Index nonSparseIndex()
      Returns an Index indicating which elements of this vector are defined as non-sparse.
      long nonZeroCount()
      Returns the number of non-zero elements in the array.
      int[] nonZeroIndices()
      Return an int array specifying the positions in this vector which are non-zero
      double[] nonZeroValues()
      Return an double array specifying the values in this vector which are non-zero
      double normalise()
      Normalises this vector to a magnitude of 1.0 Has no effect on a zero-length vector (i.e.
      AVector normaliseCopy()
      Returns a copy of this vector normalised to a Euclidean length of 1.0 Has no effect on a zero-length vector (i.e.
      double normaliseMaxAbsElement()
      Normalises so that the maximum absolute element is 1.0 Returns the previous maximum absolute element.
      AMatrix outerProduct(AVector a)
      Computes the outer product of this vector with another vector
      INDArray outerProduct(INDArray a)
      Calculates the outer product of this array with another array.
      void pow(double exponent)
      Raises all elements of the array to a specified power in place
      void projectToPlane(AVector normal, double distance)
      Projects the vector to the plane defined by: x.normal=distance
      void reciprocal()
      Computes the reciprocal of all elements in this vector.
      AVector reciprocalCopy()
      Computes the reciprocal of all elements in this vector.
      double reduce(Op2 op)
      Reduces over all elements of the array in row-major order.
      double reduce(Op2 op, double init)
      Reduces over all elements of the array in row-major order.
      AVector reduceSlices(Op2 op)
      Reduces each vector slice of the array by the given binary operator Reduces down to a single vector
      AVector reduceSlices(Op2 op, double init)
      Reduces each slice of the array by the given binary operator.
      AVector reorder(int[] order)
      Returns a re-ordered array by taking the specified order of slices along dimension 0
      AVector reorder(int dim, int[] order)
      Returns a re-ordered array by taking the specified order of slices along a given dimension May or may not use views of underlying slices (i.e.
      INDArray reshape(int... dimensions)
      Returns a new array by rearranging the elements of this array into the desired shape Truncates or zero-pads the elements as required to fill the new shape
      AVector rotateCopy(int shift)
      Rotates a vector by the specified number of elements, wrapping around element values.
      AVector rotateView(int shift)
      Rotates a vector by the specified number of elements, wrapping around element values.
      INDArray rotateView(int dimension, int shift)
      Returns rotated view of this array
      void scale(AVector v)
      Scales the vector by another vector of the same size
      void scaleAdd(double factor, AVector v)
      Scales this vector then adds another vector
      void scaleAdd(double factor, AVector b, double bfactor, double constant)
      Scales all elements of the array by a given double value, adds a scaled second vector and adds a constant value
      void scaleAdd(double factor, double constant)
      Scales this vector and adds a constant to every element
      void scaleAdd(double factor, INDArray b, double bfactor, double constant)
      Scales all elements of the array by a given double value, adds a scaled second array and adds a constant value
      AVector scaleCopy(double d)
      Scales all elements of the array by a given double value, returning a new array
      double scaleToMagnitude(double targetMagnitude)
      Scales the vector up to a specific target magnitude
      AVector select(int... indices)
      Selects a subset of indices from a vector
      AVector selectClone(int... inds)
      Selects a subset of indices from a vector, returning a mutable clone of data
      AVector selectView(int... indices)
      Selects a subset of indices from a vector, returning a view
      void set(ADenseArrayVector v)
      Sets the vector equal to the value of an ADenseArrayVector
      void set(AVector src)
      Sets the vector to equal the value of another vector
      void set(AVector source, Index indexes)
      sets the vector using values indexed from another vector
      void set(AVector src, int srcOffset)
      Set the vector equal to an offset into another vector
      void set(AVector source, int[] indexes)
      sets the vector using values indexed from another vector
      void set(double a)
      Sets all elements of an array to a specific double value
      void set(INDArray a)
      Sets this array to the element values contained in another array.
      void set(int[] indexes, double value)
      Sets the element at the given indexed position in a mutable array
      abstract void set(int i, double value)
      Sets a value at a given position in a mutable 1D array
      void set(long[] indexes, double value)
      Sets the element at the given indexed position in a mutable array
      void set(long i, double value) 
      void setApplyOp(Op op, AVector a)
      Sets this vector to the result of applying an operator to another vector
      void setApplyOp(Op op, double a)
      Sets this vector to the result of applying an operator to a double value
      void setApplyOp(Op op, INDArray a)
      Sets this array to the result of applying an operation to a source array
      void setElements(double... data)
      Sets all elements in an array using the given double values
      void setElements(double[] data, int offset)
      Sets all elements in an array using the given double values
      void setElements(int pos, double[] values, int offset, int length)
      Sets elements in an array using the given double values.
      void setInnerProduct(AMatrix a, AVector b)
      Sets this vector to the inner product of the arguments (matrix a and vector b).
      void setInnerProduct(AVector a, AMatrix b)
      Sets this vector to the inner product of the arguments (vector a and matrix b) to this vector.
      void setInnerProduct(INDArray a, INDArray b)
      Sets this array to the inner product of two arrays.
      void setMultiple(AVector a, AVector b)
      Sets this vector to the element-wise product of two otehr vectors
      void setMultiple(AVector a, double b)
      Sets this vector to be a multiple of another vector
      void setMultiple(INDArray a, double b)
      Sets this array to be the multiple of another array.
      void setMultiple(INDArray a, INDArray b)
      Sets this array to the element-wise multiple of two arrays.
      void setSparse(AVector src)
      Sets the non-sparse elements of this vector to the corresponding elements of another vector
      void setSparse(double v)
      Sets the non-sparse elements of this array to the specified value May throw an exception if non-sparse elements are not mutable
      void setSparse(INDArray src)
      Sets the non-sparse elements of this array to the corresponding elements of the source array
      AVector shiftCopy(int shift)
      Shifts a vector by the specified number of elements, filling with zeros.
      void signum()
      Calculates the signum of all elements of this mutable array Sets each component of the array to its sign value (-1, 0 or 1)
      AScalar slice(int position)
      Returns the specified major slice of this array as a view (slice along dimension 0) 0 dimensional slice results are permitted, but attempting to slice a 0 dimensional array will result in an error.
      AScalar slice(int dimension, int index)
      Returns a slice view of this array along the specified dimension
      int sliceCount()
      Returns the number of major slices in this array (i.e.
      java.lang.Object sliceValue(int i)
      Returns the value of a major slice of this array (slice along dimension 0) Like 'slice', except returns a Double value for slices of 1D vectors
      void softmax()
      Computes the softmax function over this vector, mutating this vector
      AVector softmaxCopy()
      Computes the softmax function over this vector, returning a new mutable vector
      AVector sparse()
      Coerces this INDArray to a sparse format, without changing its element values.
      AVector sparseClone()
      Clones the vector into a sparse mutable format
      AVector sqrtCopy()
      Computes the square root for each element in this vector, returning a new vector.
      void square()
      Squares all elements of the array in place
      AVector squareCopy()
      Squares all elements of the array, returning a new array
      void sub(AVector v)
      Subtracts a vector from this vector
      void sub(INDArray a)
      Subtracts all the elements of another array from this array, in an elementwise order.
      AVector subArray(int[] offsets, int[] shape)
      Returns a subarray view of a larger array
      void subAt(int i, double v)
      Subtracts a value from the specified element in this vector.
      AVector subCopy(AVector a)
      Subtracts a vector element-wise from this vector, returning a new vector.
      INDArray subCopy(INDArray a)
      Creates a new array equal to the subtraction of another array from this array
      void subMultiple(AVector v, double factor)
      Subtracts a scaled multiple of another vector from this vector
      AVector subVector(int offset, int length)
      Obtains a sub-vector view that refers to this vector.
      void tanh()
      Computes the tanh of every element in this vector.
      double[] toDoubleArray()
      Copies the elements of this array to a new double[] array.
      void toDoubleBuffer(java.nio.DoubleBuffer dest)
      Copies the elements of this INDArray to the specified double buffer.
      java.util.List<java.lang.Double> toList()
      Returns a java.util.List instance containing all elements of this vector
      AVector toNormal()
      Creates a new mutable vector representing the normalised value of this vector Returns null if the vector cannot be normalised (i.e.
      INDArray[] toSliceArray()
      Copies the slices of this array to a new INDArray[] Throws an error if the array has no slices (i.e.
      java.lang.String toString() 
      java.lang.String toStringFull() 
      Vector toVector()
      Coerces this vector to the standard dense Vector format.
      AVector tryEfficientJoin(AVector second)
      Attempts to perform an efficient join with a second vector.
      double unsafeGet(int i)
      Like get, but performs no bounds checking.
      void unsafeSet(int i, double value)
      Like set, but performs no bounds checking.
      void validate()
      Validates the internal data structure of the INDArray.
      abstract double visitNonZero(IndexedElementVisitor elementVisitor)
      Visits all non-zero elements of this vector.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • AVector

        public AVector()
    • Method Detail

      • length

        public abstract 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
        Returns:
      • get

        public abstract 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 AbstractArray<java.lang.Double>
      • set

        public abstract 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
        Overrides:
        set in class AbstractArray<java.lang.Double>
      • get

        public double get(long i)
        Description copied from interface: INDArray
        Returns the double value at the specified position in a 1D vector
        Specified by:
        get in interface INDArray
        Overrides:
        get in class AbstractArray<java.lang.Double>
      • set

        public void set(long i,
                        double value)
      • getElement

        public final double getElement(long i)
        Description copied from interface: INDArray
        Gets a specific element of this array, indexed in row-major order
        Specified by:
        getElement in interface INDArray
        Returns:
        The element value
      • set

        public void set(int[] indexes,
                        double value)
        Description copied from interface: INDArray
        Sets the element at the given indexed position in a mutable array
        Specified by:
        set in interface INDArray
      • set

        public void set(long[] indexes,
                        double value)
        Description copied from interface: INDArray
        Sets the element at the given indexed position in a mutable array
        Specified by:
        set in interface INDArray
        Overrides:
        set in class AbstractArray<java.lang.Double>
      • unsafeSet

        public void unsafeSet(int i,
                              double value)
        Like set, but performs no bounds checking. Results are undefined if the index is out of range
        Parameters:
        i -
        value -
      • unsafeGet

        public double unsafeGet(int i)
        Like get, but performs no bounds checking. Results are undefined if the index is out of range
        Parameters:
        i -
        value -
      • get

        public final double get(int x,
                                int y)
        Description copied from interface: INDArray
        Returns the double value at the specified position in a 2D matrix
        Specified by:
        get in interface INDArray
        Specified by:
        get in class AbstractArray<java.lang.Double>
      • dimensionality

        public final int dimensionality()
        Description copied from interface: INDArray
        Returns the dimensionality of the array (i.e. the number of dimensions in the array shape) e.g. 0 for a scalar, 1 for a vector, 2 for a matrix etc.
        Specified by:
        dimensionality in interface INDArray
      • get

        public final double get(int... indexes)
        Description copied from interface: INDArray
        Returns the double value at the specified index position in an array
        Specified by:
        get in interface INDArray
      • get

        public final double get(long[] indexes)
        Description copied from interface: INDArray
        Returns the double value at the specified index position in an array
        Specified by:
        get in interface INDArray
        Overrides:
        get in class AbstractArray<java.lang.Double>
      • get

        public final double get(AIndex ix)
        Description copied from interface: INDArray
        Returns the double value at the specified position in the array
        Specified by:
        get in interface INDArray
        Overrides:
        get in class AbstractArray<java.lang.Double>
      • get

        public double get()
        Description copied from interface: INDArray
        Returns the double value of a scalar array
        Specified by:
        get in interface INDArray
        Specified by:
        get in class AbstractArray<java.lang.Double>
      • slice

        public AScalar slice(int position)
        Description copied from interface: INDArray
        Returns the specified major slice of this array as a view (slice along dimension 0) 0 dimensional slice results are permitted, but attempting to slice a 0 dimensional array will result in an error.
        Specified by:
        slice in interface INDArray
      • sliceValue

        public java.lang.Object sliceValue(int i)
        Description copied from interface: INDArray
        Returns the value of a major slice of this array (slice along dimension 0) Like 'slice', except returns a Double value for slices of 1D vectors
        Specified by:
        sliceValue in interface INDArray
        Overrides:
        sliceValue in class AbstractArray<java.lang.Double>
      • slice

        public AScalar slice(int dimension,
                             int index)
        Description copied from interface: INDArray
        Returns a slice view of this array along the specified dimension
        Specified by:
        slice in interface INDArray
      • sliceCount

        public int sliceCount()
        Description copied from interface: INDArray
        Returns the number of major slices in this array (i.e. the size of dimension 0)
        Specified by:
        sliceCount in interface INDArray
      • 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 AbstractArray<java.lang.Double>
      • getShape

        public int[] getShape()
        Description copied from interface: INDArray
        Returns the shape of the array as an array of ints. WARNING: May return the internal int[] array describing the shape. Modifying this may cause undefined behaviour. If you want to guarantee a new int[] array that can be safely modified, use getShapeClone() instead
        Specified by:
        getShape in interface INDArray
      • getShapeClone

        public int[] getShapeClone()
        Description copied from interface: INDArray
        Returns the shape of the array as an array of ints, guaranteed to be a new array i.e. will perform a defensive copy of any internal shape array if required.
        Specified by:
        getShapeClone in interface INDArray
        Overrides:
        getShapeClone in class AbstractArray<java.lang.Double>
      • getShape

        public final int getShape(int dim)
        Description copied from interface: INDArray
        Returns the dimension size for a specific dimension in the array's shape
        Specified by:
        getShape in interface INDArray
        Overrides:
        getShape in class AbstractArray<java.lang.Double>
      • elementCount

        public long elementCount()
        Description copied from interface: INDArray
        Returns the total number of elements in this array. Equivalent to the product of all dimension sizes.
        Specified by:
        elementCount in interface INDArray
      • nonZeroValues

        public double[] nonZeroValues()
        Return an double array specifying the values in this vector which are non-zero
        Returns:
      • subArray

        public AVector subArray(int[] offsets,
                                int[] shape)
        Description copied from interface: INDArray
        Returns a subarray view of a larger array
        Specified by:
        subArray in interface INDArray
        Overrides:
        subArray in class AbstractArray<java.lang.Double>
      • rotateView

        public AVector rotateView(int shift)
        Description copied from interface: IVector
        Rotates a vector by the specified number of elements, wrapping around element values. Returns a view.
        Specified by:
        rotateView in interface IVector
        Returns:
      • rotateCopy

        public AVector rotateCopy(int shift)
        Description copied from interface: IVector
        Rotates a vector by the specified number of elements, wrapping around element values. Returns a new vector.
        Specified by:
        rotateCopy in interface IVector
        Returns:
      • subVector

        public AVector subVector(int offset,
                                 int length)
        Obtains a sub-vector view that refers to this vector. Changes to the sub-vector will be reflected in this vector
      • join

        public AVector join(INDArray b)
        Returns a new vector that refers to this vector joined to a second vector. Optimises the type of the returned vector to be as efficient as possible.
        Specified by:
        join in interface INDArray
        Overrides:
        join in class AbstractArray<java.lang.Double>
        Parameters:
        second -
        Returns:
      • tryEfficientJoin

        public AVector tryEfficientJoin(AVector second)
        Attempts to perform an efficient join with a second vector. An efficient join is guaranteed to be better than a simple JoinedVector(left,right) If possible, returns the joined vector. If not, returns null
      • join

        public INDArray join(INDArray a,
                             int dimension)
        Description copied from interface: INDArray
        Joins an array with another array along a specified dimension. Guarantees a view that combines the two joined arrays.
        Specified by:
        join in interface INDArray
        Overrides:
        join in class AbstractArray<java.lang.Double>
      • compareTo

        public int compareTo(AVector a)
        Compares this vector to another vector
      • equals

        public boolean equals(java.lang.Object o)
        Test for equality on vectors. Returns true iff all values in the vector are identical
        Overrides:
        equals in class AbstractArray<java.lang.Double>
      • 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 AbstractArray<java.lang.Double>
        Returns:
      • equals

        public boolean equals(INDArray v)
        Description copied from interface: INDArray
        Checks if two arrays are equal exactly in terms of both value and shape Element equality checks are consistent with compareTo
        Specified by:
        equals in interface INDArray
        Overrides:
        equals in class AbstractArray<java.lang.Double>
      • equalsArray

        public boolean equalsArray(double[] data)
        Returns true if this vector exactly matches a double[] array.
        Specified by:
        equalsArray in interface INDArray
        Overrides:
        equalsArray in class AbstractArray<java.lang.Double>
        Parameters:
        data -
        Returns:
      • elementsEqual

        public boolean elementsEqual(double value)
        Description copied from interface: INDArray
        Returns true if all elements are equal to a specific value
        Specified by:
        elementsEqual in interface INDArray
        Overrides:
        elementsEqual in class AbstractArray<java.lang.Double>
      • equalsArray

        public boolean equalsArray(double[] data,
                                   int offset)
        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 AbstractArray<java.lang.Double>
        Parameters:
        data -
        offset - Offset into the data array
        Returns:
      • toList

        public java.util.List<java.lang.Double> toList()
        Returns a java.util.List instance containing all elements of this vector
        Returns:
      • epsilonEquals

        public boolean epsilonEquals(INDArray a,
                                     double tolerance)
        Description copied from interface: INDArray
        Tests is this array is approximately equal to another array, up to a given tolerance (epsilon) The arrays must have the same shape
        Specified by:
        epsilonEquals in interface INDArray
        Overrides:
        epsilonEquals in class AbstractArray<java.lang.Double>
      • epsilonEquals

        public boolean epsilonEquals(AVector v)
        Returns true if this vector is approximately equal to another vector. A small default tolerance is used.
        Parameters:
        v -
        Returns:
      • hashCode

        public int hashCode()
        Computes the hashcode of a vector. Currently defined to be equal to List.hashCode for a equivalent list of Double values, this may change in future versions.
        Overrides:
        hashCode in class AbstractArray<java.lang.Double>
      • toSliceArray

        public INDArray[] toSliceArray()
        Description copied from interface: INDArray
        Copies the slices of this array to a new INDArray[] Throws an error if the array has no slices (i.e. is zero-dimensional)
        Specified by:
        toSliceArray in interface INDArray
        Overrides:
        toSliceArray in class AbstractArray<java.lang.Double>
      • asDoubleArray

        public double[] asDoubleArray()
        Description copied from interface: INDArray
        Returns the underlying double array representing the densely packed elements of this array. Modifications to this double array will change the original array. Returns null if there is no such array.
        Specified by:
        asDoubleArray in interface INDArray
        Overrides:
        asDoubleArray in class AbstractArray<java.lang.Double>
      • toDoubleBuffer

        public void toDoubleBuffer(java.nio.DoubleBuffer dest)
        Description copied from interface: INDArray
        Copies the elements of this INDArray to the specified double buffer.
        Specified by:
        toDoubleBuffer in interface INDArray
        Overrides:
        toDoubleBuffer in class AbstractArray<java.lang.Double>
      • copyTo

        public void copyTo(AVector dest,
                           int destOffset)
        Copies a the contents of a vector to a vector at the specified offset
      • copyTo

        public void copyTo(ADenseArrayVector dest,
                           int destOffset)
        Copies a the contents of a vector to a vector at the specified offset
      • copyTo

        public void copyTo(int offset,
                           AVector dest,
                           int destOffset,
                           int length)
        Copies a subset of this vector to a vector at the specified offset
      • copyTo

        public void copyTo(int offset,
                           double[] dest,
                           int destOffset,
                           int length)
        Copies a subset of this vector to a specified destination array offset
      • copyTo

        public void copyTo(int offset,
                           double[] dest,
                           int destOffset,
                           int length,
                           int stride)
        Copies a subset of this vector to a specified destination array offset using the given stride. Unsafe operation: performs no bounds checking
      • fill

        public void fill(double value)
        Fills the entire vector with a given value
        Specified by:
        fill in interface INDArray
        Overrides:
        fill in class AbstractArray<java.lang.Double>
        Parameters:
        value -
      • fillRange

        public void fillRange(int offset,
                              int length,
                              double value)
      • clamp

        public void clamp(double min,
                          double max)
        Clamps all values in the vector to a given range
        Specified by:
        clamp in interface INDArray
        Overrides:
        clamp in class AbstractArray<java.lang.Double>
        Parameters:
        value -
      • clampMax

        public void clampMax(double max)
      • clampMin

        public void clampMin(double min)
      • multiply

        public void multiply(double factor)
        Multiplies the vector by a constant factor
        Specified by:
        multiply in interface INDArray
        Overrides:
        multiply in class AbstractArray<java.lang.Double>
        Parameters:
        factor - Factor by which to multiply each component of the vector
      • multiply

        public void multiply(INDArray a)
        Description copied from interface: INDArray
        Multiplies all elements by the equivalent elements in a second array, i.e. performs elementwise multiplication. If matrix-style multiplication is required, use innerProduct instead.
        Specified by:
        multiply in interface INDArray
        Overrides:
        multiply in class AbstractArray<java.lang.Double>
      • multiply

        public void multiply(AVector v)
        Multiplies this vector by another vector, elementwise.
        Parameters:
        v -
      • multiply

        public void multiply(double[] data,
                             int offset)
        Multiplies the elements in this vector by corresponding elements in the target array
        Parameters:
        data -
        offset - The offset into the target array
      • multiplyTo

        public void multiplyTo(double[] dest,
                               int offset)
        Multiplies the elements in the target array by corresponding elements in this vector
        Parameters:
        data -
        offset - The offset into the target array
      • multiplyCopy

        public AVector multiplyCopy(double d)
        Description copied from interface: INDArray
        Returns a copy of the array with all elements multiplied by a single constant value
        Specified by:
        multiplyCopy in interface INDArray
        Overrides:
        multiplyCopy in class AbstractArray<java.lang.Double>
        Parameters:
        d - A scalar factor
        Returns:
        A new array, with all element values scaled by the given factor
      • divideCopy

        public AVector divideCopy(double d)
        Description copied from interface: INDArray
        Returns a copy of the array with all elements divided by a single constant value
        Specified by:
        divideCopy in interface INDArray
        Overrides:
        divideCopy in class AbstractArray<java.lang.Double>
        Returns:
        A new array, with all element values scaled by the given factor
      • multiplyCopy

        public INDArray multiplyCopy(INDArray a)
        Description copied from interface: INDArray
        Multiplies all elements by the equivalent elements in a second array, i.e. performs elementwise multiplication. Returns a new array. If matrix-style multiplication is required, use innerProduct instead.
        Specified by:
        multiplyCopy in interface INDArray
        Overrides:
        multiplyCopy in class AbstractArray<java.lang.Double>
      • multiplyCopy

        public AVector multiplyCopy(AVector a)
        Description copied from interface: IVector
        Multiplies a vector element-wise with this vector, returning a new vector.
        Specified by:
        multiplyCopy in interface IVector
        Returns:
      • divideCopy

        public AVector divideCopy(AVector a)
        Description copied from interface: IVector
        Divides this vector element-wise by another vector, returning a new vector.
        Specified by:
        divideCopy in interface IVector
        Returns:
      • divide

        public void divide(double factor)
        Description copied from interface: INDArray
        Divides all elements by a given factor
        Specified by:
        divide in interface INDArray
        Overrides:
        divide in class AbstractArray<java.lang.Double>
      • divide

        public void divide(INDArray a)
        Description copied from interface: INDArray
        Divides all elements in place by the equivalent elements in a second array
        Specified by:
        divide in interface INDArray
        Overrides:
        divide in class AbstractArray<java.lang.Double>
      • divide

        public void divide(AVector v)
      • divide

        public void divide(double[] data,
                           int offset)
        Divides the elements in this vector by corresponding elements in the target array
        Parameters:
        data -
        offset - The offset into the target array
      • divideTo

        public void divideTo(double[] data,
                             int offset)
        Divides the elements in the target array by corresponding elements in this vector
        Parameters:
        data -
        offset - The offset into the target array
      • abs

        public void abs()
        Description copied from interface: INDArray
        Replaces all elements of this array with their absolute values, according to Math.abs(double)
        Specified by:
        abs in interface INDArray
        Overrides:
        abs in class AbstractArray<java.lang.Double>
      • absCopy

        public AVector absCopy()
        Description copied from interface: INDArray
        Returns a copy of the array with the abs operator applied to each element
        Specified by:
        absCopy in interface INDArray
        Overrides:
        absCopy in class AbstractArray<java.lang.Double>
        Returns:
        A new array containing the absolute element values
      • absDiff

        public void absDiff(INDArray a)
        Description copied from interface: INDArray
        Sets this array to the absolute values of the difference between this array and another
        Specified by:
        absDiff in interface INDArray
        Overrides:
        absDiff in class AbstractArray<java.lang.Double>
      • absDiff

        public void absDiff(AVector a)
      • absDiff

        public void absDiff(double v)
      • absDiffCopy

        public INDArray absDiffCopy(INDArray a)
        Description copied from interface: INDArray
        Returns an array containing the absolute values of the difference between this array and another
        Specified by:
        absDiffCopy in interface INDArray
        Overrides:
        absDiffCopy in class AbstractArray<java.lang.Double>
        Returns:
        A new array containing the absolute element values
      • log

        public void log()
        Description copied from interface: INDArray
        Computes the natural logarithm (in-place) for all array elements
        Specified by:
        log in interface INDArray
        Overrides:
        log in class AbstractArray<java.lang.Double>
      • signum

        public void signum()
        Description copied from interface: INDArray
        Calculates the signum of all elements of this mutable array Sets each component of the array to its sign value (-1, 0 or 1)
        Specified by:
        signum in interface INDArray
        Overrides:
        signum in class AbstractArray<java.lang.Double>
      • softmaxCopy

        public AVector softmaxCopy()
        Computes the softmax function over this vector, returning a new mutable vector
      • softmax

        public void softmax()
        Computes the softmax function over this vector, mutating this vector
      • square

        public void square()
        Description copied from interface: INDArray
        Squares all elements of the array in place
        Specified by:
        square in interface INDArray
        Overrides:
        square in class AbstractArray<java.lang.Double>
      • sqrtCopy

        public AVector sqrtCopy()
        Description copied from interface: IVector
        Computes the square root for each element in this vector, returning a new vector.
        Specified by:
        sqrtCopy in interface IVector
        Returns:
      • tanh

        public void tanh()
        Computes the tanh of every element in this vector. Mutates this vector.
      • logistic

        public void logistic()
        Computes the logistic function for every element in this vector. Mutates this vector.
      • reciprocal

        public void reciprocal()
        Computes the reciprocal of all elements in this vector. Mutates this vector
        Specified by:
        reciprocal in interface INDArray
        Overrides:
        reciprocal in class AbstractArray<java.lang.Double>
      • scale

        public final void scale(AVector v)
        Scales the vector by another vector of the same size
        Parameters:
        v -
      • scaleToMagnitude

        public double scaleToMagnitude(double targetMagnitude)
        Scales the vector up to a specific target magnitude
        Returns:
        the old magnitude of the vector
      • scaleAdd

        public void scaleAdd(double factor,
                             AVector v)
        Scales this vector then adds another vector
        Parameters:
        factor -
        v -
      • interpolate

        public void interpolate(AVector v,
                                double alpha)
        Interpolates between this vector and a second vector, according to the ratio alpha. alpha = 0.0 returns this vector. alpha = 1.0 returns the other vector Other values perform linear interpolation. Stores the result in this vector
        Parameters:
        v -
        alpha -
      • magnitudeSquared

        public final double magnitudeSquared()
        Computes the squared magnitude (sum of squares) for this vector
        Returns:
      • getTranspose

        public final AVector getTranspose()
        Description copied from interface: INDArray
        Returns the transpose of this array. A transpose of an array is equivalent to reversing the order of dimensions. May or may not return a view depending on the array type.
        Specified by:
        getTranspose in interface INDArray
        Overrides:
        getTranspose in class AbstractArray<java.lang.Double>
      • getTransposeView

        public final AVector getTransposeView()
        Description copied from interface: INDArray
        Returns a transposed view of the array. May throw UnsupportedOperationException if the array type does not support this capability
        Specified by:
        getTransposeView in interface INDArray
        Overrides:
        getTransposeView in class AbstractArray<java.lang.Double>
      • select

        public AVector select(int... indices)
        Selects a subset of indices from a vector
        Parameters:
        indices -
        Returns:
      • selectView

        public AVector selectView(int... indices)
        Selects a subset of indices from a vector, returning a view
        Parameters:
        indices -
        Returns:
        a view of the selected indices
      • selectClone

        public AVector selectClone(int... inds)
        Selects a subset of indices from a vector, returning a mutable clone of data
        Parameters:
        indices -
        Returns:
        a new mutable vector containing the selected indices
      • outerProduct

        public AMatrix outerProduct(AVector a)
        Computes the outer product of this vector with another vector
        Parameters:
        a -
        Returns:
        a matrix representing the outer product
      • innerProduct

        public AScalar innerProduct(AVector v)
        Computes the inner product of this vector with another vector
        Specified by:
        innerProduct in interface INDArray
        Overrides:
        innerProduct in class AbstractArray<java.lang.Double>
        Parameters:
        v - A vector
        Returns:
        an AScalar instance representing the inner product
      • innerProduct

        public Scalar innerProduct(ADenseArrayVector v)
        Overloaded inner product for dense array vector argument
        Parameters:
        v -
        Returns:
      • innerProduct

        public AVector innerProduct(AMatrix m)
        Computes the inner product of this vector with a matrix
        Parameters:
        m -
        Returns:
        a vector representing the inner product
      • innerProduct

        public final AVector innerProduct(AScalar s)
        Computes the inner product of this vector with a scalar
        Specified by:
        innerProduct in interface INDArray
        Overrides:
        innerProduct in class AbstractArray<java.lang.Double>
        Parameters:
        s - A scalar instance
        Returns:
        a vector representing the inner product
      • dotProduct

        public double dotProduct(AVector v)
        Returns the dot product of this vector with another vector The vectors must have the same length: if not the result is undefined
        Parameters:
        v -
        Returns:
      • dotProduct

        public double dotProduct(ADenseArrayVector v)
        Returns the dot product of this vector with a target ADenseArrayVector.
        Parameters:
        v -
        Returns:
      • dotProduct

        public double dotProduct(AVector v,
                                 Index ix)
        Returns the dotProduct of this vector with the elements of another vector mapped to specified indexes in this vector.
        Parameters:
        v -
        ix -
        Returns:
      • dotProduct

        public abstract double dotProduct(double[] data,
                                          int offset)
        Fast dot product with a double[] array. Performs no bounds checking. Likely to be faster than most other dot product operations
      • dotProduct

        public double dotProduct(double[] data,
                                 int offset,
                                 int stride)
        Fast dot product with a double[] array and a stride. Performs no bounds checking. Likely to be faster than other dot product operations
      • crossProduct

        public void crossProduct(AVector a)
        Computes the crossProduct of this vector with another vector, and stores the result in this vector. Both vectors must have length 3.
        Parameters:
        a -
      • crossProduct

        public void crossProduct(Vector3 a)
        Computes the crossProduct of this vector with another vector, and stores the result in this vector. Both vectors must have length 3.
        Parameters:
        a -
      • magnitude

        public double magnitude()
        Returns the magnitude (Euclidean length) of the vector
        Returns:
      • distanceSquared

        public double distanceSquared(AVector v)
        Returns the squared Euclidean distance to another vector.
        Parameters:
        v -
        Returns:
      • distance

        public double distance(AVector v)
        Returns the Euclidean distance to another vector.
        Parameters:
        v -
        Returns:
      • distanceL1

        public double distanceL1(AVector v)
        Returns the distance from this vector to another vector according to the L1 (Taxicab) norm.
        Parameters:
        v -
        Returns:
      • distanceLinf

        public double distanceLinf(AVector v)
        Returns the distance from this vector to another vector according to the Linf norm.
        Parameters:
        v -
        Returns:
      • maxAbsElement

        public double maxAbsElement()
        Returns the maximum absolute element value of a vector
        Returns:
      • maxAbsElementIndex

        public int maxAbsElementIndex()
        Returns the index of the maximum absolute element of a vector
        Returns:
      • maxElement

        public final double maxElement()
        Returns the maximum element value in a vector. Synonym for elementMax()
        Returns:
      • maxElementIndex

        public int maxElementIndex()
        Returns the index of the maximum element of a vector
        Returns:
      • minElement

        public final double minElement()
        Returns the minimum element value in a vector. Synonym for elementMin()
      • minElementIndex

        public int minElementIndex()
        Returns the index of the minimum element of a vector
      • normaliseMaxAbsElement

        public double normaliseMaxAbsElement()
        Normalises so that the maximum absolute element is 1.0 Returns the previous maximum absolute element.
      • elementSum

        public double elementSum()
        Returns the sum of all elements in a vector
        Specified by:
        elementSum in interface INDArray
        Overrides:
        elementSum in class AbstractArray<java.lang.Double>
        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 AbstractArray<java.lang.Double>
      • elementMaxAbs

        public final double elementMaxAbs()
        Returns the maximum absolute element value in this vector. Throws an error if there are no elements.
        Specified by:
        elementMaxAbs in interface INDArray
        Overrides:
        elementMaxAbs in class AbstractArray<java.lang.Double>
      • 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 AbstractArray<java.lang.Double>
      • elementPowSum

        public double elementPowSum(double exponent)
        Description copied from class: AbstractArray
        Returns the sum of all the elements raised to a specified power
        Specified by:
        elementPowSum in interface INDArray
        Overrides:
        elementPowSum in class AbstractArray<java.lang.Double>
        Returns:
      • elementAbsPowSum

        public double elementAbsPowSum(double exponent)
        Description copied from class: AbstractArray
        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 AbstractArray<java.lang.Double>
        Returns:
      • angle

        public double angle(AVector v)
        Returns the Euclidean angle between this vector and another vector
        Returns:
        angle in radians
      • normalise

        public double normalise()
        Normalises this vector to a magnitude of 1.0 Has no effect on a zero-length vector (i.e. it will remain zero)
        Specified by:
        normalise in interface IVector
        Returns:
        the magnitude of the original vector
      • normaliseCopy

        public AVector normaliseCopy()
        Returns a copy of this vector normalised to a Euclidean length of 1.0 Has no effect on a zero-length vector (i.e. it will return a zero length vector)
        Specified by:
        normaliseCopy in interface IVector
        Returns:
      • negate

        public void negate()
        Negates all emlements of this vector in place.
        Specified by:
        negate in interface INDArray
        Overrides:
        negate in class AbstractArray<java.lang.Double>
      • scaleCopy

        public final AVector scaleCopy(double d)
        Description copied from interface: INDArray
        Scales all elements of the array by a given double value, returning a new array
        Specified by:
        scaleCopy in interface INDArray
        Overrides:
        scaleCopy in class AbstractArray<java.lang.Double>
      • shiftCopy

        public AVector shiftCopy(int shift)
        Description copied from interface: IVector
        Shifts a vector by the specified number of elements, filling with zeros. Returns a new vector.
        Specified by:
        shiftCopy in interface IVector
        Returns:
      • pow

        public void pow(double exponent)
        Description copied from interface: INDArray
        Raises all elements of the array to a specified power in place
        Specified by:
        pow in interface INDArray
        Overrides:
        pow in class AbstractArray<java.lang.Double>
      • set

        public void set(AVector src)
        Sets the vector to equal the value of another vector
      • set

        public void set(ADenseArrayVector v)
        Sets the vector equal to the value of an ADenseArrayVector
        Parameters:
        v -
      • set

        public final void set(double a)
        Description copied from interface: INDArray
        Sets all elements of an array to a specific double value
        Specified by:
        set in interface INDArray
        Overrides:
        set in class AbstractArray<java.lang.Double>
      • setElements

        public void setElements(double... data)
        Description copied from interface: INDArray
        Sets all elements in an array using the given double values
        Specified by:
        setElements in interface INDArray
        Overrides:
        setElements in class AbstractArray<java.lang.Double>
        Parameters:
        data - Element values in a double[] array. There must be at least as many element values as elements in this array.
      • setElements

        public void setElements(double[] data,
                                int offset)
        Description copied from interface: INDArray
        Sets all elements in an array using the given double values
        Specified by:
        setElements in interface INDArray
        Overrides:
        setElements in class AbstractArray<java.lang.Double>
        Parameters:
        data - Element values in a double[] array. There must be at least as many element values as elements in this array.
        offset - Position in the values array from which to start taking values.
      • set

        public void set(INDArray a)
        Description copied from interface: INDArray
        Sets this array to the element values contained in another array. Broadcasts the source array if necessary to the shape of this array. Throws an exception if the shapes are incompatible.
        Specified by:
        set in interface INDArray
        Overrides:
        set in class AbstractArray<java.lang.Double>
      • setElements

        public void setElements(int pos,
                                double[] values,
                                int offset,
                                int length)
        Description copied from interface: INDArray
        Sets elements in an array using the given double values. The source array must contain at least the specified length in terms of number of elements
        Specified by:
        setElements in interface INDArray
        Overrides:
        setElements in class AbstractArray<java.lang.Double>
        Parameters:
        pos - Offset into this array, expressed in terms of number of elements in row major order
        values - Element values in a double[] array. There must be at least as many element values as elements in this array.
        offset - Position in the values array from which to start taking values.
        length - Number of elements to set.
      • 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 AbstractArray<java.lang.Double>
      • getElements

        public void getElements(java.lang.Object[] dest,
                                int offset)
        Description copied from interface: INDArray
        Copies all elements of this array into an object array at the specified offset
        Specified by:
        getElements in interface INDArray
        Overrides:
        getElements in class AbstractArray<java.lang.Double>
      • getElements

        public void getElements(double[] dest,
                                int destOffset,
                                int[] indices)
        Gets the elements in this vector from the specified indices, storing at the specified offset in the destination array
        Parameters:
        dest -
        destOffset -
        indices -
      • set

        public void set(AVector src,
                        int srcOffset)
        Set the vector equal to an offset into another vector
      • clone

        public AVector clone()
        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 AbstractArray<java.lang.Double>
      • copy

        public AVector copy()
        Description copied from interface: INDArray
        Returns a defensive copy of the array data. Use this if the original array might change and you need a defensive copy. May return the same array if the original was immutable, otherwise will return a defensive copy.
        Specified by:
        copy in interface INDArray
        Overrides:
        copy in class AbstractArray<java.lang.Double>
      • asVector

        public final AVector asVector()
        Description copied from interface: INDArray
        Constructs a view of all elements in the array as a single vector in row-major order.
        Specified by:
        asVector in interface INDArray
        Overrides:
        asVector in class AbstractArray<java.lang.Double>
      • reshape

        public INDArray reshape(int... dimensions)
        Description copied from interface: INDArray
        Returns a new array by rearranging the elements of this array into the desired shape Truncates or zero-pads the elements as required to fill the new shape
        Specified by:
        reshape in interface INDArray
        Overrides:
        reshape in class AbstractArray<java.lang.Double>
      • reorder

        public final AVector reorder(int[] order)
        Description copied from interface: INDArray
        Returns a re-ordered array by taking the specified order of slices along dimension 0
        Specified by:
        reorder in interface INDArray
        Overrides:
        reorder in class AbstractArray<java.lang.Double>
      • reorder

        public final AVector reorder(int dim,
                                     int[] order)
        Description copied from interface: INDArray
        Returns a re-ordered array by taking the specified order of slices along a given dimension May or may not use views of underlying slices (i.e. may be a reordered view)
        Specified by:
        reorder in interface INDArray
        Overrides:
        reorder in class AbstractArray<java.lang.Double>
      • isView

        public boolean isView()
        Returns true if this vector is of a view type that references other vectors / data.
        Specified by:
        isView in interface INDArray
      • isFullyMutable

        public boolean isFullyMutable()
        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 AbstractArray<java.lang.Double>
      • add

        public void add(AVector v)
        Adds another vector to this one
      • add

        public final void add(ADenseArrayVector v)
        Add a DenseArrayVector to this vector
        Parameters:
        v -
      • add

        public final void add(INDArray a)
        Description copied from interface: INDArray
        Adds all the elements of another array to this array, in an elementwise order.
        Specified by:
        add in interface INDArray
        Overrides:
        add in class AbstractArray<java.lang.Double>
      • addCopy

        public AVector addCopy(AVector a)
        Description copied from interface: IVector
        Adds a vector element-wise to this vector, returning a new vector.
        Specified by:
        addCopy in interface IVector
        Returns:
      • addCopy

        public AVector addCopy(double a)
        Description copied from interface: INDArray
        Creates a new array equal to this array with a constant value added to every element
        Specified by:
        addCopy in interface INDArray
        Overrides:
        addCopy in class AbstractArray<java.lang.Double>
        Returns:
      • subCopy

        public AVector subCopy(AVector a)
        Description copied from interface: IVector
        Subtracts a vector element-wise from this vector, returning a new vector.
        Specified by:
        subCopy in interface IVector
        Returns:
      • sub

        public void sub(INDArray a)
        Description copied from interface: INDArray
        Subtracts all the elements of another array from this array, in an elementwise order.
        Specified by:
        sub in interface INDArray
        Overrides:
        sub in class AbstractArray<java.lang.Double>
      • add

        public void add(AVector src,
                        int srcOffset)
        Adds part another vector to this one, starting at the specified offset in the source vector
        Parameters:
        src -
      • add

        public final void add(int offset,
                              AVector src)
        Adds another vector into this one, at the specified offset
        Parameters:
        offset -
        src -
      • add

        public void add(int offset,
                        AVector src,
                        int srcOffset,
                        int length)
        Adds a segment of another vector into this one, at the specified offset
        Parameters:
        offset -
        src -
      • addProduct

        public void addProduct(AVector a,
                               AVector b)
        Adds the element-wise product of two vectors to this vector. Mutates this vector.
        Parameters:
        a -
        b -
      • addProductCopy

        public AVector addProductCopy(AVector a,
                                      AVector b)
        Adds the element-wise product of two vectors to this vector.
        Parameters:
        a -
        b -
        Returns:
        A new vector representing the result
      • addProductCopy

        public AVector addProductCopy(AVector a,
                                      AVector b,
                                      double factor)
        Adds the element-wise product of two vectors and a constant factor to this vector.
        Parameters:
        a -
        b -
        Returns:
        A new vector representing the result
      • addProduct

        public void addProduct(AVector a,
                               AVector b,
                               double factor)
        Adds the element-wise product of two vectors and a constant factor to this vector. Mutates this vector.
        Parameters:
        a -
        b -
      • checkLength

        public int checkLength(int length)
        Checks that a vector is the specified length, throws an exception if not.
        Parameters:
        length -
        Returns:
        The length of the vector
      • addMultiple

        public void addMultiple(AVector src,
                                double factor)
        Adds a scaled multiple of another vector to this vector
        Parameters:
        src -
      • addMultiple

        public void addMultiple(SparseIndexedVector src,
                                double factor)
        Adds a scaled multiple of a sparse indexed vector to this vector
        Parameters:
        src -
      • addMultipleCopy

        public AVector addMultipleCopy(AVector src,
                                       double factor)
        Returns the sum of this vector with a scaled multiple of a second vector.
        Parameters:
        src -
        factor -
        Returns:
      • addMultiple

        public void addMultiple(AVector src,
                                int srcOffset,
                                double factor)
        Adds a multiple of a subvector of another vector to this vector. Useful as a specialised override for joined vectors etc.
        Parameters:
        src -
        srcOffset -
        factor -
      • addMultiple

        public void addMultiple(int offset,
                                AVector src,
                                int srcOffset,
                                int length,
                                double factor)
      • addMultiple

        public final void addMultiple(int offset,
                                      AVector v,
                                      double factor)
      • addWeighted

        public final void addWeighted(AVector v,
                                      double factor)
        Updates a weighted average of this vector with another vector
        Parameters:
        v -
      • scaleAdd

        public final void scaleAdd(double factor,
                                   INDArray b,
                                   double bfactor,
                                   double constant)
        Description copied from interface: INDArray
        Scales all elements of the array by a given double value, adds a scaled second array and adds a constant value
        Specified by:
        scaleAdd in interface INDArray
        Overrides:
        scaleAdd in class AbstractArray<java.lang.Double>
      • scaleAdd

        public void scaleAdd(double factor,
                             AVector b,
                             double bfactor,
                             double constant)
        Scales all elements of the array by a given double value, adds a scaled second vector and adds a constant value
        Parameters:
        factor -
        b -
        bfactor -
        constant -
      • addPower

        public void addPower(INDArray src,
                             double exponent)
        Description copied from interface: INDArray
        Adds an array with all elements of the source array raised to the specified power
        Specified by:
        addPower in interface INDArray
        Overrides:
        addPower in class AbstractArray<java.lang.Double>
      • addPower

        public void addPower(INDArray src,
                             double exponent,
                             double factor)
        Description copied from interface: INDArray
        Adds an array with all elements raised to the specified power and scaled by the given factor
        Specified by:
        addPower in interface INDArray
        Overrides:
        addPower in class AbstractArray<java.lang.Double>
      • sub

        public void sub(AVector v)
        Subtracts a vector from this vector
        Parameters:
        v -
      • subAt

        public final void subAt(int i,
                                double v)
        Subtracts a value from the specified element in this vector.
        Parameters:
        i -
        v -
      • isZero

        public boolean isZero()
        Returns true if this vector is a zero vector (all components zero)
        Specified by:
        isZero in interface INDArray
        Overrides:
        isZero in class AbstractArray<java.lang.Double>
        Returns:
      • isRangeZero

        public boolean isRangeZero(int start,
                                   int length)
        Returns true if a sub-vector range is completely zero. Unsafe operation - does not perform bounds checking, results are undefined if sub-vector is out of range
        Parameters:
        start -
        length -
        Returns:
      • isUnitLengthVector

        public boolean isUnitLengthVector()
        Returns true if the vector has unit length
        Returns:
      • isUnitLengthVector

        public boolean isUnitLengthVector(double tolerance)
        Returns true if the vector has unit length with the given tolerance
        Returns:
      • isSameShape

        public boolean isSameShape(AVector a)
        Description copied from interface: IVector
        Returns true if this vector is exactly the same shape as another vector.
        Specified by:
        isSameShape in interface IVector
        Returns:
      • checkRange

        public int checkRange(int offset,
                              int length)
        Utility function to check vector range and throw an exception if not valid. Returns the length of this vector
      • checkIndex

        public int checkIndex(int i)
        Utility function to check an index and throw an exception in not in bounds. Returns the vector length
      • projectToPlane

        public void projectToPlane(AVector normal,
                                   double distance)
        Projects the vector to the plane defined by: x.normal=distance
        Parameters:
        normal - A Vector of unit length
        distance -
      • subMultiple

        public void subMultiple(AVector v,
                                double factor)
        Subtracts a scaled multiple of another vector from this vector
        Parameters:
        v -
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class AbstractArray<java.lang.Double>
      • toVector

        public Vector toVector()
        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 AbstractArray<java.lang.Double>
      • mutable

        public AVector mutable()
        Coerces to a mutable version of a vector. May or may not be a copy, but guaranteed to be fully mutable
        Specified by:
        mutable in interface INDArray
        Overrides:
        mutable in class AbstractArray<java.lang.Double>
        Returns:
      • sparse

        public AVector 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 AbstractArray<java.lang.Double>
      • dense

        public AVector dense()
        Description copied from interface: INDArray
        Coerces this INDArray to a dense format, without changing its element values. May return the same INDArray if already dense. 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 dense array may not be fully mutable in all elements.
        Specified by:
        dense in interface INDArray
        Overrides:
        dense in class AbstractArray<java.lang.Double>
      • denseClone

        public final Vector denseClone()
        Description copied from interface: INDArray
        Creates a fully mutable dense clone of this array. Will always use a dense format, even if the array data is sparse.
        Specified by:
        denseClone in interface INDArray
        Overrides:
        denseClone in class AbstractArray<java.lang.Double>
      • toNormal

        public AVector toNormal()
        Creates a new mutable vector representing the normalised value of this vector Returns null if the vector cannot be normalised (i.e. is a zero length vector)
        Returns:
      • asElementList

        public java.util.List<java.lang.Double> asElementList()
        Description copied from interface: INDArray
        Returns a List containing all elements of this array
        Specified by:
        asElementList in interface INDArray
        Overrides:
        asElementList in class AbstractArray<java.lang.Double>
      • iterator

        public java.util.Iterator<java.lang.Double> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.Double>
        Overrides:
        iterator in class AbstractArray<java.lang.Double>
      • elementIterator

        public final java.util.Iterator<java.lang.Double> elementIterator()
        Description copied from interface: INDArray
        Returns an iterator over all elements in this array, in row-major order
        Specified by:
        elementIterator in interface INDArray
        Overrides:
        elementIterator in class AbstractArray<java.lang.Double>
      • addMultiple

        public void addMultiple(Vector source,
                                Index sourceToDest,
                                double factor)
        Adds source vector to this vector at the specified indexes which should map from source->this
        Parameters:
        source -
        sourceToDest -
        factor -
      • addSparse

        public void addSparse(double c)
        Description copied from interface: INDArray
        Adds to the non-sparse elements of this array
        Specified by:
        addSparse in interface INDArray
        Overrides:
        addSparse in class AbstractArray<java.lang.Double>
      • addSparse

        public void addSparse(AVector v)
        Adds the corresponding elements of the source vector to the non-sparse elements of this vector
        Parameters:
        v -
      • setSparse

        public void setSparse(INDArray src)
        Description copied from interface: INDArray
        Sets the non-sparse elements of this array to the corresponding elements of the source array
        Specified by:
        setSparse in interface INDArray
        Overrides:
        setSparse in class AbstractArray<java.lang.Double>
      • setSparse

        public void setSparse(AVector src)
        Sets the non-sparse elements of this vector to the corresponding elements of another vector
        Parameters:
        v -
      • setSparse

        public void setSparse(double v)
        Description copied from interface: INDArray
        Sets the non-sparse elements of this array to the specified value May throw an exception if non-sparse elements are not mutable
        Specified by:
        setSparse in interface INDArray
        Overrides:
        setSparse in class AbstractArray<java.lang.Double>
      • addMultipleSparse

        public void addMultipleSparse(AVector v,
                                      double factor)
        Adds a multiple of a source vector to the non-sparse elements of this vector only
        Parameters:
        v -
        factor -
      • addMultiple

        public void addMultiple(AVector source,
                                Index sourceToDest,
                                double factor)
        Adds a source vector to this vector at the specified indexes which should map from source->this
        Parameters:
        source -
        sourceToDest -
        factor -
      • set

        public final void set(AVector source,
                              Index indexes)
        sets the vector using values indexed from another vector
      • set

        public void set(AVector source,
                        int[] indexes)
        sets the vector using values indexed from another vector
      • addToArray

        public void addToArray(double[] array,
                               int offset)
        Adds this vector to a double[] array, starting at the specified offset.
        Specified by:
        addToArray in interface INDArray
        Overrides:
        addToArray in class AbstractArray<java.lang.Double>
        Parameters:
        array -
        offset -
      • addToArray

        public void addToArray(double[] dest,
                               int destOffset,
                               int destStride)
        Adds this vector to a double[] array, using the specified offset and stride into the destination array
      • addToArray

        public void addToArray(int offset,
                               double[] array,
                               int arrayOffset,
                               int length)
        Adds a subvector of this vector into a double array at the specified offset
        Parameters:
        offset -
        array -
        arrayOffset -
        length -
      • addMultipleToArray

        public void addMultipleToArray(double factor,
                                       double[] array,
                                       int arrayOffset)
        Adds a multiple of this vector into a double array at the specified offset
        Parameters:
        offset -
        array -
        arrayOffset -
        length -
      • addMultipleToArray

        public void addMultipleToArray(double factor,
                                       int offset,
                                       double[] array,
                                       int arrayOffset,
                                       int length)
        Adds a multiple of a subvector of this vector into a double array at the specified offset
        Parameters:
        offset -
        array -
        arrayOffset -
        length -
      • addProductToArray

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

        public void addProductToArray(double factor,
                                      int offset,
                                      ADenseArrayVector other,
                                      int otherOffset,
                                      double[] dest,
                                      int destOffset,
                                      int length)
        Adds the scaled elementwise product of this vector and another vector to the destimation array
        Parameters:
        factor -
        offset -
        other -
        otherOffset -
        dest -
        destOffset -
        length -
      • addProduct

        public void addProduct(AVector a,
                               int aOffset,
                               AVector b,
                               int bOffset,
                               double factor)
        Adds the scaled elementwise product of two vectors to this vector
        Parameters:
        a -
        aOffset -
        b -
        bOffset -
        factor -
      • addInnerProduct

        public void addInnerProduct(AMatrix a,
                                    AVector b)
        Adds the inner product of the arguments (matrix a and vector b) to this vector.
        Parameters:
        a - A matrix with the same number or rows as this vector
        b - A vector with the same lengths as the number of columns in the parameter a
      • addInnerProduct

        public void addInnerProduct(AVector a,
                                    AMatrix b)
        Adds the inner product of the arguments (vector a and matrix b) to this vector.
        Parameters:
        a - A vector with the same lengths as the number of rows in the matrix parameter b
        b - A matrix with the same number of columns as this vector
      • setInnerProduct

        public void setInnerProduct(AMatrix a,
                                    AVector b)
        Sets this vector to the inner product of the arguments (matrix a and vector b).
        Parameters:
        a - A matrix with the same number or rows as this vector
        b - A vector with the same lengths as the number of columns in the parameter a
      • setInnerProduct

        public void setInnerProduct(AVector a,
                                    AMatrix b)
        Sets this vector to the inner product of the arguments (vector a and matrix b) to this vector.
        Parameters:
        a - A vector with the same lengths as the number of rows in the matrix parameter b
        b - A matrix with the same number of columns as this vector
      • setMultiple

        public final void setMultiple(AVector a,
                                      AVector b)
        Sets this vector to the element-wise product of two otehr vectors
        Parameters:
        a -
        b -
      • setMultiple

        public final void setMultiple(INDArray a,
                                      double b)
        Description copied from interface: INDArray
        Sets this array to be the multiple of another array. Must have compatible shapes.
        Specified by:
        setMultiple in interface INDArray
        Overrides:
        setMultiple in class AbstractArray<java.lang.Double>
      • setMultiple

        public final void setMultiple(AVector a,
                                      double b)
        Sets this vector to be a multiple of another vector
        Parameters:
        a -
        b -
      • applyOp

        public void applyOp(IOperator op)
        Description copied from interface: INDArray
        Applies a unary operator to all elements of the array (in-place)
        Specified by:
        applyOp in interface INDArray
        Overrides:
        applyOp in class AbstractArray<java.lang.Double>
        Parameters:
        op - The operator to apply to the array
      • applyOp

        public void applyOp(Op op)
        Description copied from interface: INDArray
        Applies a unary operator to all elements of the array (in-place)
        Specified by:
        applyOp in interface INDArray
        Overrides:
        applyOp in class AbstractArray<java.lang.Double>
      • applyOp

        public void applyOp(Op2 op,
                            INDArray b)
        Description copied from interface: INDArray
        Applies a binary operator to this array and a second array. Broadcasts the second array to the shape of this array if required.
        Specified by:
        applyOp in interface INDArray
        Overrides:
        applyOp in class AbstractArray<java.lang.Double>
      • applyOp

        public void applyOp(Op2 op,
                            AVector b)
        Applies a binary operator to this vector and a second vector
        Parameters:
        op -
        b -
      • applyOp

        public void applyOp(Op2 op,
                            double b)
        Description copied from interface: INDArray
        Applies a binary operator to this array and a double value. Works as if the double value was broadcast to the shape of this array.
        Specified by:
        applyOp in interface INDArray
        Overrides:
        applyOp in class AbstractArray<java.lang.Double>
      • setApplyOp

        public final void setApplyOp(Op op,
                                     INDArray a)
        Description copied from interface: INDArray
        Sets this array to the result of applying an operation to a source array
        Specified by:
        setApplyOp in interface INDArray
        Overrides:
        setApplyOp in class AbstractArray<java.lang.Double>
      • setApplyOp

        public void setApplyOp(Op op,
                               AVector a)
        Sets this vector to the result of applying an operator to another vector
        Parameters:
        op -
        a -
      • setApplyOp

        public void setApplyOp(Op op,
                               double a)
        Sets this vector to the result of applying an operator to a double value
        Parameters:
        op -
        a -
      • 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 AbstractArray<java.lang.Double>
      • 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 AbstractArray<java.lang.Double>
      • reduceSlices

        public final AVector reduceSlices(Op2 op)
        Description copied from interface: INDArray
        Reduces each vector slice of the array by the given binary operator Reduces down to a single vector
        Specified by:
        reduceSlices in interface INDArray
        Overrides:
        reduceSlices in class AbstractArray<java.lang.Double>
      • reduceSlices

        public 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 AbstractArray<java.lang.Double>
      • addAt

        public void addAt(int i,
                          double v)
        Adds a value to a specific element of the vector This function does not perform bounds checking, i.e. is an unsafe operation
        Parameters:
        i -
        v -
      • addAt

        public void addAt(long i,
                          double v)
        Description copied from interface: INDArray
        Adds to a mutable array, indexed by element position in row major order. This is an unsafe operation: bounds are not checked
        Specified by:
        addAt in interface INDArray
        Overrides:
        addAt in class AbstractArray<java.lang.Double>
      • scaleAdd

        public void scaleAdd(double factor,
                             double constant)
        Scales this vector and adds a constant to every element
        Specified by:
        scaleAdd in interface INDArray
        Overrides:
        scaleAdd in class AbstractArray<java.lang.Double>
      • add

        public void add(double constant)
        Description copied from interface: INDArray
        Adds a double value to all elements in this array. Implementations may optimize the case of 0.0
        Specified by:
        add in interface INDArray
        Overrides:
        add in class AbstractArray<java.lang.Double>
      • add

        public void add(double[] data,
                        int offset)
        Adds to this vector from a given double array.
        Parameters:
        data -
        offset -
      • add

        public void add(double[] data)
        Adds the values from a double[] array to this vector
        Parameters:
        data -
      • exactClone

        public abstract AVector exactClone()
        Returns an exact clone of this vector, i.e. of the same type
        Specified by:
        exactClone in interface INDArray
        Returns:
      • broadcast

        public INDArray broadcast(int... targetShape)
        Description copied from interface: INDArray
        Returns a view of this array broadcasted up to a larger shape
        Specified by:
        broadcast in interface INDArray
        Overrides:
        broadcast in class AbstractArray<java.lang.Double>
      • 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 AbstractArray<java.lang.Double>
      • nonSparseIndex

        public Index nonSparseIndex()
        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.
        Returns:
      • nonZeroIndices

        public int[] nonZeroIndices()
        Return an int array specifying the positions in this vector which are non-zero
        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 AbstractArray<java.lang.Double>
        Returns:
        True if any element is this array is NaN or infinite, false otherwise
      • visitNonZero

        public abstract double visitNonZero(IndexedElementVisitor elementVisitor)
        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.
        Parameters:
        elementVisitor -

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.