mikera.vectorz.impl
Class Vector0
- java.lang.Object
-
- mikera.arrayz.impl.AbstractArray<java.lang.Double>
-
- mikera.vectorz.AVector
-
- mikera.vectorz.impl.APrimitiveVector
-
- mikera.vectorz.impl.Vector0
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<java.lang.Double>, IDense, INDArray, ISparse, IVector
public final class Vector0 extends APrimitiveVector implements IDense, ISparse
Special singleton zero length vector class. Mainly for convenience when doing vector construction / appending etc.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddToArray(int offset, double[] array, int arrayOffset, int length)Adds a subvector of this vector into a double array at the specified offsetVector0clone()Clones the vector, creating a new mutable copy of all data.Vectordense()Coerces this INDArray to a dense format, without changing its element values.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.doubleelementProduct()Returns the product of all elements in the array.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[] data, int offset)Returns true if this vector exactly matches the elements in double[] array, starting from the specified offsetVector0exactClone()Returns an exact clone of this vector, i.e.doubleget(int i)Returns the double value at the specified position in a 1D vectorinthashCode()Computes the hashcode of a vector.Vector0immutable()Creates an immutable copy of a vectorbooleanisFullyMutable()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.booleanisZero()Returns true if this vector is a zero vector (all components zero)AVectorjoin(AVector v)intlength()Returns the length of a vector, in terms of the number of elements.doublemagnitude()Returns the magnitude (Euclidean length) of the vectorlongnonZeroCount()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-zerostatic Vector0of()static Vector0of(double... values)voidset(int i, double value)Sets a value at a given position in a mutable 1D arrayVector0subVector(int start, 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.doublevisitNonZero(IndexedElementVisitor elementVisitor)Visits all non-zero elements of this vector.-
Methods inherited from class mikera.vectorz.impl.APrimitiveVector
getT, getX, getY, getZ, isView, sparse, sparseClone, toNormal
-
Methods inherited from class mikera.vectorz.AVector
abs, absCopy, absDiff, absDiff, absDiff, absDiffCopy, add, add, add, add, add, add, add, add, add, addAt, addAt, addCopy, addCopy, addCopy, addInnerProduct, addInnerProduct, addInnerProduct, addInnerProduct, addMultiple, addMultiple, addMultiple, addMultiple, addMultiple, addMultiple, addMultiple, addMultiple, addMultipleCopy, addMultipleSparse, addMultipleSparse, addMultipleToArray, addMultipleToArray, addPower, addPower, addProduct, addProduct, addProduct, addProductCopy, addProductCopy, addProductToArray, addProductToArray, addSparse, addSparse, addToArray, addToArray, addWeighted, angle, applyOp, applyOp, applyOp, applyOp, applyOp, applyOpCopy, asDoubleArray, asElementList, asVector, broadcast, broadcastLike, broadcastLike, broadcastLike, checkIndex, checkLength, checkRange, clamp, clampMax, clampMin, compareTo, compareTo, copy, copyTo, copyTo, copyTo, copyTo, copyTo, crossProduct, crossProduct, denseClone, dimensionality, distance, distanceL1, distanceLinf, distanceSquared, divide, divide, divide, divide, divideCopy, divideCopy, divideCopy, divideTo, dotProduct, dotProduct, dotProduct, elementAbsPowSum, elementCount, elementIterator, elementMax, elementMaxAbs, elementMin, elementPowSum, elementsEqual, epsilonEquals, epsilonEquals, epsilonEquals, equals, equals, equalsArray, fill, fillRange, get, get, get, get, get, get, getElement, getElements, getElements, getElements, getLongShape, getShape, getShape, getShapeClone, getSlices, getTranspose, getTransposeCopy, getTransposeView, hasUncountable, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, interpolate, isElementConstrained, isSameShape, isSameShape, isUnitLengthVector, isUnitLengthVector, iterator, join, join, log, logistic, magnitudeSquared, maxAbsElement, maxAbsElementIndex, maxElement, maxElementIndex, minElement, minElementIndex, multiply, multiply, multiply, multiply, multiply, multiplyCopy, multiplyCopy, multiplyCopy, multiplyTo, mutable, negate, negateCopy, nonSparseIndex, nonZeroValues, normalise, normaliseCopy, normaliseMaxAbsElement, outerProduct, outerProduct, pow, projectToPlane, reciprocal, reciprocalCopy, reduce, reduce, reduceSlices, 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, setApplyOp, setApplyOp, setApplyOp, setElements, setElements, setElements, setInnerProduct, setInnerProduct, setInnerProduct, setMultiple, setMultiple, setMultiple, setMultiple, setSparse, setSparse, setSparse, shiftCopy, signum, slice, slice, sliceCount, sliceValue, softmax, softmaxCopy, sqrtCopy, square, squareCopy, sub, sub, subArray, subAt, subCopy, subCopy, subMultiple, tanh, toDoubleBuffer, toList, 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, 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
-
-
-
-
Field Detail
-
INSTANCE
public static final Vector0 INSTANCE
-
-
Method Detail
-
of
public static Vector0 of()
-
of
public static Vector0 of(double... values)
-
length
public 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
-
elementSum
public double elementSum()
Description copied from class:AVectorReturns the sum of all elements in a vector- Specified by:
elementSumin interfaceINDArray- Overrides:
elementSumin classAVector
-
elementProduct
public double elementProduct()
Description copied from interface:INDArrayReturns the product of all elements in the array.- Specified by:
elementProductin interfaceINDArray- Overrides:
elementProductin classAVector- Returns:
-
nonZeroCount
public long nonZeroCount()
Description copied from interface:INDArrayReturns the number of non-zero elements in the array.- Specified by:
nonZeroCountin interfaceINDArray- Overrides:
nonZeroCountin classAVector
-
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:
-
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
-
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
-
clone
public Vector0 clone()
Description copied from class:AVectorClones 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)
-
isMutable
public boolean isMutable()
Description copied from class:AVectorReturns true if this vector is mutable.- Specified by:
isMutablein interfaceINDArray- Overrides:
isMutablein classAPrimitiveVector
-
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 classAPrimitiveVector
-
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.
-
isZero
public boolean isZero()
Description copied from class:AVectorReturns true if this vector is a zero vector (all components zero)
-
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:
-
elementSquaredSum
public double elementSquaredSum()
Description copied from interface:INDArrayReturns the sum of squared elements in this array.- Specified by:
elementSquaredSumin interfaceINDArray- Overrides:
elementSquaredSumin classAVector
-
magnitude
public double magnitude()
Description copied from class:AVectorReturns the magnitude (Euclidean length) of the vector
-
immutable
public Vector0 immutable()
Description copied from class:AVectorCreates an immutable copy of a vector
-
dense
public Vector 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.
-
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 classAVector
-
equals
public boolean equals(AVector v)
Description copied from class:AbstractArrayReturns true if this array is exactly equal to a vector.
-
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 classAVector- Parameters:
data- Array of double element values to check for equalityoffset- Offset into the data array- Returns:
-
subVector
public Vector0 subVector(int start, 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
-
exactClone
public Vector0 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 classAPrimitiveVector- Returns:
- A clone of the original array
-
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
-
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 classAPrimitiveVector
-
-
DMelt 3.0 © DataMelt by jWork.ORG