public final class Vector extends ADenseArrayVector
| Modifier and Type | Field and Description |
|---|---|
static Vector |
EMPTY |
datalength| Constructor and Description |
|---|
Vector(AVector source)
Copy constructor from an arbitrary vector
|
| Modifier and Type | Method and Description |
|---|---|
void |
abs()
Replaces all elements of this array with their absolute values, according to Math.abs(double)
|
void |
add(ADenseArrayVector src,
int srcOffset) |
void |
add(AVector v)
Adds another vector to this one
|
void |
add(double constant)
Adds a double value to all elements in this array.
|
void |
add(double[] srcData,
int srcOffset)
Adds to this vector from a given double array.
|
void |
addAt(int i,
double v)
Adds a value to a specific element of the vector
This function does not perform bounds checking, i.e.
|
void |
addMultiple(ADenseArrayVector v,
double factor) |
void |
addMultiple(AVector v,
double factor)
Adds a scaled multiple of another vector to this vector
|
void |
addMultiple(Vector source,
Index index,
double factor)
Adds source vector to this vector at the specified indexes which should map from source->this
|
void |
addProduct(AVector a,
AVector b)
Adds the element-wise product of two vectors to this vector.
|
void |
addProduct(Vector a,
Vector b) |
void |
addProduct(Vector a,
Vector b,
double factor) |
void |
applyOp(Op op)
Applies a unary operator to all elements of the array (in-place)
|
double[] |
asDoubleArray()
Returns the underlying double array representing the densely packed elements of this array
Returns null if there is no such array
|
void |
clamp(double min,
double max)
Clamps all values in the vector to a given range
|
Vector |
clone()
Clones the vector, creating a new mutable copy of all data.
|
static Vector |
create(AIndex a) |
static Vector |
create(ArrayList<Number> al) |
static Vector |
create(AVector a) |
static Vector |
create(double[] data)
Creates a new Vector from the given double[] data.
|
static Vector |
create(double[] data,
int start,
int length)
Creates a new Vector from the given double[] data.
|
static Vector |
create(INDArray a) |
static Vector |
create(Iterable<Number> iterable)
Creates a Vector from the specified Iterable object
|
static Vector |
create(Iterator<Number> iterator)
Creates a Vector from the specified Iterator object
|
static Vector |
create(List<Number> al) |
static Vector |
create(Object o) |
static Vector |
createFromVector(AVector source,
int length)
Creates a new vector using the elements in the specified vector.
|
static Vector |
createLength(int length)
Create an empty (zero-filled) vector of a specified length
|
Vector |
dense()
Coerces this INDArray to a dense format, without changing its element values.
|
double |
distance(AVector v)
Returns the Euclidean distance to another vector.
|
double |
distanceSquared(Vector v) |
void |
divide(AVector v) |
void |
divide(double factor)
Divides all elements by a given factor
|
void |
divide(Vector v)
Performance Override for divide
|
double |
dotProduct(AVector v,
Index ix)
Returns the dotProduct of this vector with the elements of another vector mapped to specified indexes in this vector.
|
double |
dotProduct(double[] data,
int offset)
Fast dot product with a double[] array.
|
double |
dotProduct(Vector v,
Index ix) |
double |
elementMax()
Returns the maximum element value in this array.
|
double |
elementMin()
Returns the maximum element value in this array.
|
double |
elementSum()
Returns the sum of all elements in a vector
|
Vector |
ensureMutable()
Ensures the array is a fully mutable, efficient representation that is not
a view.
|
boolean |
equals(AVector v) |
boolean |
equalsArray(double[] arr)
Returns true if this vector exactly matches a double[] array.
|
boolean |
equalsArray(double[] arr,
int offset)
Returns true if this vector exactly matches the elements in double[] array, starting
from the specified offset
|
Vector |
exactClone()
Returns an exact clone of this vector, i.e.
|
void |
fill(double value)
Fills the entire vector with a given value
|
double |
get(int i)
Returns the double value at the specified position in a 1D vector
|
int |
getArrayOffset()
Gets the offset into the underlying double[] data array for the first element of this vector
|
void |
getElements(double[] dest,
int destOffset)
Gets all elements of the array, copying them into a double array at the specified offset
|
void |
getElements(double[] data,
int offset,
int[] indices)
Gets the elements in this vector from the specified indices, storing at the specified
offset in the destination array
|
int |
hashCode()
Computes the hashcode of a vector.
|
protected int |
index(int i)
Computes an index into the underlying array for a given vector index
|
boolean |
isPackedArray()
Checks if this array is fully packed in row major order.
|
boolean |
isView()
Returns true if this vector is of a view type that references other vectors / data.
|
void |
logistic()
Computes the logistic function for every element in this vector.
|
void |
multiply(AVector v) |
void |
multiply(double factor)
Multiplies the vector by a constant factor
|
void |
multiply(Vector v) |
Vector |
multiplyCopy(double factor)
Returns a copy of the array with all elements multiplied by a single constant value
|
long |
nonZeroCount()
Returns the number of non-zero elements in the array.
|
static Vector |
of(double... values)
Create a vector with specific component values.
|
void |
scaleAdd(double factor,
double constant)
Scales this vector and adds a constant to every element
|
void |
set(AVector a)
Sets the vector to equal the value of another vector
|
void |
set(int i,
double value)
Sets a value at a given position in a mutable 1D array
|
void |
setElements(double[] values,
int offset)
Sets all elements in an array using the given double values
|
void |
signum()
Calculates the signum of all elements of this mutable array
Sets each component of the array to its sign value (-1, 0 or 1)
|
void |
square()
Squares all elements of the array in place
|
void |
sub(ADenseArrayVector v) |
void |
sub(ADenseArrayVector src,
int srcOffset) |
void |
sub(AVector v)
Subtracts a vector from this vector
|
void |
tanh()
Computes the tanh of every element in this vector.
|
void |
toDoubleBuffer(DoubleBuffer dest)
Copies the elements of this INDArray to the specified double buffer
|
Vector |
toNormal()
Creates a new mutable vector representing the normalised value of this vector
Returns null if the vector cannot be normalised (i.e.
|
Vector |
toVector()
Coerces this vector to the standard dense Vector format.
|
double |
unsafeGet(int i) |
void |
unsafeSet(int i,
double value) |
static Vector |
wrap(double[] source)
Wraps a double array into a Vector, does *no defensive copy* so use with caution
|
add, add, add, add, addMultiple, addMultipleToArray, addMultipleToArray, addProduct, addProduct, addProductToArray, addProductToArray, addToArray, addToArray, applyOp, copyTo, copyTo, copyTo, copyTo, divide, divideTo, dotProduct, dotProduct, elementAbsPowSum, elementPowSum, elementProduct, elementsEqual, elementSquaredSum, equals, exp, fillRange, getStride, isRangeZero, isZero, join, join, join, log, magnitude, maxAbsElement, maxAbsElementIndex, maxElementIndex, minElementIndex, multiply, multiplyTo, nonZeroIndices, pow, reciprocal, reduce, reduce, scaleAdd, selectView, set, setElements, slice, sqrt, squareCopy, subVector, toDoubleArray, tryEfficientJoin, validateadd, applyOpCopy, broadcast, broadcastLike, getArray, getStride, getStrides, hasUncountable, iteratorcheckIndex, checkLength, checkRange, checkSameLength, checkSameLength, elementCount, get, getShape, getShapeClone, isSameShape, length, sliceCountabsCopy, add, add, add, addAt, addCopy, addCopy, addCopy, addInnerProduct, addInnerProduct, addInnerProduct, addMultiple, addMultiple, addMultiple, addMultiple, addMultiple, addMultipleCopy, addPower, addPower, addPower, addProductCopy, addProductCopy, addToArray, addWeighted, angle, applyOp, applyOp, applyOp, asElementList, asVector, broadcastLike, broadcastLike, checkDimension, checkSameLength, clampMax, clampMin, compareTo, copy, copyTo, copyTo, crossProduct, crossProduct, denseClone, dimensionality, distanceL1, distanceLinf, distanceSquared, divide, divideCopy, divideCopy, dotProduct, elementIterator, epsilonEquals, epsilonEquals, epsilonEquals, epsilonEquals, equals, get, get, get, get, getElements, getLongShape, getShape, getSlices, getTranspose, getTransposeCopy, getTransposeView, immutable, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, interpolate, isElementConstrained, isFullyMutable, isMutable, isSameShape, isUnitLengthVector, isUnitLengthVector, join, join, magnitudeSquared, maxElement, minElement, multiply, multiply, multiplyCopy, multiplyCopy, mutable, negate, negateCopy, nonSparseIndex, nonZeroValues, normalise, normaliseCopy, normaliseMaxAbsElement, outerProduct, outerProduct, projectToPlane, reduceSlices, reduceSlices, reorder, reorder, reshape, rotateCopy, rotateView, rotateView, scale, scaleAdd, scaleAdd, scaleCopy, scaleToMagnitude, select, selectClone, set, set, set, set, set, set, set, set, setElements, setInnerProduct, setInnerProduct, setInnerProduct, setMultiple, setMultiple, setMultiple, setMultiple, shiftCopy, slice, sliceValue, softmax, softmaxCopy, sparse, sparseClone, sqrtCopy, sub, subArray, subAt, subCopy, subCopy, subMultiple, toList, toSliceArray, toString, toStringFulladd, addInnerProduct, addInnerProduct, addOuterProduct, broadcastCloneLike, broadcastCopyLike, checkMutable, componentCount, density, get, get, get, getComponent, getComponents, getElements, getElements, getSlices, getSliceViews, isBoolean, isDense, isSparse, reciprocalCopy, scale, set, set, signumCopy, sub, sub, toArray, withComponentsfinalize, getClass, notify, notifyAll, wait, wait, waitgetArrayabsCopy, add, addAt, addCopy, addCopy, addInnerProduct, addMultiple, addOuterProduct, addPower, addPower, addToArray, applyOp, applyOp, applyOp, asElementList, asVector, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, checkMutable, componentCount, copy, denseClone, dimensionality, divide, divideCopy, elementCount, elementIterator, epsilonEquals, epsilonEquals, get, get, get, get, get, get, get, get, getComponent, getComponents, getElements, getElements, getElements, getLongShape, getShape, getShape, getShapeClone, getSlices, getSlices, getSliceViews, getTranspose, getTransposeCopy, getTransposeView, immutable, innerProduct, innerProduct, innerProduct, innerProduct, isBoolean, isDense, isElementConstrained, isFullyMutable, isMutable, isSameShape, isSparse, join, join, multiply, multiplyCopy, mutable, negate, negateCopy, outerProduct, reciprocalCopy, reduceSlices, reduceSlices, reorder, reorder, reshape, rotateView, scale, scaleAdd, scaleCopy, set, set, set, set, set, set, setElements, setInnerProduct, setMultiple, setMultiple, signumCopy, slice, sliceCount, sliceValue, sparse, sparseClone, sub, sub, subArray, subCopy, toArray, toSliceArray, withComponentsforEach, spliteratorpublic static final Vector EMPTY
public Vector(AVector source)
source - public static Vector wrap(double[] source)
source - public static Vector create(double[] data)
public static Vector create(Iterable<Number> iterable)
iterable - An Iterable containing java.lang.Number instancespublic static Vector create(Iterator<Number> iterator)
iterator - An Iterator over java.lang.Number instancespublic static Vector create(double[] data, int start, int length)
public static Vector createFromVector(AVector source, int length)
data - public static Vector of(double... values)
values - public static Vector createLength(int length)
length - public double get(int i)
INDArraypublic double unsafeGet(int i)
unsafeGet in class ADenseArrayVectorpublic void set(int i,
double value)
INDArraypublic void unsafeSet(int i,
double value)
unsafeSet in class ADenseArrayVectorpublic void set(AVector a)
AVectorset in class ADenseArrayVectorpublic void getElements(double[] data,
int offset,
int[] indices)
AVectorgetElements in class AStridedVectorpublic int getArrayOffset()
AStridedVectorgetArrayOffset in interface IDenseArraygetArrayOffset in interface IStridedArraygetArrayOffset in class AStridedVectorpublic void applyOp(Op op)
INDArrayapplyOp in interface INDArrayapplyOp in class AStridedVectorpublic void fill(double value)
AVectorfill in interface INDArrayfill in class ADenseArrayVectorpublic void clamp(double min,
double max)
AVectorclamp in interface INDArrayclamp in class ADenseArrayVectorpublic void square()
INDArraysquare in interface INDArraysquare in class ADenseArrayVectorpublic void tanh()
AVectorpublic void logistic()
AVectorpublic double elementSum()
AVectorelementSum in interface INDArrayelementSum in class ADenseArrayVectorpublic double elementMax()
INDArrayelementMax in interface INDArrayelementMax in class ADenseArrayVectorpublic double elementMin()
INDArrayelementMin in interface INDArrayelementMin in class ADenseArrayVectorpublic long nonZeroCount()
INDArraynonZeroCount in interface INDArraynonZeroCount in class ADenseArrayVectorpublic void signum()
INDArraysignum in interface INDArraysignum in class ADenseArrayVectorpublic void abs()
INDArraypublic void add(ADenseArrayVector src, int srcOffset)
add in class ADenseArrayVectorpublic void addMultiple(ADenseArrayVector v, double factor)
addMultiple in class ADenseArrayVectorpublic void add(AVector v)
AVectoradd in class ADenseArrayVectorpublic void add(double[] srcData,
int srcOffset)
AVectoradd in class ADenseArrayVectorpublic void scaleAdd(double factor,
double constant)
AVectorscaleAdd in interface INDArrayscaleAdd in class ADenseArrayVectorpublic void add(double constant)
INDArrayadd in interface INDArrayadd in class ADenseArrayVectorpublic void addProduct(AVector a, AVector b)
AVectoraddProduct in class ADenseArrayVectorpublic void addAt(int i,
double v)
AVectoraddAt in class ADenseArrayVectorpublic void sub(AVector v)
AVectorpublic double dotProduct(AVector v, Index ix)
AVectordotProduct in class AVectorpublic double dotProduct(double[] data,
int offset)
AVectordotProduct in class ADenseArrayVectorpublic Vector multiplyCopy(double factor)
INDArraymultiplyCopy in interface INDArraymultiplyCopy in class AVectorfactor - A scalar factorpublic double distanceSquared(Vector v)
public double distance(AVector v)
AVectorpublic void sub(ADenseArrayVector v)
public void sub(ADenseArrayVector src, int srcOffset)
public void addMultiple(AVector v, double factor)
AVectoraddMultiple in class ADenseArrayVectorpublic void addMultiple(Vector source, Index index, double factor)
AVectoraddMultiple in class AVectorpublic void multiply(double factor)
AVectormultiply in interface INDArraymultiply in class ADenseArrayVectorfactor - Factor by which to multiply each component of the vectorpublic void multiply(AVector v)
multiply in class ADenseArrayVectorpublic void multiply(Vector v)
public void divide(AVector v)
divide in class ADenseArrayVectorpublic void divide(Vector v)
public void divide(double factor)
INDArraypublic boolean isView()
AVectorisView in interface INDArrayisView in class ADenseArrayVectorpublic Vector clone()
AVectorpublic int hashCode()
AVectorpublic Vector ensureMutable()
INDArrayensureMutable in interface INDArrayensureMutable in class AStridedVectorpublic Vector exactClone()
AVectorexactClone in interface INDArrayexactClone in class AVectorpublic boolean isPackedArray()
IStridedArrayisPackedArray in interface IStridedArrayisPackedArray in class ADenseArrayVectorpublic void toDoubleBuffer(DoubleBuffer dest)
INDArraytoDoubleBuffer in interface INDArraytoDoubleBuffer in class ADenseArrayVectorpublic Vector toNormal()
AVectorpublic Vector toVector()
AVectorpublic double[] asDoubleArray()
INDArrayasDoubleArray in interface INDArrayasDoubleArray in class AStridedVectorpublic Vector dense()
INDArraydense in interface INDArraydense in class ADenseArrayVectorpublic boolean equals(AVector v)
equals in class ADenseArrayVectorpublic boolean equalsArray(double[] arr,
int offset)
AVectorequalsArray in interface INDArrayequalsArray in class ADenseArrayVectorarr - Array of double element values to check for equalityoffset - Offset into the data arraypublic boolean equalsArray(double[] arr)
AVectorequalsArray in interface INDArrayequalsArray in class ADenseArrayVectorarr - Array of double element values to check for equalityprotected int index(int i)
AArrayVectorindex in class AArrayVectorpublic void setElements(double[] values,
int offset)
INDArraysetElements in interface INDArraysetElements in class AStridedVectorvalues - 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.public void getElements(double[] dest,
int destOffset)
INDArraygetElements in interface INDArraygetElements in class ADenseArrayVectorCopyright © 2016. All rights reserved.