|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.mahout.math.AbstractVector
public abstract class AbstractVector
Implementations of generic capabilities like sum of elements and dot products
| Nested Class Summary | |
|---|---|
protected class |
AbstractVector.LocalElement
|
| Nested classes/interfaces inherited from interface org.apache.mahout.math.Vector |
|---|
Vector.Element |
| Field Summary | |
|---|---|
protected double |
lengthSquared
|
| Constructor Summary | |
|---|---|
protected |
AbstractVector(int size)
|
| Method Summary | |
|---|---|
double |
aggregate(DoubleDoubleFunction aggregator,
DoubleFunction map)
Examples speak louder than words: aggregate(plus, pow(2)) is another way to say getLengthSquared(), aggregate(max, abs) is norm(Double.POSITIVE_INFINITY). |
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. |
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 function)
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 |
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 |
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 v)
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 |
hashCode()
|
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()
|
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 x)
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) |
Vector |
times(double x)
Return a new vector containing the product of each value of the recipient and the argument |
Vector |
times(Vector x)
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 |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.apache.mahout.math.Vector |
|---|
getNumNondefaultElements, getQuick, isDense, isSequentialAccess, iterateNonZero, iterator, like, setQuick |
| Field Detail |
|---|
protected double lengthSquared
| Constructor Detail |
|---|
protected AbstractVector(int size)
| Method Detail |
|---|
public double aggregate(DoubleDoubleFunction aggregator,
DoubleFunction map)
Vector
aggregate in interface Vectoraggregator - used to combine the current value of the aggregation with the result of map.apply(nextValue)map - a function to apply to each element of the vector in turn before passing to the aggregator
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 with
protected abstract Matrix matrixLike(int rows,
int columns)
rows - the row cardinalitycolumns - the column cardinality
public Vector viewPart(int offset,
int length)
Vector
viewPart in interface Vectoroffset - an int offset into the receiverlength - the cardinality of the desired result
public Vector clone()
Vector
clone in interface Vectorclone in class Objectpublic Vector divide(double x)
Vector
divide in interface Vectorx - a double value
public double dot(Vector x)
Vector
dot in interface Vectorx - a Vector
public double dotSelf()
public double get(int index)
Vector
get in interface Vectorindex - an int index
public Vector.Element getElement(int index)
Vector
getElement in interface Vectorindex - Index of the Vector.Element required
public Vector minus(Vector that)
Vector
minus in interface Vectorthat - a Vector
public Vector normalize()
Vector
normalize in interface Vectorpublic Vector normalize(double power)
VectorDouble.POSITIVE_INFINITY (max element). Again, see the Wikipedia page for more info
normalize 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()
Vector
logNormalize in interface Vectorpublic Vector logNormalize(double power)
Vector
logNormalize 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()
Vector
getLengthSquared in interface Vectorpublic double getDistanceSquared(Vector v)
Vector
getDistanceSquared in interface Vectorpublic double maxValue()
maxValue in interface Vectorpublic int maxValueIndex()
maxValueIndex in interface Vectorpublic double minValue()
minValue in interface Vectorpublic int minValueIndex()
minValueIndex in interface Vectorpublic Vector plus(double x)
Vector
plus in interface Vectorx - a double
public Vector plus(Vector x)
Vector
plus in interface Vectorx - a Vector
public void set(int index,
double value)
Vector
set in interface Vectorindex - an int index into the receivervalue - a double value to setpublic Vector times(double x)
Vector
times in interface Vectorx - a double argument
public Vector times(Vector x)
Vector
times in interface Vectorx - a Vector argument
public double zSum()
Vector
zSum in interface Vectorpublic Vector assign(double value)
Vector
assign in interface Vectorvalue - a double value
public Vector assign(double[] values)
Vector
assign in interface Vectorvalues - a double[] of values
public Vector assign(Vector other)
Vector
assign in interface Vectorother - a Vector
public Vector assign(DoubleDoubleFunction f,
double y)
Vector
assign in interface Vectorf - a DoubleDoubleFunction to be appliedy - a double value to be argument to the function
public Vector assign(DoubleFunction function)
Vector
assign in interface Vectorfunction - a DoubleFunction to apply
public Vector assign(Vector other,
DoubleDoubleFunction function)
Vector
assign in interface Vectorother - a Vector containing the second arguments to the functionfunction - a DoubleDoubleFunction to apply
public Matrix cross(Vector other)
Vector
cross in interface Vectorother - another Vector
public final int size()
Vector
size in interface Vectorpublic String asFormatString()
asFormatString in interface Vectorpublic int hashCode()
hashCode in class Objectpublic boolean equals(Object o)
Vector represents the same logical vector as another
object. Two Vectors are equal (regardless of implementation) if the value at
each index is the same, and the cardinalities are the same.
equals in class Objectpublic String toString()
toString in class Objectpublic String toString(String[] dictionary)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||