mikera.vectorz.impl
Class ZeroVector
- java.lang.Object
-
- mikera.arrayz.impl.AbstractArray<java.lang.Double>
-
- mikera.vectorz.AVector
-
- mikera.vectorz.impl.ASizedVector
-
- mikera.vectorz.impl.ASparseVector
-
- mikera.vectorz.impl.ZeroVector
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<java.lang.Double>, INDArray, ISparse, ISparseVector, IVector
public final class ZeroVector extends ASparseVector
Specialised immutable vector containing nothing but zeros. This enables significant optimisations on operations involving zeros and composite arrays that have zero areas. Must have length 1 or more: use Vector0 instead for immutable length 0 vectors.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description ZeroVectorabsCopy()Returns a copy of the array with the abs operator applied to each elementvoidadd(ASparseVector v)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 elementvoidaddMultipleToArray(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 offsetvoidaddSparse(AVector v)Adds the corresponding elements of the source vector to the non-sparse elements of this vectorvoidaddToArray(double[] dest, int offset, int stride)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 offsetAVectorapplyOpCopy(Op op)Applies a unary operator to all elements of the array (creating a new array)voidcopyTo(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.static ZeroVectorcreate(INDArray array)Creates a ZeroVector with the same number of elements as the given array.static ZeroVectorcreate(int dimensions)Create a ZeroVector with the specified number of dimensionsstatic ZeroVectorcreateCached(int dimensions)static ZeroVectorcreateNew(int dimensions)doubledensity()Computes the density ratio of this sparse array (proportion of non-zero elements)ZeroVectordivideCopy(AVector a)Divides this vector element-wise by another vector, returning a new vector.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(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 p)Returns the sum of the absolute values of all the elements raised to a specified powerdoubleelementMax()Returns the maximum element value in this array.doubleelementMin()Returns the maximum element value in this array.doubleelementPowSum(double p)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 vectorbooleanequals(AVector v)Returns true if this array is exactly equal to a vector.booleanequalsArray(double[] data, int offset)Returns true if this vector exactly matches the elements in double[] array, starting from the specified offsetZeroVectorexactClone()Returns an exact clone of this vector, i.e.doubleget(int i)Returns the double value at the specified position in a 1D vectorvoidgetElements(double[] dest, int offset)Copies all elements of this array a double array at the specified offsetvoidgetElements(java.lang.Object[] dest, int offset)Copies all elements of this array into an object array at the specified offsetinthashCode()Computes the hashcode of a vector.booleanhasUncountable()Returns true if any element is this array is NaN or infinitebooleanincludesIndex(int i)Returns true iff the sparse vector contains the index iScalarinnerProduct(ADenseArrayVector v)Overloaded inner product for dense array vector argumentAVectorinnerProduct(AMatrix m)Computes the inner product of this vector with a matrixbooleanisBoolean()Returns true if the array is boolean (contains only 0.0 or 1.0 values)booleanisFullyMutable()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.booleanisUnitLengthVector()Returns true if the vector has unit lengthbooleanisZero()Returns true if this vector is a zero vector (all components zero)java.util.Iterator<java.lang.Double>iterator()ZeroVectorjoin(ZeroVector a)doublemagnitude()Returns the magnitude (Euclidean length) of the vectordoublemaxAbsElement()Returns the maximum absolute element value of a vectorintmaxAbsElementIndex()Returns the index of the maximum absolute element of a vectorintmaxElementIndex()Returns the index of the maximum element of a vectorintminElementIndex()Returns the index of the minimum element of a vectorvoidmultiply(AVector a)Multiplies this vector by another vector, elementwise.voidmultiply(double factor)Multiplies the vector by a constant factorZeroVectormultiplyCopy(AVector a)Multiplies a vector element-wise with this vector, returning a new vector.ZeroVectormultiplyCopy(double factor)Returns a copy of the array with all elements multiplied by a single constant valueintnonSparseElementCount()Returns the number of non-sparse elements in the sparse vector.IndexnonSparseIndex()Returns an Index indicating which elements of this vector are defined as non-sparse.AVectornonSparseValues()Returns the non-sparse elements as a compacted vector.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-zeroAVectornormaliseCopy()Returns a copy of this vector normalised to a Euclidean length of 1.0 Has no effect on a zero-length vector (i.e.RepeatedElementVectorreciprocalCopy()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.AVectorselect(int... order)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... inds)Selects a subset of indices from a vector, returning a viewvoidset(int i, double value)Sets a value at a given position in a mutable 1D arrayvoidsetSparse(double value)Sets the non-sparse elements of this array to the specified value May throw an exception if non-sparse elements are not mutableImmutableScalarslice(int i)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.AVectorsparseClone()Clones the vector into a sparse mutable formatAVectorsquareCopy()Squares all elements of the array, returning a new arrayAVectorsubCopy(AVector a)Subtracts a vector element-wise from this vector, returning a new vector.AVectorsubVector(int offset, int length)Obtains a sub-vector view that refers to this vector.double[]toDoubleArray()Copies the elements of this array to a new double[] array.AVectortryEfficientJoin(AVector a)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.doublevisitNonZero(IndexedElementVisitor elementVisitor)Visits all non-zero elements of this vector.-
Methods inherited from class mikera.vectorz.impl.ASparseVector
add, addMultiple, clone, copyTo, distanceL1, distanceLinf, distanceSquared, dotProduct, equals, getSlices, isSparse, isView, reduceSlices, roundToZero, sparse, toSparseIndexedVector
-
Methods inherited from class mikera.vectorz.impl.ASizedVector
checkIndex, checkLength, checkRange, elementCount, equalsArray, get, getShape, getShapeClone, isSameShape, length, sliceCount
-
Methods inherited from class mikera.vectorz.AVector
abs, absDiff, absDiff, absDiff, absDiffCopy, add, add, add, add, add, add, add, add, addAt, addAt, addCopy, addInnerProduct, addInnerProduct, addInnerProduct, addInnerProduct, addMultiple, addMultiple, addMultiple, addMultiple, addMultiple, addMultiple, addMultiple, addMultipleCopy, addMultipleSparse, addMultipleSparse, addMultipleToArray, addPower, addPower, addProduct, addProduct, addProduct, addProductCopy, addProductCopy, addProductToArray, addProductToArray, addSparse, addToArray, addWeighted, angle, applyOp, applyOp, applyOp, applyOp, applyOp, asDoubleArray, asElementList, asVector, broadcast, broadcastLike, broadcastLike, broadcastLike, clamp, clampMax, clampMin, compareTo, compareTo, copy, copyTo, copyTo, copyTo, crossProduct, crossProduct, dense, denseClone, dimensionality, distance, divide, divide, divide, divide, divideCopy, divideCopy, divideTo, dotProduct, elementIterator, elementMaxAbs, epsilonEquals, epsilonEquals, epsilonEquals, equals, equals, fill, fillRange, get, get, get, get, get, getElement, getElements, getLongShape, getShape, getTranspose, getTransposeCopy, getTransposeView, immutable, innerProduct, innerProduct, innerProduct, innerProduct, interpolate, isElementConstrained, isSameShape, isUnitLengthVector, join, join, join, log, logistic, magnitudeSquared, maxElement, minElement, multiply, multiply, multiply, multiplyCopy, multiplyTo, mutable, negate, negateCopy, normalise, normaliseMaxAbsElement, outerProduct, outerProduct, pow, projectToPlane, reciprocal, reduceSlices, reorder, reorder, reshape, rotateCopy, rotateView, rotateView, scale, scaleAdd, scaleAdd, scaleAdd, scaleAdd, scaleCopy, scaleToMagnitude, set, set, set, set, set, set, set, set, set, set, setApplyOp, setApplyOp, setApplyOp, setElements, setElements, setElements, setInnerProduct, setInnerProduct, setInnerProduct, setMultiple, setMultiple, setMultiple, setMultiple, setSparse, setSparse, shiftCopy, signum, slice, sliceValue, softmax, softmaxCopy, sqrtCopy, square, sub, sub, subArray, subAt, subCopy, subMultiple, tanh, toDoubleBuffer, toList, toNormal, toSliceArray, toString, toStringFull, toVector, validate
-
Methods inherited from class mikera.arrayz.impl.AbstractArray
add, addApplyOp, addCopy, addInnerProduct, addInnerProduct, addOuterProduct, addOuterProductSparse, addSparse, broadcastCloneLike, broadcastCopyLike, componentCount, ensureMutable, epsilonEquals, exp, get, get, getComponent, getComponents, getElements, getElements, getSlices, getSliceViews, isDense, scale, set, set, signumCopy, sqrt, sub, sub, withComponents
-
Methods inherited from interface mikera.vectorz.IVector
epsilonEquals, isSameShape, length, normalise, rotateCopy, rotateView, shiftCopy, sqrtCopy
-
Methods inherited from interface mikera.arrayz.INDArray
abs, absDiff, absDiffCopy, add, add, addApplyOp, addAt, addCopy, addInnerProduct, addInnerProduct, addMultiple, addMultipleSparse, addOuterProduct, addOuterProductSparse, addPower, addPower, addSparse, addSparse, addToArray, applyOp, applyOp, applyOp, applyOp, asDoubleArray, asElementList, asVector, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, broadcastLike, clamp, componentCount, copy, dense, denseClone, dimensionality, divide, divide, divideCopy, divideCopy, elementCount, elementIterator, elementMaxAbs, ensureMutable, epsilonEquals, epsilonEquals, equals, equalsArray, exp, fill, get, get, get, get, get, get, get, get, getComponent, getComponents, getElement, getElements, getElements, getLongShape, getShape, getShape, getShapeClone, getSlices, getSliceViews, getTranspose, getTransposeCopy, getTransposeView, immutable, innerProduct, innerProduct, innerProduct, innerProduct, isDense, isElementConstrained, isSameShape, join, join, log, multiply, multiplyCopy, mutable, negate, negateCopy, outerProduct, pow, reciprocal, reduceSlices, reorder, reorder, reshape, rotateView, scale, scaleAdd, scaleAdd, scaleCopy, set, set, set, set, set, set, setApplyOp, setElements, setElements, setElements, setInnerProduct, setMultiple, setMultiple, setSparse, signum, signumCopy, slice, sliceCount, sliceValue, sqrt, square, sub, sub, subArray, subCopy, toDoubleBuffer, toSliceArray, toVector, validate, withComponents
-
-
-
-
Method Detail
-
create
public static ZeroVector create(int dimensions)
Create a ZeroVector with the specified number of dimensions- Parameters:
dimensions-- Returns:
-
createNew
public static ZeroVector createNew(int dimensions)
-
createCached
public static ZeroVector createCached(int dimensions)
-
create
public static ZeroVector create(INDArray array)
Creates a ZeroVector with the same number of elements as the given array.- Parameters:
arraySize-- Returns:
-
dotProduct
public double dotProduct(AVector v)
Description copied from class:AVectorReturns the dot product of this vector with another vector The vectors must have the same length: if not the result is undefined- Specified by:
dotProductin classASparseVector- Returns:
-
dotProduct
public double dotProduct(double[] data, int offset)Description copied from class:AVectorFast dot product with a double[] array. Performs no bounds checking. Likely to be faster than most other dot product operations- Specified by:
dotProductin classAVector
-
innerProduct
public AVector innerProduct(AMatrix m)
Description copied from class:AVectorComputes the inner product of this vector with a matrix- Overrides:
innerProductin classASparseVector- Returns:
- a vector representing the inner product
-
innerProduct
public Scalar innerProduct(ADenseArrayVector v)
Description copied from class:AVectorOverloaded inner product for dense array vector argument- Overrides:
innerProductin classAVector- Returns:
-
get
public double get(int i)
Description copied from interface:INDArrayReturns the double value at the specified position in a 1D vector
-
set
public void set(int i, double value)Description copied from interface:INDArraySets a value at a given position in a mutable 1D array
-
setSparse
public void setSparse(double value)
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
-
unsafeGet
public double unsafeGet(int i)
Description copied from class:AVectorLike get, but performs no bounds checking. Results are undefined if the index is out of range
-
unsafeSet
public void unsafeSet(int i, double value)Description copied from class:AVectorLike set, but performs no bounds checking. Results are undefined if the index is out of range
-
add
public void add(ASparseVector v)
- Specified by:
addin classASparseVector
-
addSparse
public void addSparse(AVector v)
Description copied from class:AVectorAdds the corresponding elements of the source vector to the non-sparse elements of this vector
-
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
-
subCopy
public AVector subCopy(AVector a)
Description copied from interface:IVectorSubtracts a vector element-wise from this vector, returning a new vector.
-
reciprocalCopy
public RepeatedElementVector reciprocalCopy()
Description copied from class:AVectorComputes the reciprocal of all elements in this vector. Mutates this vector- Specified by:
reciprocalCopyin interfaceINDArray- Overrides:
reciprocalCopyin classAVector
-
absCopy
public ZeroVector absCopy()
Description copied from interface:INDArrayReturns a copy of the array with the abs operator applied to each element
-
multiply
public void multiply(AVector a)
Description copied from class:AVectorMultiplies this vector by another vector, elementwise.
-
multiply
public void multiply(double factor)
Description copied from class:AVectorMultiplies the vector by a constant factor
-
multiplyCopy
public ZeroVector multiplyCopy(AVector a)
Description copied from interface:IVectorMultiplies a vector element-wise with this vector, returning a new vector.- Specified by:
multiplyCopyin interfaceIVector- Overrides:
multiplyCopyin classAVector- Returns:
-
multiplyCopy
public ZeroVector multiplyCopy(double factor)
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 classAVector- Parameters:
factor- A scalar factor- Returns:
- A new array, with all element values scaled by the given factor
-
normaliseCopy
public AVector normaliseCopy()
Description copied from class:AVectorReturns 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- Overrides:
normaliseCopyin classAVector- Returns:
-
divideCopy
public ZeroVector divideCopy(AVector a)
Description copied from interface:IVectorDivides this vector element-wise by another vector, returning a new vector.- Specified by:
divideCopyin interfaceIVector- Overrides:
divideCopyin classAVector- Returns:
-
elementSquaredSum
public double elementSquaredSum()
Description copied from interface:INDArrayReturns the sum of squared elements in this array.- Specified by:
elementSquaredSumin interfaceINDArray- Overrides:
elementSquaredSumin classASparseVector
-
magnitude
public double magnitude()
Description copied from class:AVectorReturns the magnitude (Euclidean length) of the vector
-
elementSum
public double elementSum()
Description copied from class:AVectorReturns the sum of all elements in a vector- Specified by:
elementSumin interfaceINDArray- Overrides:
elementSumin classASparseVector
-
elementProduct
public double elementProduct()
Description copied from interface:INDArrayReturns the product of all elements in the array.- Specified by:
elementProductin interfaceINDArray- Overrides:
elementProductin classASparseVector- 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 classAVector
-
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 classAVector
-
maxElementIndex
public int maxElementIndex()
Description copied from class:AVectorReturns the index of the maximum element of a vector- Overrides:
maxElementIndexin classAVector- Returns:
-
maxAbsElement
public double maxAbsElement()
Description copied from class:AVectorReturns the maximum absolute element value of a vector- Overrides:
maxAbsElementin classAVector- Returns:
-
maxAbsElementIndex
public int maxAbsElementIndex()
Description copied from class:AVectorReturns the index of the maximum absolute element of a vector- Overrides:
maxAbsElementIndexin classAVector- Returns:
-
minElementIndex
public int minElementIndex()
Description copied from class:AVectorReturns the index of the minimum element of a vector- Overrides:
minElementIndexin classAVector
-
nonZeroCount
public long nonZeroCount()
Description copied from interface:INDArrayReturns the number of non-zero elements in the array.- Specified by:
nonZeroCountin interfaceINDArray- Overrides:
nonZeroCountin classASparseVector
-
nonZeroValues
public double[] nonZeroValues()
Description copied from class:AVectorReturn an double array specifying the values in this vector which are non-zero- Overrides:
nonZeroValuesin classAVector- Returns:
-
isZero
public boolean isZero()
Description copied from class:AVectorReturns true if this vector is a zero vector (all components zero)- Specified by:
isZeroin interfaceINDArray- Overrides:
isZeroin classASparseVector
-
isRangeZero
public boolean isRangeZero(int start, int length)Description copied from class:AVectorReturns 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- Overrides:
isRangeZeroin classAVector- Returns:
-
isBoolean
public boolean isBoolean()
Description copied from interface:INDArrayReturns true if the array is boolean (contains only 0.0 or 1.0 values)- Specified by:
isBooleanin interfaceINDArray- Overrides:
isBooleanin classAbstractArray<java.lang.Double>
-
isMutable
public boolean isMutable()
Description copied from class:AVectorReturns true if this vector is mutable.
-
isFullyMutable
public boolean isFullyMutable()
Description copied from class:AVectorReturns true if this vector is fully mutable, i.e. can contain any unconstrained double values- Specified by:
isFullyMutablein interfaceINDArray- Overrides:
isFullyMutablein classAVector
-
isUnitLengthVector
public boolean isUnitLengthVector()
Description copied from class:AVectorReturns true if the vector has unit length- Overrides:
isUnitLengthVectorin classAVector- Returns:
-
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 classASparseVector
-
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 classASparseVector
-
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 classAVector
-
addToArray
public void addToArray(int offset, double[] array, int arrayOffset, int length)Description copied from class:AVectorAdds a subvector of this vector into a double array at the specified offset- Overrides:
addToArrayin classAVector
-
copyTo
public void copyTo(int offset, double[] dest, int destOffset, int length, int stride)Description copied from class:AVectorCopies a subset of this vector to a specified destination array offset using the given stride. Unsafe operation: performs no bounds checking- Overrides:
copyToin classASparseVector
-
addToArray
public void addToArray(double[] dest, int offset, int stride)Description copied from class:AVectorAdds this vector to a double[] array, using the specified offset and stride into the destination array- Overrides:
addToArrayin classAVector
-
addMultipleToArray
public void addMultipleToArray(double factor, int offset, double[] array, int arrayOffset, int length)Description copied from class:AVectorAdds a multiple of a subvector of this vector into a double array at the specified offset- Overrides:
addMultipleToArrayin classAVector
-
slice
public final ImmutableScalar slice(int i)
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.
-
iterator
public java.util.Iterator<java.lang.Double> iterator()
-
density
public double density()
Description copied from interface:ISparseComputes the density ratio of this sparse array (proportion of non-zero elements)- Specified by:
densityin interfaceISparse- Overrides:
densityin classASparseVector- Returns:
-
subVector
public AVector subVector(int offset, int length)
Description copied from class:AVectorObtains a sub-vector view that refers to this vector. Changes to the sub-vector will be reflected in this vector
-
join
public ZeroVector join(ZeroVector a)
-
tryEfficientJoin
public AVector tryEfficientJoin(AVector a)
Description copied from class:AVectorAttempts 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- Overrides:
tryEfficientJoinin classAVector
-
select
public AVector select(int... order)
Description copied from class:AVectorSelects a subset of indices from a vector
-
nonSparseElementCount
public int nonSparseElementCount()
Description copied from class:ASparseVectorReturns the number of non-sparse elements in the sparse vector. This will be greater or equal to the number of non-zero elements- Specified by:
nonSparseElementCountin classASparseVector- Returns:
-
nonSparseValues
public AVector nonSparseValues()
Description copied from interface:ISparseVectorReturns the non-sparse elements as a compacted vector. May or may not be a view.- Specified by:
nonSparseValuesin interfaceISparseVector- Specified by:
nonSparseValuesin classASparseVector- Returns:
-
nonSparseIndex
public Index nonSparseIndex()
Description copied from class:AVectorReturns an Index indicating which elements of this vector are defined as non-sparse. A sparse index must be zero. A non-sparse element may be zero, but is typically expected be non-zero.- Specified by:
nonSparseIndexin interfaceISparseVector- Specified by:
nonSparseIndexin classASparseVector- Returns:
-
nonZeroIndices
public int[] nonZeroIndices()
Description copied from class:AVectorReturn an int array specifying the positions in this vector which are non-zero- Overrides:
nonZeroIndicesin classAVector- Returns:
-
squareCopy
public AVector squareCopy()
Description copied from interface:INDArraySquares all elements of the array, returning a new array- Specified by:
squareCopyin interfaceINDArray- Overrides:
squareCopyin classAVector
-
includesIndex
public boolean includesIndex(int i)
Description copied from class:ASparseVectorReturns true iff the sparse vector contains the index i- Specified by:
includesIndexin classASparseVector- Returns:
-
hashCode
public int hashCode()
Description copied from class:AVectorComputes 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.
-
exactClone
public ZeroVector exactClone()
Description copied from class:AVectorReturns an exact clone of this vector, i.e. of the same type- Specified by:
exactClonein interfaceINDArray- Specified by:
exactClonein classAVector- Returns:
- A clone of the original array
-
sparseClone
public AVector sparseClone()
Description copied from class:AVectorClones the vector into a sparse mutable format- Specified by:
sparseClonein interfaceINDArray- Overrides:
sparseClonein classAVector
-
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 classASparseVector
-
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 classAVector
-
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 classAVector
-
selectClone
public AVector selectClone(int... inds)
Description copied from class:AVectorSelects a subset of indices from a vector, returning a mutable clone of data- Overrides:
selectClonein classAVector- Returns:
- a new mutable vector containing the selected indices
-
selectView
public AVector selectView(int... inds)
Description copied from class:AVectorSelects a subset of indices from a vector, returning a view- Overrides:
selectViewin classAVector- Returns:
- a view of the selected indices
-
equals
public boolean equals(AVector v)
Description copied from class:AbstractArrayReturns true if this array is exactly equal to a vector.- Overrides:
equalsin classASparseVector- Returns:
-
equalsArray
public boolean equalsArray(double[] data, int offset)Description copied from class:AVectorReturns true if this vector exactly matches the elements in double[] array, starting from the specified offset- Specified by:
equalsArrayin interfaceINDArray- Overrides:
equalsArrayin classASizedVector- Parameters:
data- Array of double element values to check for equalityoffset- Offset into the data array- 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 classAVector
-
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 classASparseVector- Returns:
- True if any element is this array is NaN or infinite, false otherwise
-
elementPowSum
public double elementPowSum(double p)
Description copied from class:ASparseVectorReturns the sum of all the elements raised to a specified power- Specified by:
elementPowSumin interfaceINDArray- Overrides:
elementPowSumin classASparseVector- Returns:
-
elementAbsPowSum
public double elementAbsPowSum(double p)
Description copied from class:ASparseVectorReturns the sum of the absolute values of all the elements raised to a specified power- Specified by:
elementAbsPowSumin interfaceINDArray- Overrides:
elementAbsPowSumin classASparseVector- Returns:
-
dotProduct
public double dotProduct(double[] data, int offset, int stride)Description copied from class:AVectorFast dot product with a double[] array and a stride. Performs no bounds checking. Likely to be faster than other dot product operations- Overrides:
dotProductin classAVector
-
visitNonZero
public double visitNonZero(IndexedElementVisitor elementVisitor)
Description copied from class:AVectorVisits all non-zero elements of this vector. Visitor may return a non-zero value to terminate early, which will return the given value. Returns 0.0 otherwise.- Overrides:
visitNonZeroin classASparseVector
-
-
DMelt 3.0 © DataMelt by jWork.ORG