mikera.vectorz.impl
Class JoinedVector
- java.lang.Object
-
- mikera.arrayz.impl.AbstractArray<java.lang.Double>
-
- mikera.vectorz.AVector
-
- mikera.vectorz.impl.ASizedVector
-
- mikera.vectorz.impl.AJoinedVector
-
- mikera.vectorz.impl.JoinedVector
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<java.lang.Double>, INDArray, IVector
public final class JoinedVector extends AJoinedVector
A vector that represents the concatenation of two vectors. Should only be used if the two vectors cannot otherwise be efficiently joined.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance 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 elementvoidadd(AVector a)Adds another vector to this onevoidadd(AVector a, int aOffset)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, int offset)Adds to this vector from a given double array.voidadd(int offset, AVector a, int aOffset, int length)Adds a segment of another vector into this one, at the specified offsetvoidadd(JoinedVector a)voidaddAt(int i, double v)Adds a value to a specific element of the vector This function does not perform bounds checking, i.e.AVectoraddCopy(AVector a)Adds a vector element-wise to this vector, returning a new vector.voidaddMultiple(AVector a, double factor)Adds a scaled multiple of another vector to this vectorvoidaddMultiple(AVector a, int aOffset, double factor)Adds a multiple of a subvector of another vector to this vector.voidaddMultiple(JoinedVector a, double factor)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 offsetvoidaddProduct(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 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 offsetvoidapplyOp(Op op)Applies a unary operator to all elements of the array (in-place)voidclamp(double min, double max)Clamps all values in the vector to a given rangeintcomponentCount()Returns the number of components of this array.voidcopyTo(AVector dest, int offset)Copies a the contents of a vector to a vector at the specified offsetvoidcopyTo(int start, AVector dest, int destOffset, int length)Copies a subset of this vector to a vector at the specified offsetintdepth()static intdepthCalc(AVector v)voiddivideTo(double[] data, int offset)Divides the elements in the target array by corresponding elements in this vectordoubledotProduct(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(JoinedVector jv)doubleelementMax()Returns the maximum element value in this array.doubleelementMin()Returns the maximum element value in this array.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.booleanequals(JoinedVector v)booleanequalsArray(double[] data, int offset)Returns true if this vector exactly matches the elements in double[] array, starting from the specified offsetJoinedVectorexactClone()Returns an exact clone of this vector, i.e.voidexp()Computes the function e^x (in-place) for all array elementsvoidfill(double value)Fills the entire vector with a given valuedoubleget(int i)Returns the double value at the specified position in a 1D vectorAVectorgetComponent(int k)Gets a component from the array at the specified index Will throw an error if components are not supported, or if the component is out of bounds as defined by 0 <= kvoidgetElements(double[] data, int offset)Copies all elements of this array a double array at the specified offsetbooleanisFullyMutable()Returns true if this vector is fully mutable, i.e.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(JoinedVector a)static AVectorjoinVectors(AVector left, AVector right)Returns a JoinedVector connecting the two vectorsvoidlog()Computes the natural logarithm (in-place) for all array elementsvoidlogistic()Computes the logistic function for every element in this vector.voidmultiply(double value)Multiplies the vector by a constant factorvoidmultiplyTo(double[] data, int offset)Multiplies the elements in the target array by corresponding elements in this vectorvoidnegate()Negates all emlements of this vector in place.AVectornegateCopy()Negates all elements in the array, returning a new arraylongnonZeroCount()Returns the number of non-zero elements in the array.voidreciprocal()Computes the reciprocal of all elements in this vector.voidscaleAdd(double factor, double constant)Scales this vector and adds a constant to every elementvoidset(AVector src)Sets the vector to equal the value of another vectorvoidset(AVector src, int srcOffset)Set the vector equal to an offset into another vectorvoidset(int i, double value)Sets a value at a given position in a mutable 1D arrayvoidsetElements(int pos, double[] values, int offset, int length)Sets elements in an array using the given double values.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)voidsqrt()Computes the square root of all elements in the arrayvoidsquare()Squares all elements of the array in placeAVectorsubVector(int start, 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.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.voidvalidate()Validates the internal data structure of the INDArray.JoinedVectorwithComponents(INDArray... segments)Reconstructs a new joined vector of the same type and shape with the given segments.-
Methods inherited from class mikera.vectorz.impl.AJoinedVector
addSparse, applyOp, copyTo, copyTo, dotProduct, hasUncountable, isMutable, isView, reduce, reduce, scaleAdd, setElements, setSparse
-
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
absDiff, absDiff, absDiff, absDiffCopy, add, add, add, add, addAt, addCopy, addCopy, addInnerProduct, addInnerProduct, addInnerProduct, addInnerProduct, addMultiple, addMultiple, addMultiple, addMultiple, addMultiple, addMultiple, addMultipleCopy, addMultipleSparse, addMultipleSparse, addMultipleToArray, addPower, addPower, addProduct, addProductCopy, addProductCopy, addProductToArray, addProductToArray, addSparse, addToArray, addWeighted, angle, applyOp, applyOp, applyOp, applyOpCopy, asDoubleArray, asElementList, asVector, broadcast, broadcastLike, broadcastLike, broadcastLike, clampMax, clampMin, clone, compareTo, compareTo, copy, copyTo, crossProduct, crossProduct, dense, denseClone, dimensionality, distance, distanceL1, distanceLinf, distanceSquared, divide, divide, divide, divide, divideCopy, divideCopy, divideCopy, dotProduct, dotProduct, elementAbsPowSum, elementIterator, elementMaxAbs, elementPowSum, elementsEqual, epsilonEquals, epsilonEquals, epsilonEquals, equals, equals, fillRange, get, get, get, get, get, getElement, getElements, getElements, getLongShape, getShape, getSlices, getTranspose, getTransposeCopy, getTransposeView, hashCode, immutable, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, interpolate, isElementConstrained, isSameShape, isUnitLengthVector, isUnitLengthVector, iterator, join, join, join, magnitude, magnitudeSquared, maxAbsElement, maxAbsElementIndex, maxElement, maxElementIndex, minElement, minElementIndex, multiply, multiply, multiply, multiply, multiplyCopy, multiplyCopy, multiplyCopy, mutable, nonSparseIndex, nonZeroIndices, nonZeroValues, normalise, normaliseCopy, normaliseMaxAbsElement, outerProduct, outerProduct, pow, projectToPlane, reciprocalCopy, reduceSlices, reduceSlices, reorder, reorder, reshape, rotateCopy, rotateView, rotateView, scale, scaleAdd, scaleAdd, scaleCopy, scaleToMagnitude, select, selectClone, selectView, set, set, set, set, set, set, set, set, setApplyOp, setApplyOp, setApplyOp, setElements, setInnerProduct, setInnerProduct, setInnerProduct, setMultiple, setMultiple, setMultiple, setMultiple, setSparse, setSparse, shiftCopy, slice, slice, sliceValue, softmax, softmaxCopy, sparse, sparseClone, sqrtCopy, squareCopy, sub, sub, subArray, subAt, subCopy, subCopy, subMultiple, toList, toNormal, toSliceArray, toString, toStringFull, toVector
-
Methods inherited from class mikera.arrayz.impl.AbstractArray
add, addApplyOp, addCopy, addInnerProduct, addInnerProduct, addOuterProduct, addOuterProductSparse, addSparse, broadcastCloneLike, broadcastCopyLike, density, ensureMutable, epsilonEquals, get, get, getComponents, getElements, getElements, getSlices, getSliceViews, isBoolean, isDense, isSparse, scale, set, set, signumCopy, sub, sub
-
Methods inherited from interface mikera.arrayz.INDArray
addApplyOp, addInnerProduct, addOuterProduct, addOuterProductSparse, addSparse, broadcastCloneLike, broadcastCopyLike, ensureMutable, epsilonEquals, get, get, getComponents, getElements, getElements, getSlices, getSliceViews, isBoolean, isDense, isSparse, scale, set, set, signumCopy, sub
-
-
-
-
Method Detail
-
joinVectors
public static AVector joinVectors(AVector left, AVector right)
Returns a JoinedVector connecting the two vectors- Parameters:
left-right-- Returns:
-
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
-
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 classAJoinedVector
-
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:
-
copyTo
public void copyTo(AVector dest, int offset)
Description copied from class:AVectorCopies a the contents of a vector to a vector at the specified offset- Overrides:
copyToin classAJoinedVector
-
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 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
-
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
-
addAt
public void addAt(int i, double v)Description copied from class:AVectorAdds a value to a specific element of the vector This function does not perform bounds checking, i.e. is an unsafe operation
-
getElements
public void getElements(double[] data, 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
-
multiplyTo
public void multiplyTo(double[] data, int offset)Description copied from class:AVectorMultiplies the elements in the target array by corresponding elements in this vector- Overrides:
multiplyToin classAVectoroffset- The offset into the target array
-
divideTo
public void divideTo(double[] data, int offset)Description copied from class:AVectorDivides the elements in the target array by corresponding elements in this vector
-
copyTo
public void copyTo(int start, AVector dest, int destOffset, int length)Description copied from class:AVectorCopies a subset of this vector to a vector at the specified offset- Overrides:
copyToin classAJoinedVector
-
subVector
public AVector 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
-
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
-
join
public AVector join(JoinedVector a)
-
add
public void add(AVector a)
Description copied from class:AVectorAdds another vector to this one
-
addCopy
public AVector addCopy(AVector a)
Description copied from interface:IVectorAdds a vector element-wise to this vector, returning a new vector.
-
add
public void add(JoinedVector a)
-
scaleAdd
public void scaleAdd(double factor, double constant)Description copied from class:AVectorScales this vector and adds a constant to every element
-
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
-
reciprocal
public void reciprocal()
Description copied from class:AVectorComputes the reciprocal of all elements in this vector. Mutates this vector- Specified by:
reciprocalin interfaceINDArray- Overrides:
reciprocalin classAVector
-
clamp
public void clamp(double min, double max)Description copied from class:AVectorClamps all values in the vector to a given range
-
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- Overrides:
dotProductin classAJoinedVector
-
dotProduct
public double dotProduct(JoinedVector jv)
-
add
public void add(AVector a, int aOffset)
Description copied from class:AVectorAdds part another vector to this one, starting at the specified offset in the source vector
-
add
public void add(double[] data, int offset)Description copied from class:AVectorAdds to this vector from a given double array.
-
add
public void add(int offset, AVector a, int aOffset, int length)Description copied from class:AVectorAdds a segment of another vector into this one, at the specified offset
-
addMultiple
public void addMultiple(AVector a, double factor)
Description copied from class:AVectorAdds a scaled multiple of another vector to this vector- Overrides:
addMultiplein classAVector
-
addMultiple
public void addMultiple(JoinedVector a, double factor)
-
addMultiple
public void addMultiple(AVector a, int aOffset, double factor)
Description copied from class:AVectorAdds a multiple of a subvector of another vector to this vector. Useful as a specialised override for joined vectors etc.- Overrides:
addMultiplein classAVector
-
addProduct
public void addProduct(AVector a, AVector b, double factor)
Description copied from class:AVectorAdds the element-wise product of two vectors and a constant factor to this vector. Mutates this vector.- Overrides:
addProductin classAVector
-
addProduct
public void addProduct(AVector a, int aOffset, AVector b, int bOffset, double factor)
Description copied from class:AVectorAdds the scaled elementwise product of two vectors to this vector- Overrides:
addProductin classAVector
-
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)
-
abs
public void abs()
Description copied from interface:INDArrayReplaces all elements of this array with their absolute values, according to Math.abs(double)
-
absCopy
public AVector absCopy()
Description copied from interface:INDArrayReturns a copy of the array with the abs operator applied to each element
-
exp
public void exp()
Description copied from interface:INDArrayComputes the function e^x (in-place) for all array elements- Specified by:
expin interfaceINDArray- Overrides:
expin classAbstractArray<java.lang.Double>
-
log
public void log()
Description copied from interface:INDArrayComputes the natural logarithm (in-place) for all array elements
-
negate
public void negate()
Description copied from class:AVectorNegates all emlements of this vector in place.
-
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
-
applyOp
public void applyOp(Op op)
Description copied from interface:INDArrayApplies a unary operator to all elements of the array (in-place)
-
elementSum
public double elementSum()
Description copied from class:AVectorReturns the sum of all elements in a vector- Specified by:
elementSumin interfaceINDArray- Overrides:
elementSumin classAJoinedVector
-
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 classAJoinedVector
-
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
-
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(AVector src)
Description copied from class:AVectorSets the vector to equal the value of another 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
-
set
public void set(AVector src, int srcOffset)
Description copied from class:AVectorSet the vector equal to an offset into another vector
-
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 classAVector- 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.
-
set
public void set(int i, double value)Description copied from interface:INDArraySets a value at a given position in a mutable 1D array
-
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
-
fill
public void fill(double value)
Description copied from class:AVectorFills the entire vector with a given value
-
square
public void square()
Description copied from interface:INDArraySquares all elements of the array in place
-
sqrt
public void sqrt()
Description copied from interface:INDArrayComputes the square root of all elements in the array- Specified by:
sqrtin interfaceINDArray- Overrides:
sqrtin classAbstractArray<java.lang.Double>
-
tanh
public void tanh()
Description copied from class:AVectorComputes the tanh of every element in this vector. Mutates this vector.
-
logistic
public void logistic()
Description copied from class:AVectorComputes the logistic function for every element in this vector. Mutates this vector.
-
multiply
public void multiply(double value)
Description copied from class:AVectorMultiplies the vector by a constant factor
-
depthCalc
public static int depthCalc(AVector v)
-
depth
public int depth()
-
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.- Overrides:
equalsin classAJoinedVector- Returns:
-
equals
public boolean equals(JoinedVector v)
-
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 classAJoinedVector- Parameters:
data- Array of double element values to check for equalityoffset- Offset into the data array- Returns:
-
exactClone
public JoinedVector 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
-
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.
-
componentCount
public int componentCount()
Description copied from interface:INDArrayReturns the number of components of this array. May return 0 if components are not supported- Specified by:
componentCountin interfaceINDArray- Specified by:
componentCountin classAJoinedVector- Returns:
-
getComponent
public AVector getComponent(int k)
Description copied from interface:INDArrayGets a component from the array at the specified index Will throw an error if components are not supported, or if the component is out of bounds as defined by 0 <= k- Specified by:
getComponentin interfaceINDArray- Specified by:
getComponentin classAJoinedVector- Returns:
-
withComponents
public JoinedVector withComponents(INDArray... segments)
Description copied from class:AJoinedVectorReconstructs a new joined vector of the same type and shape with the given segments. The segments must be the same shape as the original segments- Specified by:
withComponentsin interfaceINDArray- Specified by:
withComponentsin classAJoinedVector
-
-
DMelt 3.0 © DataMelt by jWork.ORG
You see the box below because you did not login.