mikera.vectorz.impl
Class ASparseIndexedVector
- java.lang.Object
-
- mikera.arrayz.impl.AbstractArray<java.lang.Double>
-
- mikera.vectorz.AVector
-
- mikera.vectorz.impl.ASizedVector
-
- mikera.vectorz.impl.ASparseVector
-
- mikera.vectorz.impl.ASparseIndexedVector
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<java.lang.Double>, INDArray, ISparse, ISparseVector, IVector
- Direct Known Subclasses:
- SparseImmutableVector, SparseIndexedVector
public abstract class ASparseIndexedVector extends ASparseVector
Base class containing common implementations for sparse indexed vectors- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description ASparseIndexedVector(int length)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddMultipleToArray(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 offsetvoidaddProductToArray(double factor, int offset, ADenseArrayVector other, int otherOffset, double[] array, int arrayOffset, 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)voidaddToArray(double[] dest, int offset)Adds this vector to a double[] array, starting at the specified offset.voidaddToArray(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 offsetSparseIndexedVectorcloneIncludingIndices(int[] ixs)Create a clone of this sparse indexed vector including the new indexes specified Intended to allow fast subsequent modificationvoidcopyTo(AVector v, int offset)Copies a the contents of a vector to a vector at the specified offsetdoubledotProduct(ASparseVector v)Multiply this sparse indexed vector with another sparse 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.doubleelementSquaredSum()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[] ds, int offset)Returns true if this vector exactly matches the elements in double[] array, starting from the specified offsetvoidgetElements(double[] array, int offset)Copies all elements of this array a double array at the specified offsetbooleanincludesIndex(int i)Returns true iff the sparse vector contains the index iAVectorinnerProduct(AMatrix a)Computes the inner product of this vector with a matrixbooleanisRangeZero(int start, int length)Returns true if a sub-vector range is completely zero.booleanisZero()Returns true if this vector is a zero vector (all components zero)voidmultiply(double factor)Multiplies the vector by a constant factorlongnonZeroCount()Returns the number of non-zero elements in the array.int[]nonZeroIndices()Return an int array specifying the positions in this vector which are non-zero-
Methods inherited from class mikera.vectorz.impl.ASparseVector
add, add, addMultiple, clone, copyTo, copyTo, density, distanceL1, distanceLinf, distanceSquared, dotProduct, elementAbsPowSum, elementPowSum, elementProduct, equals, getSlices, hasUncountable, isSparse, isView, nonSparseElementCount, nonSparseIndex, nonSparseValues, reduce, reduce, reduceSlices, roundToZero, sparse, toDoubleArray, toSparseIndexedVector, visitNonZero
-
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, absCopy, absDiff, absDiff, absDiff, absDiffCopy, add, add, add, add, add, add, add, add, addAt, addAt, addCopy, addCopy, addCopy, addInnerProduct, addInnerProduct, addInnerProduct, addInnerProduct, addMultiple, addMultiple, addMultiple, addMultiple, addMultiple, addMultiple, addMultiple, addMultipleCopy, addMultipleSparse, addMultipleSparse, addMultipleToArray, addPower, addPower, addProduct, addProduct, addProduct, addProductCopy, addProductCopy, addSparse, addSparse, addWeighted, angle, applyOp, applyOp, applyOp, applyOp, applyOp, applyOpCopy, asDoubleArray, asElementList, asVector, broadcast, broadcastLike, broadcastLike, broadcastLike, clamp, clampMax, clampMin, compareTo, compareTo, copy, copyTo, copyTo, crossProduct, crossProduct, dense, denseClone, dimensionality, distance, divide, divide, divide, divide, divideCopy, divideCopy, divideCopy, divideTo, dotProduct, elementIterator, elementMax, elementMaxAbs, elementMin, elementsEqual, epsilonEquals, epsilonEquals, epsilonEquals, equals, equals, exactClone, fill, fillRange, get, get, get, get, get, get, getElement, getElements, getElements, getLongShape, getShape, getTranspose, getTransposeCopy, getTransposeView, hashCode, immutable, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, interpolate, isElementConstrained, isFullyMutable, isMutable, isSameShape, isUnitLengthVector, isUnitLengthVector, iterator, join, join, join, log, logistic, magnitude, magnitudeSquared, maxAbsElement, maxAbsElementIndex, maxElement, maxElementIndex, minElement, minElementIndex, multiply, multiply, multiply, multiply, multiplyCopy, multiplyCopy, multiplyCopy, multiplyTo, mutable, negate, negateCopy, nonZeroValues, normalise, normaliseCopy, normaliseMaxAbsElement, outerProduct, outerProduct, pow, projectToPlane, reciprocal, reciprocalCopy, reduceSlices, reorder, reorder, reshape, rotateCopy, rotateView, rotateView, scale, scaleAdd, scaleAdd, scaleAdd, scaleAdd, scaleCopy, scaleToMagnitude, select, selectClone, selectView, set, 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, setSparse, shiftCopy, signum, slice, slice, sliceValue, softmax, softmaxCopy, sparseClone, sqrtCopy, square, squareCopy, sub, sub, subArray, subAt, subCopy, subCopy, subMultiple, subVector, tanh, toDoubleBuffer, toList, toNormal, toSliceArray, toString, toStringFull, toVector, tryEfficientJoin, unsafeGet, unsafeSet, 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, isBoolean, isDense, scale, set, set, signumCopy, sqrt, sub, sub, withComponents
-
Methods inherited from interface mikera.vectorz.IVector
addCopy, divideCopy, epsilonEquals, get, isSameShape, length, multiplyCopy, normalise, normaliseCopy, rotateCopy, rotateView, set, shiftCopy, sqrtCopy, subCopy
-
Methods inherited from interface mikera.arrayz.INDArray
abs, absCopy, absDiff, absDiffCopy, add, add, addApplyOp, addAt, addCopy, addCopy, addInnerProduct, addInnerProduct, addMultiple, addMultipleSparse, addOuterProduct, addOuterProductSparse, addPower, addPower, addSparse, addSparse, applyOp, applyOp, applyOp, applyOp, applyOpCopy, asDoubleArray, asElementList, asVector, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, broadcastLike, clamp, componentCount, copy, dense, denseClone, dimensionality, divide, divide, divideCopy, divideCopy, elementCount, elementIterator, elementMax, elementMaxAbs, elementMin, elementsEqual, ensureMutable, epsilonEquals, epsilonEquals, equals, equalsArray, exactClone, exp, fill, get, get, get, get, get, get, get, get, getComponent, getComponents, getElement, getElements, getElements, getElements, getLongShape, getShape, getShape, getShapeClone, getSlices, getSliceViews, getTranspose, getTransposeCopy, getTransposeView, immutable, innerProduct, innerProduct, innerProduct, innerProduct, isBoolean, isDense, isElementConstrained, isFullyMutable, isMutable, isSameShape, join, join, log, multiply, multiplyCopy, multiplyCopy, mutable, negate, negateCopy, outerProduct, pow, reciprocal, reciprocalCopy, reduceSlices, reorder, reorder, reshape, rotateView, scale, scaleAdd, scaleAdd, scaleCopy, set, set, set, set, set, set, setApplyOp, setElements, setElements, setElements, setInnerProduct, setMultiple, setMultiple, setSparse, setSparse, signum, signumCopy, slice, slice, sliceCount, sliceValue, sparseClone, sqrt, square, squareCopy, sub, sub, subArray, subCopy, toDoubleBuffer, toSliceArray, toVector, validate, withComponents
-
-
-
-
Method Detail
-
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:
-
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:
-
elementSum
public double elementSum()
Description copied from class:AVectorReturns the sum of all elements in a vector- Specified by:
elementSumin interfaceINDArray- Overrides:
elementSumin classASparseVector
-
multiply
public void multiply(double factor)
Description copied from class:AVectorMultiplies the vector by a constant factor
-
elementSquaredSum
public double elementSquaredSum()
Description copied from interface:INDArrayReturns the sum of squared elements in this array.- Specified by:
elementSquaredSumin interfaceINDArray- Overrides:
elementSquaredSumin classASparseVector
-
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
-
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
-
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
-
innerProduct
public AVector innerProduct(AMatrix a)
Description copied from class:AVectorComputes the inner product of this vector with a matrix- Overrides:
innerProductin classASparseVector- Returns:
- a vector representing the inner product
-
dotProduct
public final 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 final double dotProduct(ASparseVector v)
Multiply this sparse indexed vector with another sparse vector.- Parameters:
v-- 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:
-
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
-
addToArray
public void addToArray(double[] dest, int offset)Description copied from class:AVectorAdds this vector to a double[] array, starting at the specified offset.- Specified by:
addToArrayin interfaceINDArray- Overrides:
addToArrayin classAVector
-
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
-
addProductToArray
public void addProductToArray(double factor, int offset, AVector other, int otherOffset, double[] array, int arrayOffset, int length)- Overrides:
addProductToArrayin classAVector
-
addProductToArray
public void addProductToArray(double factor, int offset, ADenseArrayVector other, int otherOffset, double[] array, int arrayOffset, int length)Description copied from class:AVectorAdds the scaled elementwise product of this vector and another vector to the destimation array- Overrides:
addProductToArrayin classAVector
-
equalsArray
public boolean equalsArray(double[] ds, 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:
ds- Array of double element values to check for equalityoffset- Offset into the data array- Returns:
-
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:
-
cloneIncludingIndices
public final SparseIndexedVector cloneIncludingIndices(int[] ixs)
Create a clone of this sparse indexed vector including the new indexes specified Intended to allow fast subsequent modification
-
getElements
public final void getElements(double[] array, 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
-
-
DMelt 3.0 © DataMelt by jWork.ORG