mikera.vectorz
Class AVector
- java.lang.Object
-
- mikera.arrayz.impl.AbstractArray<java.lang.Double>
-
- mikera.vectorz.AVector
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<java.lang.Double>, INDArray, IVector
- Direct Known Subclasses:
- APrimitiveVector, ASizedVector, GrowableIndexedVector, GrowableVector
public abstract class AVector extends AbstractArray<java.lang.Double> implements IVector
Main abstract base class for all types of vector Contains default implementations for most vector operations which can be overriden to achieve better performance in derived classes.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description AVector()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description voidabs()Replaces all elements of this array with their absolute values, according to Math.abs(double)AVectorabsCopy()Returns a copy of the array with the abs operator applied to each elementvoidabsDiff(AVector a)voidabsDiff(double v)voidabsDiff(INDArray a)Sets this array to the absolute values of the difference between this array and anotherINDArrayabsDiffCopy(INDArray a)Returns an array containing the absolute values of the difference between this array and anothervoidadd(ADenseArrayVector v)Add a DenseArrayVector to this vectorvoidadd(AVector v)Adds another vector to this onevoidadd(AVector src, int srcOffset)Adds part another vector to this one, starting at the specified offset in the source vectorvoidadd(double constant)Adds a double value to all elements in this array.voidadd(double[] data)Adds the values from a double[] array to this vectorvoidadd(double[] data, int offset)Adds to this vector from a given double array.voidadd(INDArray a)Adds all the elements of another array to this array, in an elementwise order.voidadd(int offset, AVector src)Adds another vector into this one, at the specified offsetvoidadd(int offset, AVector src, int srcOffset, int length)Adds a segment of another vector into this one, at the specified offsetvoidaddAt(int i, double v)Adds a value to a specific element of the vector This function does not perform bounds checking, i.e.voidaddAt(long i, double v)Adds to a mutable array, indexed by element position in row major order.AVectoraddCopy(AVector a)Adds a vector element-wise to this vector, returning a new vector.AVectoraddCopy(double a)Creates a new array equal to this array with a constant value added to every elementINDArrayaddCopy(INDArray a)Creates a new array equal to the sum of this array with another array.voidaddInnerProduct(AMatrix a, AVector b)Adds the inner product of the arguments (matrix a and vector b) to this vector.voidaddInnerProduct(AMatrix a, INDArray b)Adds the inner product of a matrix and an array to this arrayvoidaddInnerProduct(AVector a, AMatrix b)Adds the inner product of the arguments (vector a and matrix b) to this vector.voidaddInnerProduct(INDArray a, INDArray b)Adds the inner product of two arrays to this array.voidaddMultiple(AVector src, double factor)Adds a scaled multiple of another vector to this vectorvoidaddMultiple(AVector source, Index sourceToDest, double factor)Adds a source vector to this vector at the specified indexes which should map from source->thisvoidaddMultiple(AVector src, int srcOffset, double factor)Adds a multiple of a subvector of another vector to this vector.voidaddMultiple(INDArray src, double factor)Adds a scaled multiple of another array to this arrayvoidaddMultiple(int offset, AVector v, double factor)voidaddMultiple(int offset, AVector src, int srcOffset, int length, double factor)voidaddMultiple(SparseIndexedVector src, double factor)Adds a scaled multiple of a sparse indexed vector to this vectorvoidaddMultiple(Vector source, Index sourceToDest, double factor)Adds source vector to this vector at the specified indexes which should map from source->thisAVectoraddMultipleCopy(AVector src, double factor)Returns the sum of this vector with a scaled multiple of a second vector.voidaddMultipleSparse(AVector v, double factor)Adds a multiple of a source vector to the non-sparse elements of this vector onlyvoidaddMultipleSparse(INDArray a, double factor)Adds a multiple of the source array to the non-sparse elements of this arrayvoidaddMultipleToArray(double factor, double[] array, int arrayOffset)Adds a multiple of this vector into a double array at the specified offsetvoidaddMultipleToArray(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 offsetvoidaddPower(INDArray src, double exponent)Adds an array with all elements of the source array raised to the specified powervoidaddPower(INDArray src, double exponent, double factor)Adds an array with all elements raised to the specified power and scaled by the given factorvoidaddProduct(AVector a, AVector b)Adds the element-wise product of two vectors to this vector.voidaddProduct(AVector a, AVector b, double factor)Adds the element-wise product of two vectors and a constant factor to this vector.voidaddProduct(AVector a, int aOffset, AVector b, int bOffset, double factor)Adds the scaled elementwise product of two vectors to this vectorAVectoraddProductCopy(AVector a, AVector b)Adds the element-wise product of two vectors to this vector.AVectoraddProductCopy(AVector a, AVector b, double factor)Adds the element-wise product of two vectors and a constant factor to this vector.voidaddProductToArray(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 arrayvoidaddProductToArray(double factor, int offset, AVector other, int otherOffset, double[] array, int arrayOffset, int length)voidaddSparse(AVector v)Adds the corresponding elements of the source vector to the non-sparse elements of this vectorvoidaddSparse(double c)Adds to the non-sparse elements of this arrayvoidaddToArray(double[] array, int offset)Adds this vector to a double[] array, starting at the specified offset.voidaddToArray(double[] dest, int destOffset, int destStride)Adds this vector to a double[] array, using the specified offset and stride into the destination arrayvoidaddToArray(int offset, double[] array, int arrayOffset, int length)Adds a subvector of this vector into a double array at the specified offsetvoidaddWeighted(AVector v, double factor)Updates a weighted average of this vector with another vectordoubleangle(AVector v)Returns the Euclidean angle between this vector and another vectorvoidapplyOp(IOperator op)Applies a unary operator to all elements of the array (in-place)voidapplyOp(Op op)Applies a unary operator to all elements of the array (in-place)voidapplyOp(Op2 op, AVector b)Applies a binary operator to this vector and a second vectorvoidapplyOp(Op2 op, double b)Applies a binary operator to this array and a double value.voidapplyOp(Op2 op, INDArray b)Applies a binary operator to this array and a second array.AVectorapplyOpCopy(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 Listcontaining all elements of this array AVectorasVector()Constructs a view of all elements in the array as a single vector in row-major order.INDArraybroadcast(int... targetShape)Returns a view of this array broadcasted up to a larger shapeAMatrixbroadcastLike(AMatrix target)Broadcasts an array to match the shape of the target matrixAVectorbroadcastLike(AVector target)Broadcasts an array to match the shape of the target vectorINDArraybroadcastLike(INDArray target)Broadcasts an array to match the shape of the targetintcheckIndex(int i)Utility function to check an index and throw an exception in not in bounds.intcheckLength(int length)Checks that a vector is the specified length, throws an exception if not.intcheckRange(int offset, int length)Utility function to check vector range and throw an exception if not valid.voidclamp(double min, double max)Clamps all values in the vector to a given rangevoidclampMax(double max)voidclampMin(double min)AVectorclone()Clones the vector, creating a new mutable copy of all data.intcompareTo(AVector a)Compares this vector to another vectorintcompareTo(INDArray a)AVectorcopy()Returns a defensive copy of the array data.voidcopyTo(ADenseArrayVector dest, int destOffset)Copies a the contents of a vector to a vector at the specified offsetvoidcopyTo(AVector dest, int destOffset)Copies a the contents of a vector to a vector at the specified offsetvoidcopyTo(int offset, AVector dest, int destOffset, int length)Copies a subset of this vector to a vector at the specified offsetvoidcopyTo(int offset, double[] dest, int destOffset, int length)Copies a subset of this vector to a specified destination array offsetvoidcopyTo(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.voidcrossProduct(AVector a)Computes the crossProduct of this vector with another vector, and stores the result in this vector.voidcrossProduct(Vector3 a)Computes the crossProduct of this vector with another vector, and stores the result in this vector.AVectordense()Coerces this INDArray to a dense format, without changing its element values.VectordenseClone()Creates a fully mutable dense clone of this array.intdimensionality()Returns the dimensionality of the array (i.e.doubledistance(AVector v)Returns the Euclidean distance to another vector.doubledistanceL1(AVector v)Returns the distance from this vector to another vector according to the L1 (Taxicab) norm.doubledistanceLinf(AVector v)Returns the distance from this vector to another vector according to the Linf norm.doubledistanceSquared(AVector v)Returns the squared Euclidean distance to another vector.voiddivide(AVector v)voiddivide(double factor)Divides all elements by a given factorvoiddivide(double[] data, int offset)Divides the elements in this vector by corresponding elements in the target arrayvoiddivide(INDArray a)Divides all elements in place by the equivalent elements in a second arrayAVectordivideCopy(AVector a)Divides this vector element-wise by another vector, returning a new vector.AVectordivideCopy(double d)Returns a copy of the array with all elements divided by a single constant valueINDArraydivideCopy(INDArray a)Divides all elements by the equivalent elements in a second array.voiddivideTo(double[] data, int offset)Divides the elements in the target array by corresponding elements in this vectordoubledotProduct(ADenseArrayVector v)Returns the dot product of this vector with a target ADenseArrayVector.doubledotProduct(AVector v)Returns the dot product of this vector with another vector The vectors must have the same length: if not the result is undefineddoubledotProduct(AVector v, Index ix)Returns the dotProduct of this vector with the elements of another vector mapped to specified indexes in this vector.abstract doubledotProduct(double[] data, int offset)Fast dot product with a double[] array.doubledotProduct(double[] data, int offset, int stride)Fast dot product with a double[] array and a stride.doubleelementAbsPowSum(double exponent)Returns the sum of the absolute values of all the elements raised to a specified powerlongelementCount()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 orderdoubleelementMax()Returns the maximum element value in this array.doubleelementMaxAbs()Returns the maximum absolute element value in this vector.doubleelementMin()Returns the maximum element value in this array.doubleelementPowSum(double exponent)Returns the sum of all the elements raised to a specified powerdoubleelementProduct()Returns the product of all elements in the array.booleanelementsEqual(double value)Returns true if all elements are equal to a specific valuedoubleelementSquaredSum()Returns the sum of squared elements in this array.doubleelementSum()Returns the sum of all elements in a vectorbooleanepsilonEquals(AVector v)Returns true if this vector is approximately equal to another vector.booleanepsilonEquals(AVector v, double tolerance)booleanepsilonEquals(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 shapebooleanequals(AVector v)Returns true if this array is exactly equal to a vector.booleanequals(INDArray v)Checks if two arrays are equal exactly in terms of both value and shape Element equality checks are consistent with compareTobooleanequals(java.lang.Object o)Test for equality on vectors.booleanequalsArray(double[] data)Returns true if this vector exactly matches a double[] array.booleanequalsArray(double[] data, int offset)Returns true if this vector exactly matches the elements in double[] array, starting from the specified offsetabstract AVectorexactClone()Returns an exact clone of this vector, i.e.voidfill(double value)Fills the entire vector with a given valuevoidfillRange(int offset, int length, double value)doubleget()Returns the double value of a scalar arraydoubleget(AIndex ix)Returns the double value at the specified position in the arraydoubleget(int... indexes)Returns the double value at the specified index position in an arrayabstract doubleget(int i)Returns the double value at the specified position in a 1D vectordoubleget(int x, int y)Returns the double value at the specified position in a 2D matrixdoubleget(long i)Returns the double value at the specified position in a 1D vectordoubleget(long[] indexes)Returns the double value at the specified index position in an arraydoublegetElement(long i)Gets a specific element of this array, indexed in row-major ordervoidgetElements(double[] dest, int offset)Copies all elements of this array a double array at the specified offsetvoidgetElements(double[] dest, int destOffset, int[] indices)Gets the elements in this vector from the specified indices, storing at the specified offset in the destination arrayvoidgetElements(java.lang.Object[] dest, int offset)Copies all elements of this array into an object array at the specified offsetlong[]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.intgetShape(int dim)Returns the dimension size for a specific dimension in the array's shapeint[]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.AVectorgetTranspose()Returns the transpose of this array.AVectorgetTransposeCopy()Returns a transposed copy of the array.AVectorgetTransposeView()Returns a transposed view of the array.inthashCode()Computes the hashcode of a vector.booleanhasUncountable()Returns true if any element is this array is NaN or infiniteAVectorimmutable()Creates an immutable copy of a vectorScalarinnerProduct(ADenseArrayVector v)Overloaded inner product for dense array vector argumentAVectorinnerProduct(AMatrix m)Computes the inner product of this vector with a matrixAVectorinnerProduct(AScalar s)Computes the inner product of this vector with a scalarAScalarinnerProduct(AVector v)Computes the inner product of this vector with another vectorAVectorinnerProduct(double a)Calculates the inner product of this array with a double valueINDArrayinnerProduct(INDArray a)Calculates the inner product of this array with another array.voidinterpolate(AVector v, double alpha)Interpolates between this vector and a second vector, according to the ratio alpha.booleanisElementConstrained()Returns true if this array has some constraints on element valuesbooleanisFullyMutable()Returns true if this vector is fully mutable, i.e.booleanisMutable()Returns true if this vector is mutable.booleanisRangeZero(int start, int length)Returns true if a sub-vector range is completely zero.booleanisSameShape(AVector a)Returns true if this vector is exactly the same shape as another vector.booleanisSameShape(INDArray a)Returns true if this array is the same shape as another arraybooleanisUnitLengthVector()Returns true if the vector has unit lengthbooleanisUnitLengthVector(double tolerance)Returns true if the vector has unit length with the given tolerancebooleanisView()Returns true if this vector is of a view type that references other vectors / data.booleanisZero()Returns true if this vector is a zero vector (all components zero)java.util.Iterator<java.lang.Double>iterator()AVectorjoin(AVector second)AVectorjoin(INDArray b)Returns a new vector that refers to this vector joined to a second vector.INDArrayjoin(INDArray a, int dimension)Joins an array with another array along a specified dimension.abstract intlength()Returns the length of a vector, in terms of the number of elements.voidlog()Computes the natural logarithm (in-place) for all array elementsvoidlogistic()Computes the logistic function for every element in this vector.doublemagnitude()Returns the magnitude (Euclidean length) of the vectordoublemagnitudeSquared()Computes the squared magnitude (sum of squares) for this vectordoublemaxAbsElement()Returns the maximum absolute element value of a vectorintmaxAbsElementIndex()Returns the index of the maximum absolute element of a vectordoublemaxElement()Returns the maximum element value in a vector.intmaxElementIndex()Returns the index of the maximum element of a vectordoubleminElement()Returns the minimum element value in a vector.intminElementIndex()Returns the index of the minimum element of a vectorvoidmultiply(ADenseArrayVector v)voidmultiply(AVector v)Multiplies this vector by another vector, elementwise.voidmultiply(double factor)Multiplies the vector by a constant factorvoidmultiply(double[] data, int offset)Multiplies the elements in this vector by corresponding elements in the target arrayvoidmultiply(INDArray a)Multiplies all elements by the equivalent elements in a second array, i.e.AVectormultiplyCopy(AVector a)Multiplies a vector element-wise with this vector, returning a new vector.AVectormultiplyCopy(double d)Returns a copy of the array with all elements multiplied by a single constant valueINDArraymultiplyCopy(INDArray a)Multiplies all elements by the equivalent elements in a second array, i.e.voidmultiplyTo(double[] dest, int offset)Multiplies the elements in the target array by corresponding elements in this vectorAVectormutable()Coerces to a mutable version of a vector.voidnegate()Negates all emlements of this vector in place.AVectornegateCopy()Negates all elements in the array, returning a new arrayIndexnonSparseIndex()Returns an Index indicating which elements of this vector are defined as non-sparse.longnonZeroCount()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-zerodouble[]nonZeroValues()Return an double array specifying the values in this vector which are non-zerodoublenormalise()Normalises this vector to a magnitude of 1.0 Has no effect on a zero-length vector (i.e.AVectornormaliseCopy()Returns a copy of this vector normalised to a Euclidean length of 1.0 Has no effect on a zero-length vector (i.e.doublenormaliseMaxAbsElement()Normalises so that the maximum absolute element is 1.0 Returns the previous maximum absolute element.AMatrixouterProduct(AVector a)Computes the outer product of this vector with another vectorINDArrayouterProduct(INDArray a)Calculates the outer product of this array with another array.voidpow(double exponent)Raises all elements of the array to a specified power in placevoidprojectToPlane(AVector normal, double distance)Projects the vector to the plane defined by: x.normal=distancevoidreciprocal()Computes the reciprocal of all elements in this vector.AVectorreciprocalCopy()Computes the reciprocal of all elements in this vector.doublereduce(Op2 op)Reduces over all elements of the array in row-major order.doublereduce(Op2 op, double init)Reduces over all elements of the array in row-major order.AVectorreduceSlices(Op2 op)Reduces each vector slice of the array by the given binary operator Reduces down to a single vectorAVectorreduceSlices(Op2 op, double init)Reduces each slice of the array by the given binary operator.AVectorreorder(int[] order)Returns a re-ordered array by taking the specified order of slices along dimension 0AVectorreorder(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.INDArrayreshape(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 shapeAVectorrotateCopy(int shift)Rotates a vector by the specified number of elements, wrapping around element values.AVectorrotateView(int shift)Rotates a vector by the specified number of elements, wrapping around element values.INDArrayrotateView(int dimension, int shift)Returns rotated view of this arrayvoidscale(AVector v)Scales the vector by another vector of the same sizevoidscaleAdd(double factor, AVector v)Scales this vector then adds another vectorvoidscaleAdd(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 valuevoidscaleAdd(double factor, double constant)Scales this vector and adds a constant to every elementvoidscaleAdd(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 valueAVectorscaleCopy(double d)Scales all elements of the array by a given double value, returning a new arraydoublescaleToMagnitude(double targetMagnitude)Scales the vector up to a specific target magnitudeAVectorselect(int... indices)Selects a subset of indices from a vectorAVectorselectClone(int... inds)Selects a subset of indices from a vector, returning a mutable clone of dataAVectorselectView(int... indices)Selects a subset of indices from a vector, returning a viewvoidset(ADenseArrayVector v)Sets the vector equal to the value of an ADenseArrayVectorvoidset(AVector src)Sets the vector to equal the value of another vectorvoidset(AVector source, Index indexes)sets the vector using values indexed from another vectorvoidset(AVector src, int srcOffset)Set the vector equal to an offset into another vectorvoidset(AVector source, int[] indexes)sets the vector using values indexed from another vectorvoidset(double a)Sets all elements of an array to a specific double valuevoidset(INDArray a)Sets this array to the element values contained in another array.voidset(int[] indexes, double value)Sets the element at the given indexed position in a mutable arrayabstract voidset(int i, double value)Sets a value at a given position in a mutable 1D arrayvoidset(long[] indexes, double value)Sets the element at the given indexed position in a mutable arrayvoidset(long i, double value)voidsetApplyOp(Op op, AVector a)Sets this vector to the result of applying an operator to another vectorvoidsetApplyOp(Op op, double a)Sets this vector to the result of applying an operator to a double valuevoidsetApplyOp(Op op, INDArray a)Sets this array to the result of applying an operation to a source arrayvoidsetElements(double... data)Sets all elements in an array using the given double valuesvoidsetElements(double[] data, int offset)Sets all elements in an array using the given double valuesvoidsetElements(int pos, double[] values, int offset, int length)Sets elements in an array using the given double values.voidsetInnerProduct(AMatrix a, AVector b)Sets this vector to the inner product of the arguments (matrix a and vector b).voidsetInnerProduct(AVector a, AMatrix b)Sets this vector to the inner product of the arguments (vector a and matrix b) to this vector.voidsetInnerProduct(INDArray a, INDArray b)Sets this array to the inner product of two arrays.voidsetMultiple(AVector a, AVector b)Sets this vector to the element-wise product of two otehr vectorsvoidsetMultiple(AVector a, double b)Sets this vector to be a multiple of another vectorvoidsetMultiple(INDArray a, double b)Sets this array to be the multiple of another array.voidsetMultiple(INDArray a, INDArray b)Sets this array to the element-wise multiple of two arrays.voidsetSparse(AVector src)Sets the non-sparse elements of this vector to the corresponding elements of another vectorvoidsetSparse(double v)Sets the non-sparse elements of this array to the specified value May throw an exception if non-sparse elements are not mutablevoidsetSparse(INDArray src)Sets the non-sparse elements of this array to the corresponding elements of the source arrayAVectorshiftCopy(int shift)Shifts a vector by the specified number of elements, filling with zeros.voidsignum()Calculates the signum of all elements of this mutable array Sets each component of the array to its sign value (-1, 0 or 1)AScalarslice(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.AScalarslice(int dimension, int index)Returns a slice view of this array along the specified dimensionintsliceCount()Returns the number of major slices in this array (i.e.java.lang.ObjectsliceValue(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 vectorsvoidsoftmax()Computes the softmax function over this vector, mutating this vectorAVectorsoftmaxCopy()Computes the softmax function over this vector, returning a new mutable vectorAVectorsparse()Coerces this INDArray to a sparse format, without changing its element values.AVectorsparseClone()Clones the vector into a sparse mutable formatAVectorsqrtCopy()Computes the square root for each element in this vector, returning a new vector.voidsquare()Squares all elements of the array in placeAVectorsquareCopy()Squares all elements of the array, returning a new arrayvoidsub(AVector v)Subtracts a vector from this vectorvoidsub(INDArray a)Subtracts all the elements of another array from this array, in an elementwise order.AVectorsubArray(int[] offsets, int[] shape)Returns a subarray view of a larger arrayvoidsubAt(int i, double v)Subtracts a value from the specified element in this vector.AVectorsubCopy(AVector a)Subtracts a vector element-wise from this vector, returning a new vector.INDArraysubCopy(INDArray a)Creates a new array equal to the subtraction of another array from this arrayvoidsubMultiple(AVector v, double factor)Subtracts a scaled multiple of another vector from this vectorAVectorsubVector(int offset, int length)Obtains a sub-vector view that refers to this vector.voidtanh()Computes the tanh of every element in this vector.double[]toDoubleArray()Copies the elements of this array to a new double[] array.voidtoDoubleBuffer(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 vectorAVectortoNormal()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.StringtoString()java.lang.StringtoStringFull()VectortoVector()Coerces this vector to the standard dense Vector format.AVectortryEfficientJoin(AVector second)Attempts to perform an efficient join with a second vector.doubleunsafeGet(int i)Like get, but performs no bounds checking.voidunsafeSet(int i, double value)Like set, but performs no bounds checking.voidvalidate()Validates the internal data structure of the INDArray.abstract doublevisitNonZero(IndexedElementVisitor elementVisitor)Visits all non-zero elements of this vector.-
Methods inherited from class mikera.arrayz.impl.AbstractArray
add, addApplyOp, addCopy, addInnerProduct, addInnerProduct, addOuterProduct, addOuterProductSparse, addSparse, broadcastCloneLike, broadcastCopyLike, componentCount, density, ensureMutable, epsilonEquals, exp, get, get, getComponent, getComponents, getElements, getElements, getSlices, getSliceViews, isBoolean, isDense, isSparse, scale, set, set, signumCopy, sqrt, sub, sub, withComponents
-
Methods inherited from interface mikera.arrayz.INDArray
addApplyOp, addInnerProduct, addOuterProduct, addOuterProductSparse, addSparse, broadcastCloneLike, broadcastCopyLike, componentCount, ensureMutable, epsilonEquals, exp, get, get, getComponent, getComponents, getElements, getElements, getSlices, getSliceViews, isBoolean, isDense, isSparse, scale, set, set, signumCopy, sqrt, sub, withComponents
-
-
-
-
Method Detail
-
length
public abstract int length()
Description copied from interface:IVectorReturns the length of a vector, in terms of the number of elements. For Euclidean length, use magnitude() instead
-
get
public abstract double get(int i)
Description copied from interface:INDArrayReturns the double value at the specified position in a 1D vector
-
set
public abstract void set(int i, double value)Description copied from interface:INDArraySets a value at a given position in a mutable 1D array
-
get
public double get(long i)
Description copied from interface:INDArrayReturns the double value at the specified position in a 1D vector- Specified by:
getin interfaceINDArray- Overrides:
getin classAbstractArray<java.lang.Double>
-
set
public void set(long i, double value)
-
getElement
public final double getElement(long i)
Description copied from interface:INDArrayGets a specific element of this array, indexed in row-major order- Specified by:
getElementin interfaceINDArray- Returns:
- The element value
-
set
public void set(int[] indexes, double value)Description copied from interface:INDArraySets the element at the given indexed position in a mutable array
-
set
public void set(long[] indexes, double value)Description copied from interface:INDArraySets the element at the given indexed position in a mutable array- Specified by:
setin interfaceINDArray- Overrides:
setin classAbstractArray<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:INDArrayReturns the double value at the specified position in a 2D matrix- Specified by:
getin interfaceINDArray- Specified by:
getin classAbstractArray<java.lang.Double>
-
dimensionality
public final int dimensionality()
Description copied from interface:INDArrayReturns 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:
dimensionalityin interfaceINDArray
-
get
public final double get(int... indexes)
Description copied from interface:INDArrayReturns the double value at the specified index position in an array
-
get
public final double get(long[] indexes)
Description copied from interface:INDArrayReturns the double value at the specified index position in an array- Specified by:
getin interfaceINDArray- Overrides:
getin classAbstractArray<java.lang.Double>
-
get
public final double get(AIndex ix)
Description copied from interface:INDArrayReturns the double value at the specified position in the array- Specified by:
getin interfaceINDArray- Overrides:
getin classAbstractArray<java.lang.Double>
-
get
public double get()
Description copied from interface:INDArrayReturns the double value of a scalar array- Specified by:
getin interfaceINDArray- Specified by:
getin classAbstractArray<java.lang.Double>
-
slice
public AScalar slice(int position)
Description copied from interface:INDArrayReturns 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.
-
sliceValue
public java.lang.Object sliceValue(int i)
Description copied from interface:INDArrayReturns 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:
sliceValuein interfaceINDArray- Overrides:
sliceValuein classAbstractArray<java.lang.Double>
-
slice
public AScalar slice(int dimension, int index)
Description copied from interface:INDArrayReturns a slice view of this array along the specified dimension
-
sliceCount
public int sliceCount()
Description copied from interface:INDArrayReturns the number of major slices in this array (i.e. the size of dimension 0)- Specified by:
sliceCountin interfaceINDArray
-
getSlices
public java.util.List<java.lang.Double> getSlices()
Description copied from interface:INDArrayReturns 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:
getSlicesin interfaceINDArray- Overrides:
getSlicesin classAbstractArray<java.lang.Double>
-
getShape
public int[] getShape()
Description copied from interface:INDArrayReturns 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
-
getShapeClone
public int[] getShapeClone()
Description copied from interface:INDArrayReturns 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:
getShapeClonein interfaceINDArray- Overrides:
getShapeClonein classAbstractArray<java.lang.Double>
-
getShape
public final int getShape(int dim)
Description copied from interface:INDArrayReturns the dimension size for a specific dimension in the array's shape- Specified by:
getShapein interfaceINDArray- Overrides:
getShapein classAbstractArray<java.lang.Double>
-
getLongShape
public long[] getLongShape()
Description copied from interface:INDArrayReturns the shape of the array as an array of longs.- Specified by:
getLongShapein interfaceINDArray- Overrides:
getLongShapein classAbstractArray<java.lang.Double>
-
elementCount
public long elementCount()
Description copied from interface:INDArrayReturns the total number of elements in this array. Equivalent to the product of all dimension sizes.- Specified by:
elementCountin interfaceINDArray
-
nonZeroCount
public long nonZeroCount()
Description copied from interface:INDArrayReturns the number of non-zero elements in the array.- Specified by:
nonZeroCountin interfaceINDArray- Overrides:
nonZeroCountin classAbstractArray<java.lang.Double>
-
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:INDArrayReturns a subarray view of a larger array- Specified by:
subArrayin interfaceINDArray- Overrides:
subArrayin classAbstractArray<java.lang.Double>
-
rotateView
public INDArray rotateView(int dimension, int shift)
Description copied from interface:INDArrayReturns rotated view of this array- Specified by:
rotateViewin interfaceINDArray- Overrides:
rotateViewin classAbstractArray<java.lang.Double>
-
rotateView
public AVector rotateView(int shift)
Description copied from interface:IVectorRotates a vector by the specified number of elements, wrapping around element values. Returns a view.- Specified by:
rotateViewin interfaceIVector- Returns:
-
rotateCopy
public AVector rotateCopy(int shift)
Description copied from interface:IVectorRotates a vector by the specified number of elements, wrapping around element values. Returns a new vector.- Specified by:
rotateCopyin interfaceIVector- 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:
joinin interfaceINDArray- Overrides:
joinin classAbstractArray<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:INDArrayJoins an array with another array along a specified dimension. Guarantees a view that combines the two joined arrays.- Specified by:
joinin interfaceINDArray- Overrides:
joinin classAbstractArray<java.lang.Double>
-
compareTo
public int compareTo(INDArray a)
- Specified by:
compareToin interfacejava.lang.Comparable<INDArray>- Overrides:
compareToin classAbstractArray<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:
equalsin classAbstractArray<java.lang.Double>
-
equals
public boolean equals(AVector v)
Description copied from class:AbstractArrayReturns true if this array is exactly equal to a vector.- Overrides:
equalsin classAbstractArray<java.lang.Double>- Returns:
-
equals
public boolean equals(INDArray v)
Description copied from interface:INDArrayChecks if two arrays are equal exactly in terms of both value and shape Element equality checks are consistent with compareTo- Specified by:
equalsin interfaceINDArray- Overrides:
equalsin classAbstractArray<java.lang.Double>
-
equalsArray
public boolean equalsArray(double[] data)
Returns true if this vector exactly matches a double[] array.- Specified by:
equalsArrayin interfaceINDArray- Overrides:
equalsArrayin classAbstractArray<java.lang.Double>- Parameters:
data-- Returns:
-
elementsEqual
public boolean elementsEqual(double value)
Description copied from interface:INDArrayReturns true if all elements are equal to a specific value- Specified by:
elementsEqualin interfaceINDArray- Overrides:
elementsEqualin classAbstractArray<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:
equalsArrayin interfaceINDArray- Overrides:
equalsArrayin classAbstractArray<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:INDArrayTests is this array is approximately equal to another array, up to a given tolerance (epsilon) The arrays must have the same shape- Specified by:
epsilonEqualsin interfaceINDArray- Overrides:
epsilonEqualsin classAbstractArray<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:
-
epsilonEquals
public boolean epsilonEquals(AVector v, double tolerance)
- Specified by:
epsilonEqualsin interfaceIVector
-
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:
hashCodein classAbstractArray<java.lang.Double>
-
toDoubleArray
public double[] toDoubleArray()
Description copied from interface:INDArrayCopies the elements of this array to a new double[] array.- Specified by:
toDoubleArrayin interfaceINDArray- Overrides:
toDoubleArrayin classAbstractArray<java.lang.Double>
-
toSliceArray
public INDArray[] toSliceArray()
Description copied from interface:INDArrayCopies 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:
toSliceArrayin interfaceINDArray- Overrides:
toSliceArrayin classAbstractArray<java.lang.Double>
-
asDoubleArray
public double[] asDoubleArray()
Description copied from interface:INDArrayReturns 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:
asDoubleArrayin interfaceINDArray- Overrides:
asDoubleArrayin classAbstractArray<java.lang.Double>
-
toDoubleBuffer
public void toDoubleBuffer(java.nio.DoubleBuffer dest)
Description copied from interface:INDArrayCopies the elements of this INDArray to the specified double buffer.- Specified by:
toDoubleBufferin interfaceINDArray- Overrides:
toDoubleBufferin classAbstractArray<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:
fillin interfaceINDArray- Overrides:
fillin classAbstractArray<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:
clampin interfaceINDArray- Overrides:
clampin classAbstractArray<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:
multiplyin interfaceINDArray- Overrides:
multiplyin classAbstractArray<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:INDArrayMultiplies 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:
multiplyin interfaceINDArray- Overrides:
multiplyin classAbstractArray<java.lang.Double>
-
multiply
public void multiply(AVector v)
Multiplies this vector by another vector, elementwise.- Parameters:
v-
-
multiply
public final void multiply(ADenseArrayVector 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:INDArrayReturns a copy of the array with all elements multiplied by a single constant value- Specified by:
multiplyCopyin interfaceINDArray- Overrides:
multiplyCopyin classAbstractArray<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:INDArrayReturns a copy of the array with all elements divided by a single constant value- Specified by:
divideCopyin interfaceINDArray- Overrides:
divideCopyin classAbstractArray<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:INDArrayMultiplies 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:
multiplyCopyin interfaceINDArray- Overrides:
multiplyCopyin classAbstractArray<java.lang.Double>
-
multiplyCopy
public AVector multiplyCopy(AVector a)
Description copied from interface:IVectorMultiplies a vector element-wise with this vector, returning a new vector.- Specified by:
multiplyCopyin interfaceIVector- Returns:
-
divideCopy
public INDArray divideCopy(INDArray a)
Description copied from interface:INDArrayDivides all elements by the equivalent elements in a second array. Returns a new array.- Specified by:
divideCopyin interfaceINDArray- Overrides:
divideCopyin classAbstractArray<java.lang.Double>
-
divideCopy
public AVector divideCopy(AVector a)
Description copied from interface:IVectorDivides this vector element-wise by another vector, returning a new vector.- Specified by:
divideCopyin interfaceIVector- Returns:
-
divide
public void divide(double factor)
Description copied from interface:INDArrayDivides all elements by a given factor- Specified by:
dividein interfaceINDArray- Overrides:
dividein classAbstractArray<java.lang.Double>
-
divide
public void divide(INDArray a)
Description copied from interface:INDArrayDivides all elements in place by the equivalent elements in a second array- Specified by:
dividein interfaceINDArray- Overrides:
dividein classAbstractArray<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:INDArrayReplaces all elements of this array with their absolute values, according to Math.abs(double)- Specified by:
absin interfaceINDArray- Overrides:
absin classAbstractArray<java.lang.Double>
-
absCopy
public AVector absCopy()
Description copied from interface:INDArrayReturns a copy of the array with the abs operator applied to each element- Specified by:
absCopyin interfaceINDArray- Overrides:
absCopyin classAbstractArray<java.lang.Double>- Returns:
- A new array containing the absolute element values
-
absDiff
public void absDiff(INDArray a)
Description copied from interface:INDArraySets this array to the absolute values of the difference between this array and another- Specified by:
absDiffin interfaceINDArray- Overrides:
absDiffin classAbstractArray<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:INDArrayReturns an array containing the absolute values of the difference between this array and another- Specified by:
absDiffCopyin interfaceINDArray- Overrides:
absDiffCopyin classAbstractArray<java.lang.Double>- Returns:
- A new array containing the absolute element values
-
log
public void log()
Description copied from interface:INDArrayComputes the natural logarithm (in-place) for all array elements- Specified by:
login interfaceINDArray- Overrides:
login classAbstractArray<java.lang.Double>
-
signum
public void signum()
Description copied from interface:INDArrayCalculates 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:
signumin interfaceINDArray- Overrides:
signumin classAbstractArray<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:INDArraySquares all elements of the array in place- Specified by:
squarein interfaceINDArray- Overrides:
squarein classAbstractArray<java.lang.Double>
-
squareCopy
public AVector squareCopy()
Description copied from interface:INDArraySquares all elements of the array, returning a new array- Specified by:
squareCopyin interfaceINDArray- Overrides:
squareCopyin classAbstractArray<java.lang.Double>
-
sqrtCopy
public AVector sqrtCopy()
Description copied from interface:IVectorComputes the square root for each element in this vector, returning a new vector.
-
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:
reciprocalin interfaceINDArray- Overrides:
reciprocalin classAbstractArray<java.lang.Double>
-
reciprocalCopy
public AVector reciprocalCopy()
Computes the reciprocal of all elements in this vector. Mutates this vector- Specified by:
reciprocalCopyin interfaceINDArray- Overrides:
reciprocalCopyin classAbstractArray<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:INDArrayReturns 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:
getTransposein interfaceINDArray- Overrides:
getTransposein classAbstractArray<java.lang.Double>
-
getTransposeCopy
public AVector getTransposeCopy()
Description copied from interface:INDArrayReturns a transposed copy of the array. Guarantees a new defensive copy.- Specified by:
getTransposeCopyin interfaceINDArray- Overrides:
getTransposeCopyin classAbstractArray<java.lang.Double>
-
getTransposeView
public final AVector getTransposeView()
Description copied from interface:INDArrayReturns a transposed view of the array. May throw UnsupportedOperationException if the array type does not support this capability- Specified by:
getTransposeViewin interfaceINDArray- Overrides:
getTransposeViewin classAbstractArray<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
-
outerProduct
public final INDArray outerProduct(INDArray a)
Description copied from interface:INDArrayCalculates the outer product of this array with another array.- Specified by:
outerProductin interfaceINDArray- Overrides:
outerProductin classAbstractArray<java.lang.Double>
-
innerProduct
public AScalar innerProduct(AVector v)
Computes the inner product of this vector with another vector- Specified by:
innerProductin interfaceINDArray- Overrides:
innerProductin classAbstractArray<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:
innerProductin interfaceINDArray- Overrides:
innerProductin classAbstractArray<java.lang.Double>- Parameters:
s- A scalar instance- Returns:
- a vector representing the inner product
-
innerProduct
public INDArray innerProduct(INDArray a)
Description copied from interface:INDArrayCalculates the inner product of this array with another array.- Specified by:
innerProductin interfaceINDArray- Overrides:
innerProductin classAbstractArray<java.lang.Double>
-
innerProduct
public final AVector innerProduct(double a)
Description copied from interface:INDArrayCalculates the inner product of this array with a double value- Specified by:
innerProductin interfaceINDArray- Overrides:
innerProductin classAbstractArray<java.lang.Double>
-
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:
elementSumin interfaceINDArray- Overrides:
elementSumin classAbstractArray<java.lang.Double>- Returns:
-
elementProduct
public double elementProduct()
Description copied from interface:INDArrayReturns the product of all elements in the array.- Specified by:
elementProductin interfaceINDArray- Overrides:
elementProductin classAbstractArray<java.lang.Double>- Returns:
-
elementMax
public double elementMax()
Description copied from interface:INDArrayReturns the maximum element value in this array. Throws an error if there are no elements.- Specified by:
elementMaxin interfaceINDArray- Overrides:
elementMaxin classAbstractArray<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:
elementMaxAbsin interfaceINDArray- Overrides:
elementMaxAbsin classAbstractArray<java.lang.Double>
-
elementMin
public double elementMin()
Description copied from interface:INDArrayReturns the maximum element value in this array. Throws an error if there are no elements.- Specified by:
elementMinin interfaceINDArray- Overrides:
elementMinin classAbstractArray<java.lang.Double>
-
elementSquaredSum
public double elementSquaredSum()
Description copied from interface:INDArrayReturns the sum of squared elements in this array.- Specified by:
elementSquaredSumin interfaceINDArray- Overrides:
elementSquaredSumin classAbstractArray<java.lang.Double>
-
elementPowSum
public double elementPowSum(double exponent)
Description copied from class:AbstractArrayReturns the sum of all the elements raised to a specified power- Specified by:
elementPowSumin interfaceINDArray- Overrides:
elementPowSumin classAbstractArray<java.lang.Double>- Returns:
-
elementAbsPowSum
public double elementAbsPowSum(double exponent)
Description copied from class:AbstractArrayReturns the sum of the absolute values of all the elements raised to a specified power- Specified by:
elementAbsPowSumin interfaceINDArray- Overrides:
elementAbsPowSumin classAbstractArray<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)
-
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:
normaliseCopyin interfaceIVector- Returns:
-
negate
public void negate()
Negates all emlements of this vector in place.- Specified by:
negatein interfaceINDArray- Overrides:
negatein classAbstractArray<java.lang.Double>
-
negateCopy
public AVector negateCopy()
Description copied from interface:INDArrayNegates all elements in the array, returning a new array- Specified by:
negateCopyin interfaceINDArray- Overrides:
negateCopyin classAbstractArray<java.lang.Double>
-
scaleCopy
public final AVector scaleCopy(double d)
Description copied from interface:INDArrayScales all elements of the array by a given double value, returning a new array- Specified by:
scaleCopyin interfaceINDArray- Overrides:
scaleCopyin classAbstractArray<java.lang.Double>
-
shiftCopy
public AVector shiftCopy(int shift)
Description copied from interface:IVectorShifts a vector by the specified number of elements, filling with zeros. Returns a new vector.
-
pow
public void pow(double exponent)
Description copied from interface:INDArrayRaises all elements of the array to a specified power in place- Specified by:
powin interfaceINDArray- Overrides:
powin classAbstractArray<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:INDArraySets all elements of an array to a specific double value- Specified by:
setin interfaceINDArray- Overrides:
setin classAbstractArray<java.lang.Double>
-
setElements
public void setElements(double... data)
Description copied from interface:INDArraySets all elements in an array using the given double values- Specified by:
setElementsin interfaceINDArray- Overrides:
setElementsin classAbstractArray<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:INDArraySets all elements in an array using the given double values- Specified by:
setElementsin interfaceINDArray- Overrides:
setElementsin classAbstractArray<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:INDArraySets 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:
setin interfaceINDArray- Overrides:
setin classAbstractArray<java.lang.Double>
-
setElements
public void setElements(int pos, double[] values, int offset, int length)Description copied from interface:INDArraySets 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:
setElementsin interfaceINDArray- Overrides:
setElementsin classAbstractArray<java.lang.Double>- Parameters:
pos- Offset into this array, expressed in terms of number of elements in row major ordervalues- 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:INDArrayCopies all elements of this array a double array at the specified offset- Specified by:
getElementsin interfaceINDArray- Overrides:
getElementsin classAbstractArray<java.lang.Double>
-
getElements
public void getElements(java.lang.Object[] dest, int offset)Description copied from interface:INDArrayCopies all elements of this array into an object array at the specified offset- Specified by:
getElementsin interfaceINDArray- Overrides:
getElementsin classAbstractArray<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)
-
copy
public AVector copy()
Description copied from interface:INDArrayReturns 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:
copyin interfaceINDArray- Overrides:
copyin classAbstractArray<java.lang.Double>
-
sparseClone
public AVector sparseClone()
Clones the vector into a sparse mutable format- Specified by:
sparseClonein interfaceINDArray- Overrides:
sparseClonein classAbstractArray<java.lang.Double>
-
asVector
public final AVector asVector()
Description copied from interface:INDArrayConstructs a view of all elements in the array as a single vector in row-major order.- Specified by:
asVectorin interfaceINDArray- Overrides:
asVectorin classAbstractArray<java.lang.Double>
-
reshape
public INDArray reshape(int... dimensions)
Description copied from interface:INDArrayReturns 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:
reshapein interfaceINDArray- Overrides:
reshapein classAbstractArray<java.lang.Double>
-
reorder
public final AVector reorder(int[] order)
Description copied from interface:INDArrayReturns a re-ordered array by taking the specified order of slices along dimension 0- Specified by:
reorderin interfaceINDArray- Overrides:
reorderin classAbstractArray<java.lang.Double>
-
reorder
public final AVector reorder(int dim, int[] order)
Description copied from interface:INDArrayReturns 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:
reorderin interfaceINDArray- Overrides:
reorderin classAbstractArray<java.lang.Double>
-
isView
public boolean isView()
Returns true if this vector is of a view type that references other vectors / data.
-
isMutable
public boolean isMutable()
Returns true if this vector is mutable.- Specified by:
isMutablein interfaceINDArray- Overrides:
isMutablein classAbstractArray<java.lang.Double>
-
isElementConstrained
public boolean isElementConstrained()
Description copied from interface:INDArrayReturns true if this array has some constraints on element values- Specified by:
isElementConstrainedin interfaceINDArray- Overrides:
isElementConstrainedin classAbstractArray<java.lang.Double>
-
isFullyMutable
public boolean isFullyMutable()
Returns true if this vector is fully mutable, i.e. can contain any unconstrained double values- Specified by:
isFullyMutablein interfaceINDArray- Overrides:
isFullyMutablein classAbstractArray<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:INDArrayAdds all the elements of another array to this array, in an elementwise order.- Specified by:
addin interfaceINDArray- Overrides:
addin classAbstractArray<java.lang.Double>
-
addCopy
public final INDArray addCopy(INDArray a)
Description copied from interface:INDArrayCreates a new array equal to the sum of this array with another array.- Specified by:
addCopyin interfaceINDArray- Overrides:
addCopyin classAbstractArray<java.lang.Double>- Returns:
-
addCopy
public AVector addCopy(AVector a)
Description copied from interface:IVectorAdds a vector element-wise to this vector, returning a new vector.
-
addCopy
public AVector addCopy(double a)
Description copied from interface:INDArrayCreates a new array equal to this array with a constant value added to every element- Specified by:
addCopyin interfaceINDArray- Overrides:
addCopyin classAbstractArray<java.lang.Double>- Returns:
-
subCopy
public final INDArray subCopy(INDArray a)
Description copied from interface:INDArrayCreates a new array equal to the subtraction of another array from this array- Specified by:
subCopyin interfaceINDArray- Overrides:
subCopyin classAbstractArray<java.lang.Double>- Returns:
-
subCopy
public AVector subCopy(AVector a)
Description copied from interface:IVectorSubtracts a vector element-wise from this vector, returning a new vector.
-
sub
public void sub(INDArray a)
Description copied from interface:INDArraySubtracts all the elements of another array from this array, in an elementwise order.- Specified by:
subin interfaceINDArray- Overrides:
subin classAbstractArray<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(INDArray src, double factor)
Description copied from interface:INDArrayAdds a scaled multiple of another array to this array- Specified by:
addMultiplein interfaceINDArray- Overrides:
addMultiplein classAbstractArray<java.lang.Double>
-
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:INDArrayScales all elements of the array by a given double value, adds a scaled second array and adds a constant value- Specified by:
scaleAddin interfaceINDArray- Overrides:
scaleAddin classAbstractArray<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:INDArrayAdds an array with all elements of the source array raised to the specified power- Specified by:
addPowerin interfaceINDArray- Overrides:
addPowerin classAbstractArray<java.lang.Double>
-
addPower
public void addPower(INDArray src, double exponent, double factor)
Description copied from interface:INDArrayAdds an array with all elements raised to the specified power and scaled by the given factor- Specified by:
addPowerin interfaceINDArray- Overrides:
addPowerin classAbstractArray<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:
isZeroin interfaceINDArray- Overrides:
isZeroin classAbstractArray<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 final boolean isSameShape(INDArray a)
Description copied from interface:INDArrayReturns true if this array is the same shape as another array- Specified by:
isSameShapein interfaceINDArray- Overrides:
isSameShapein classAbstractArray<java.lang.Double>
-
isSameShape
public boolean isSameShape(AVector a)
Description copied from interface:IVectorReturns true if this vector is exactly the same shape as another vector.- Specified by:
isSameShapein interfaceIVector- 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 lengthdistance-
-
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:
toStringin classAbstractArray<java.lang.Double>
-
toStringFull
public java.lang.String toStringFull()
- Overrides:
toStringFullin classAbstractArray<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:
toVectorin interfaceINDArray- Overrides:
toVectorin classAbstractArray<java.lang.Double>
-
immutable
public AVector immutable()
Creates an immutable copy of a vector- Specified by:
immutablein interfaceINDArray- Overrides:
immutablein classAbstractArray<java.lang.Double>- Returns:
-
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:
mutablein interfaceINDArray- Overrides:
mutablein classAbstractArray<java.lang.Double>- Returns:
-
sparse
public AVector sparse()
Description copied from interface:INDArrayCoerces 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:
sparsein interfaceINDArray- Overrides:
sparsein classAbstractArray<java.lang.Double>
-
dense
public AVector dense()
Description copied from interface:INDArrayCoerces 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:
densein interfaceINDArray- Overrides:
densein classAbstractArray<java.lang.Double>
-
denseClone
public final Vector denseClone()
Description copied from interface:INDArrayCreates a fully mutable dense clone of this array. Will always use a dense format, even if the array data is sparse.- Specified by:
denseClonein interfaceINDArray- Overrides:
denseClonein classAbstractArray<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:INDArrayReturns a Listcontaining all elements of this array - Specified by:
asElementListin interfaceINDArray- Overrides:
asElementListin classAbstractArray<java.lang.Double>
-
iterator
public java.util.Iterator<java.lang.Double> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.Double>- Overrides:
iteratorin classAbstractArray<java.lang.Double>
-
elementIterator
public final java.util.Iterator<java.lang.Double> elementIterator()
Description copied from interface:INDArrayReturns an iterator over all elements in this array, in row-major order- Specified by:
elementIteratorin interfaceINDArray- Overrides:
elementIteratorin classAbstractArray<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:INDArrayAdds to the non-sparse elements of this array- Specified by:
addSparsein interfaceINDArray- Overrides:
addSparsein classAbstractArray<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:INDArraySets the non-sparse elements of this array to the corresponding elements of the source array- Specified by:
setSparsein interfaceINDArray- Overrides:
setSparsein classAbstractArray<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:INDArraySets the non-sparse elements of this array to the specified value May throw an exception if non-sparse elements are not mutable- Specified by:
setSparsein interfaceINDArray- Overrides:
setSparsein classAbstractArray<java.lang.Double>
-
addMultipleSparse
public void addMultipleSparse(INDArray a, double factor)
Description copied from interface:INDArrayAdds a multiple of the source array to the non-sparse elements of this array- Specified by:
addMultipleSparsein interfaceINDArray- Overrides:
addMultipleSparsein classAbstractArray<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:
addToArrayin interfaceINDArray- Overrides:
addToArrayin classAbstractArray<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-
-
setInnerProduct
public final void setInnerProduct(INDArray a, INDArray b)
Description copied from interface:INDArraySets this array to the inner product of two arrays. Must be the correct shape.- Specified by:
setInnerProductin interfaceINDArray- Overrides:
setInnerProductin classAbstractArray<java.lang.Double>
-
addInnerProduct
public void addInnerProduct(AMatrix a, INDArray b)
Description copied from class:AbstractArrayAdds the inner product of a matrix and an array to this array- Overrides:
addInnerProductin classAbstractArray<java.lang.Double>
-
addInnerProduct
public final void addInnerProduct(INDArray a, INDArray b)
Description copied from interface:INDArrayAdds the inner product of two arrays to this array.- Specified by:
addInnerProductin interfaceINDArray- Overrides:
addInnerProductin classAbstractArray<java.lang.Double>
-
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 vectorb- 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 bb- 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 vectorb- 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 bb- A matrix with the same number of columns as this vector
-
setMultiple
public final void setMultiple(INDArray a, INDArray b)
Description copied from interface:INDArraySets this array to the element-wise multiple of two arrays. Must have compatible shapes.- Specified by:
setMultiplein interfaceINDArray- Overrides:
setMultiplein classAbstractArray<java.lang.Double>
-
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:INDArraySets this array to be the multiple of another array. Must have compatible shapes.- Specified by:
setMultiplein interfaceINDArray- Overrides:
setMultiplein classAbstractArray<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:INDArrayApplies a unary operator to all elements of the array (in-place)- Specified by:
applyOpin interfaceINDArray- Overrides:
applyOpin classAbstractArray<java.lang.Double>- Parameters:
op- The operator to apply to the array
-
applyOp
public void applyOp(Op op)
Description copied from interface:INDArrayApplies a unary operator to all elements of the array (in-place)- Specified by:
applyOpin interfaceINDArray- Overrides:
applyOpin classAbstractArray<java.lang.Double>
-
applyOp
public void applyOp(Op2 op, INDArray b)
Description copied from interface:INDArrayApplies a binary operator to this array and a second array. Broadcasts the second array to the shape of this array if required.- Specified by:
applyOpin interfaceINDArray- Overrides:
applyOpin classAbstractArray<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:INDArrayApplies 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:
applyOpin interfaceINDArray- Overrides:
applyOpin classAbstractArray<java.lang.Double>
-
applyOpCopy
public AVector applyOpCopy(Op op)
Description copied from interface:INDArrayApplies a unary operator to all elements of the array (creating a new array)- Specified by:
applyOpCopyin interfaceINDArray- Overrides:
applyOpCopyin classAbstractArray<java.lang.Double>
-
setApplyOp
public final void setApplyOp(Op op, INDArray a)
Description copied from interface:INDArraySets this array to the result of applying an operation to a source array- Specified by:
setApplyOpin interfaceINDArray- Overrides:
setApplyOpin classAbstractArray<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:INDArrayReduces 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:
reducein interfaceINDArray- Overrides:
reducein classAbstractArray<java.lang.Double>
-
reduce
public double reduce(Op2 op)
Description copied from interface:INDArrayReduces 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:
reducein interfaceINDArray- Overrides:
reducein classAbstractArray<java.lang.Double>
-
reduceSlices
public final AVector reduceSlices(Op2 op)
Description copied from interface:INDArrayReduces each vector slice of the array by the given binary operator Reduces down to a single vector- Specified by:
reduceSlicesin interfaceINDArray- Overrides:
reduceSlicesin classAbstractArray<java.lang.Double>
-
reduceSlices
public AVector reduceSlices(Op2 op, double init)
Description copied from interface:INDArrayReduces 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:
reduceSlicesin interfaceINDArray- Overrides:
reduceSlicesin classAbstractArray<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:INDArrayAdds to a mutable array, indexed by element position in row major order. This is an unsafe operation: bounds are not checked- Specified by:
addAtin interfaceINDArray- Overrides:
addAtin classAbstractArray<java.lang.Double>
-
scaleAdd
public void scaleAdd(double factor, double constant)Scales this vector and adds a constant to every element- Specified by:
scaleAddin interfaceINDArray- Overrides:
scaleAddin classAbstractArray<java.lang.Double>
-
add
public void add(double constant)
Description copied from interface:INDArrayAdds a double value to all elements in this array. Implementations may optimize the case of 0.0- Specified by:
addin interfaceINDArray- Overrides:
addin classAbstractArray<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:
exactClonein interfaceINDArray- Returns:
-
broadcast
public INDArray broadcast(int... targetShape)
Description copied from interface:INDArrayReturns a view of this array broadcasted up to a larger shape- Specified by:
broadcastin interfaceINDArray- Overrides:
broadcastin classAbstractArray<java.lang.Double>
-
broadcastLike
public INDArray broadcastLike(INDArray target)
Description copied from interface:INDArrayBroadcasts an array to match the shape of the target- Specified by:
broadcastLikein interfaceINDArray- Overrides:
broadcastLikein classAbstractArray<java.lang.Double>- Parameters:
target- The target array
-
broadcastLike
public AVector broadcastLike(AVector target)
Description copied from interface:INDArrayBroadcasts an array to match the shape of the target vector- Specified by:
broadcastLikein interfaceINDArray- Overrides:
broadcastLikein classAbstractArray<java.lang.Double>- Parameters:
target- The target vector
-
broadcastLike
public AMatrix broadcastLike(AMatrix target)
Description copied from interface:INDArrayBroadcasts an array to match the shape of the target matrix- Specified by:
broadcastLikein interfaceINDArray- Overrides:
broadcastLikein classAbstractArray<java.lang.Double>- Parameters:
target- The target matrix
-
validate
public void validate()
Description copied from interface:INDArrayValidates the internal data structure of the INDArray. Throws an exception on failure. Failure indicates a serious bug and/or data corruption.- Specified by:
validatein interfaceINDArray- Overrides:
validatein classAbstractArray<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:AbstractArrayReturns true if any element is this array is NaN or infinite- Specified by:
hasUncountablein interfaceINDArray- Overrides:
hasUncountablein classAbstractArray<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