public abstract class AbstractVector extends Object implements Vector
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractVector.LocalElement |
Vector.Element| Modifier and Type | Field and Description |
|---|---|
protected double |
lengthSquared |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractVector(int size) |
| Modifier and Type | Method and Description |
|---|---|
double |
aggregate(DoubleDoubleFunction aggregator,
DoubleFunction map)
Aggregates a vector by applying a mapping function fm(x) to every component and aggregating
the results with an aggregating function fa(x, y).
|
double |
aggregate(Vector other,
DoubleDoubleFunction aggregator,
DoubleDoubleFunction combiner)
Generalized inner product - take two vectors, iterate over them both, using the combiner to combine together
(and possibly map in some way) each pair of values, which are then aggregated with the previous accumulated
value in the combiner.
|
Iterable<Vector.Element> |
all() |
String |
asFormatString() |
Vector |
assign(double value)
Assign the value to all elements of the receiver
|
Vector |
assign(double[] values)
Assign the values to the receiver
|
Vector |
assign(DoubleDoubleFunction f,
double y)
Apply the function to each element of the receiver, using the y value as the second argument of the
DoubleDoubleFunction
|
Vector |
assign(DoubleFunction f)
Apply the function to each element of the receiver
|
Vector |
assign(Vector other)
Assign the other vector values to the receiver
|
Vector |
assign(Vector other,
DoubleDoubleFunction function)
Apply the function to each element of the receiver and the corresponding element of the other argument
|
Vector |
clone()
Return a copy of the recipient
|
protected Vector |
createOptimizedCopy()
Copy the current vector in the most optimum fashion.
|
Matrix |
cross(Vector other)
Return the cross product of the receiver and the other vector
|
Vector |
divide(double x)
Return a new vector containing the values of the recipient divided by the argument
|
double |
dot(Vector x)
Return the dot product of the recipient and the argument
|
protected double |
dotSelf() |
boolean |
equals(Object o)
Determines whether this
Vector represents the same logical vector as another
object. |
double |
get(int index)
Return the value at the given index
|
double |
getDistanceSquared(Vector that)
Get the square of the distance between this vector and the other vector.
|
Vector.Element |
getElement(int index)
Return an object of Vector.Element representing an element of this Vector.
|
double |
getLengthSquared()
Return the sum of squares of all elements in the vector.
|
int |
getNumNonZeroElements()
Return the number of non zero elements in the vector.
|
int |
hashCode() |
void |
incrementQuick(int index,
double increment)
Increment the value at the given index by the given value.
|
void |
invalidateCachedLength()
Invalidates the length cache.
|
protected abstract Iterator<Vector.Element> |
iterateNonZero()
Iterates over all non-zero elements.
|
protected abstract Iterator<Vector.Element> |
iterator()
Iterates over all elements * NOTE: Implementations may choose to reuse the Element returned for performance
reasons, so if you need a copy of it, you should call
getElement(int) for the given index |
Vector |
logNormalize()
Return a new vector containing the log(1 + entry)/ L_2 norm values of the recipient
|
Vector |
logNormalize(double power)
Return a new Vector with a normalized value calculated as log_power(1 + entry)/ L_power norm.
|
Vector |
logNormalize(double power,
double normLength) |
protected abstract Matrix |
matrixLike(int rows,
int columns)
Subclasses must override to return an appropriately sparse or dense result
|
double |
maxValue() |
int |
maxValueIndex() |
Vector |
minus(Vector that)
Return a new vector containing the element by element difference of the recipient and the argument
|
double |
minValue() |
int |
minValueIndex() |
Iterable<Vector.Element> |
nonZeroes() |
double |
norm(double power)
Return the k-norm of the vector.
|
Vector |
normalize()
Return a new vector containing the normalized (L_2 norm) values of the recipient
|
Vector |
normalize(double power)
Return a new Vector containing the normalized (L_power norm) values of the recipient.
|
Vector |
plus(double x)
Return a new vector containing the sum of each value of the recipient and the argument
|
Vector |
plus(Vector that)
Return a new vector containing the element by element sum of the recipient and the argument
|
void |
set(int index,
double value)
Set the value at the given index
|
int |
size()
Return the cardinality of the recipient (the maximum number of values)
|
String |
sparseVectorToString()
toString() implementation for sparse vectors via
nonZeroes() method |
Vector |
times(double x)
Return a new vector containing the product of each value of the recipient and the argument
|
Vector |
times(Vector that)
Return a new vector containing the element-wise product of the recipient and the argument
|
String |
toString() |
String |
toString(String[] dictionary) |
Vector |
viewPart(int offset,
int length)
Return a new vector containing the subset of the recipient
|
double |
zSum()
Return the sum of all the elements of the receiver
|
finalize, getClass, notify, notifyAll, wait, wait, waitgetIteratorAdvanceCost, getLookupCost, getNumNondefaultElements, getQuick, isAddConstantTime, isDense, isSequentialAccess, like, like, mergeUpdates, setQuickpublic Iterable<Vector.Element> all()
public Iterable<Vector.Element> nonZeroes()
protected abstract Iterator<Vector.Element> iterator()
getElement(int) for the given indexIterator over all elementsprotected abstract Iterator<Vector.Element> iterateNonZero()
getElement(int) for the given indexIterator over all non-zero elementspublic double aggregate(DoubleDoubleFunction aggregator, DoubleFunction map)
public double aggregate(Vector other, DoubleDoubleFunction aggregator, DoubleDoubleFunction combiner)
VectorGeneralized inner product - take two vectors, iterate over them both, using the combiner to combine together (and possibly map in some way) each pair of values, which are then aggregated with the previous accumulated value in the combiner.
Example: dot(other) could be expressed as aggregate(other, Plus, Times), and kernelized inner products (which are symmetric on the indices) work similarly.
aggregate in interface Vectorother - a vector to aggregate in combination withaggregator - function we're aggregating with; facombiner - function we're combining with; fcprotected abstract Matrix matrixLike(int rows, int columns)
rows - the row cardinalitycolumns - the column cardinalitypublic Vector viewPart(int offset, int length)
Vectorpublic Vector clone()
Vectorpublic Vector divide(double x)
Vectorpublic double dot(Vector x)
Vectorprotected double dotSelf()
public double get(int index)
Vectorpublic Vector.Element getElement(int index)
VectorgetElement in interface Vectorindex - Index of the Vector.Element requiredpublic Vector normalize()
Vectorpublic Vector normalize(double power)
VectorDouble.POSITIVE_INFINITY (max element). Again, see the Wikipedia page for more infonormalize in interface Vectorpower - The power to use. Must be >= 0. May also be Double.POSITIVE_INFINITY. See the Wikipedia link
for more on this.public Vector logNormalize()
VectorlogNormalize in interface Vectorpublic Vector logNormalize(double power)
VectorlogNormalize in interface Vectorpower - The power to use. Must be > 1. Cannot be Double.POSITIVE_INFINITY.public Vector logNormalize(double power, double normLength)
public double norm(double power)
VectorDouble.POSITIVE_INFINITY (max element). Again, see the Wikipedia page for
more info.norm in interface Vectorpower - The power to use.Vector.normalize(double)public double getLengthSquared()
VectorgetLengthSquared in interface Vectorpublic void invalidateCachedLength()
public double getDistanceSquared(Vector that)
VectorgetDistanceSquared in interface Vectorpublic double maxValue()
public int maxValueIndex()
maxValueIndex in interface Vectorpublic double minValue()
public int minValueIndex()
minValueIndex in interface Vectorpublic Vector plus(double x)
Vectorpublic Vector plus(Vector that)
Vectorpublic Vector minus(Vector that)
Vectorpublic void set(int index,
double value)
Vectorpublic void incrementQuick(int index,
double increment)
VectorincrementQuick in interface Vectorindex - an int index into the receiverincrement - sets the value at the given index to value + increment;public Vector times(double x)
Vectorprotected Vector createOptimizedCopy()
public Vector times(Vector that)
Vectorpublic double zSum()
Vectorpublic int getNumNonZeroElements()
VectorgetNumNonZeroElements in interface Vectorpublic Vector assign(double value)
Vectorpublic Vector assign(double[] values)
Vectorpublic Vector assign(Vector other)
Vectorpublic Vector assign(DoubleDoubleFunction f, double y)
Vectorpublic Vector assign(DoubleFunction f)
Vectorpublic Vector assign(Vector other, DoubleDoubleFunction function)
Vectorpublic Matrix cross(Vector other)
Vectorpublic final int size()
Vectorpublic String asFormatString()
asFormatString in interface Vectorpublic boolean equals(Object o)
public String sparseVectorToString()
nonZeroes() methodCopyright © 2008–2016 The Apache Software Foundation. All rights reserved.