mikera.vectorz.impl
Class RepeatedElementVector
- java.lang.Object
-
- mikera.arrayz.impl.AbstractArray<java.lang.Double>
-
- mikera.vectorz.AVector
-
- mikera.vectorz.impl.ASizedVector
-
- mikera.vectorz.impl.RepeatedElementVector
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<java.lang.Double>, INDArray, IVector
public final class RepeatedElementVector extends ASizedVector
An immutable vector that has the same value for elements.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description AVectorabsCopy()Returns a copy of the array with the abs operator applied to each elementAVectoraddCopy(AVector v)Adds a vector element-wise to this vector, returning a new vector.AVectoraddCopy(double v)Creates a new array equal to this array with a constant value added to every elementvoidaddToArray(double[] data, int offset)Adds this vector to a double[] array, starting at the specified offset.AVectorapplyOpCopy(Op op)Applies a unary operator to all elements of the array (creating a new array)static RepeatedElementVectorcreate(int length, double value)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 offsetRepeatedElementVectorexactClone()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 offsetbooleanhasUncountable()Returns true if any element is this array is NaN or infiniteAVectorinnerProduct(AMatrix m)Computes the inner product of this vector with a matrixbooleanisElementConstrained()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.booleanisZero()Returns true if this vector is a zero vector (all components zero)java.util.Iterator<java.lang.Double>iterator()AVectormultiplyCopy(AVector v)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 valueAVectornegateCopy()Negates all elements in the array, returning a new arraylongnonZeroCount()Returns the number of non-zero elements in the array.AVectorreciprocalCopy()Computes the reciprocal of all elements in this vector.AVectorselect(int... order)Selects a subset of indices from a vectorvoidset(int i, double value)Sets a value at a given position in a mutable 1D arrayAVectorsubVector(int offset, int length)Obtains a sub-vector view that refers to this vector.AVectortryEfficientJoin(AVector a)Attempts to perform an efficient join with a second vector.doubleunsafeGet(int i)Like get, but performs no bounds checking.-
Methods inherited from class mikera.vectorz.impl.ASizedVector
checkIndex, checkLength, checkRange, elementCount, equalsArray, get, getShape, getShapeClone, isSameShape, length, sliceCount, visitNonZero
-
Methods inherited from class mikera.vectorz.AVector
abs, absDiff, absDiff, absDiff, absDiffCopy, add, add, add, add, add, add, add, add, add, addAt, addAt, 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, asDoubleArray, asElementList, asVector, broadcast, broadcastLike, broadcastLike, broadcastLike, clamp, clampMax, clampMin, clone, compareTo, compareTo, copy, copyTo, copyTo, copyTo, copyTo, copyTo, crossProduct, crossProduct, dense, denseClone, dimensionality, distance, distanceL1, distanceLinf, distanceSquared, divide, divide, divide, divide, divideCopy, divideCopy, divideCopy, divideTo, dotProduct, dotProduct, elementIterator, elementMaxAbs, epsilonEquals, epsilonEquals, epsilonEquals, equals, equals, fill, fillRange, get, get, get, get, get, getElement, getElements, getElements, getLongShape, getShape, getSlices, getTranspose, getTransposeCopy, getTransposeView, hashCode, immutable, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, interpolate, isSameShape, isUnitLengthVector, isUnitLengthVector, isView, join, join, join, log, logistic, magnitude, magnitudeSquared, maxAbsElement, maxAbsElementIndex, maxElement, maxElementIndex, minElement, minElementIndex, multiply, multiply, multiply, multiply, multiply, multiplyCopy, multiplyTo, mutable, negate, nonSparseIndex, nonZeroIndices, nonZeroValues, normalise, normaliseCopy, normaliseMaxAbsElement, outerProduct, outerProduct, pow, projectToPlane, reciprocal, reduce, reduce, reduceSlices, reduceSlices, reorder, reorder, reshape, rotateCopy, rotateView, rotateView, scale, scaleAdd, scaleAdd, scaleAdd, scaleAdd, scaleCopy, scaleToMagnitude, 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, sliceValue, softmax, softmaxCopy, sparse, sparseClone, sqrtCopy, square, squareCopy, sub, sub, subArray, subAt, subCopy, subCopy, subMultiple, tanh, toDoubleArray, toDoubleBuffer, toList, toNormal, toSliceArray, toString, toStringFull, toVector, 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
-
-
-
-
Method Detail
-
create
public static RepeatedElementVector create(int length, double value)
-
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
-
isMutable
public boolean isMutable()
Description copied from class:AVectorReturns true if this vector is mutable.
-
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:
-
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 classAVector
-
get
public double get(int i)
Description copied from interface:INDArrayReturns the double value at the specified position in a 1D vector
-
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
-
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
-
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:
-
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
-
elementSquaredSum
public double elementSquaredSum()
Description copied from interface:INDArrayReturns the sum of squared elements in this array.- Specified by:
elementSquaredSumin interfaceINDArray- Overrides:
elementSquaredSumin classAVector
-
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- Overrides:
dotProductin classAVector- 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
-
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
-
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 classAVector- Parameters:
d- A scalar factor- Returns:
- A new array, with all element values scaled by the given factor
-
innerProduct
public AVector innerProduct(AMatrix m)
Description copied from class:AVectorComputes the inner product of this vector with a matrix- Overrides:
innerProductin classAVector- Returns:
- a vector representing the inner product
-
select
public AVector select(int... order)
Description copied from class:AVectorSelects a subset of indices from a vector
-
reciprocalCopy
public AVector 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 AVector absCopy()
Description copied from interface:INDArrayReturns a copy of the array with the abs operator applied to each element
-
negateCopy
public AVector negateCopy()
Description copied from interface:INDArrayNegates all elements in the array, returning a new array- Specified by:
negateCopyin interfaceINDArray- Overrides:
negateCopyin classAVector
-
addCopy
public AVector addCopy(AVector v)
Description copied from interface:IVectorAdds a vector element-wise to this vector, returning a new vector.
-
multiplyCopy
public AVector multiplyCopy(AVector v)
Description copied from interface:IVectorMultiplies a vector element-wise with this vector, returning a new vector.- Specified by:
multiplyCopyin interfaceIVector- Overrides:
multiplyCopyin classAVector- Returns:
-
addCopy
public AVector addCopy(double v)
Description copied from interface:INDArrayCreates a new array equal to this array with a constant value added to every element
-
addToArray
public void addToArray(double[] data, 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
-
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
-
set
public void set(int i, double value)Description copied from interface:INDArraySets a value at a given position in a mutable 1D array
-
iterator
public java.util.Iterator<java.lang.Double> iterator()
-
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
-
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
-
exactClone
public RepeatedElementVector 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
-
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
-
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 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 classAVector- Returns:
- True if any element is this array is NaN or infinite, false otherwise
-
elementPowSum
public double elementPowSum(double p)
Returns the sum of all the elements raised to a specified power- Specified by:
elementPowSumin interfaceINDArray- Overrides:
elementPowSumin classAVector- Returns:
-
elementAbsPowSum
public double elementAbsPowSum(double p)
Returns the sum of the absolute values of all the elements raised to a specified power- Specified by:
elementAbsPowSumin interfaceINDArray- Overrides:
elementAbsPowSumin classAVector- Returns:
-
-
DMelt 3.0 © DataMelt by jWork.ORG