|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mahout.math.NamedVector
public class NamedVector
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.mahout.math.Vector |
---|
Vector.Element |
Constructor Summary | |
---|---|
NamedVector()
|
|
NamedVector(NamedVector other)
|
|
NamedVector(Vector delegate,
java.lang.String name)
|
Method Summary | |
---|---|
void |
addTo(Vector v)
Add the elements to the other vector and results are stored in that vector. |
double |
aggregate(BinaryFunction aggregator,
UnaryFunction 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,
BinaryFunction aggregator,
BinaryFunction 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. |
java.lang.String |
asFormatString()
|
Vector |
assign(BinaryFunction f,
double y)
Apply the function to each element of the receiver, using the y value as the second argument of the BinaryFunction |
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(UnaryFunction 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,
BinaryFunction function)
Apply the function to each element of the receiver and the corresponding element of the other argument |
NamedVector |
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 |
boolean |
equals(java.lang.Object other)
To not break transitivity with other Vector s, this does not compare name. |
double |
get(int index)
Return the value at the given index |
Vector |
getDelegate()
|
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. |
java.lang.String |
getName()
|
int |
getNumNondefaultElements()
Return the number of values in the recipient |
double |
getQuick(int index)
Return the value at the given index, without checking bounds |
int |
hashCode()
|
boolean |
isDense()
|
boolean |
isSequentialAccess()
|
java.util.Iterator<Vector.Element> |
iterateNonZero()
Iterates over all non-zero elements. |
java.util.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 Vector.getElement(int) for the given index |
NamedVector |
like()
Return an empty vector of the same underlying class as the receiver |
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. |
double |
maxValue()
|
int |
maxValueIndex()
|
Vector |
minus(Vector x)
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 |
void |
setQuick(int index,
double value)
Set the value at the given index, without checking bounds |
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 |
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, toString, wait, wait, wait |
Constructor Detail |
---|
public NamedVector()
public NamedVector(NamedVector other)
public NamedVector(Vector delegate, java.lang.String name)
Method Detail |
---|
public java.lang.String getName()
public Vector getDelegate()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object other)
Vector
s, this does not compare name.
equals
in class java.lang.Object
public NamedVector clone()
Vector
clone
in interface Vector
clone
in class java.lang.Object
public java.lang.String asFormatString()
asFormatString
in interface Vector
public Vector assign(double value)
Vector
assign
in interface Vector
value
- a double value
public Vector assign(double[] values)
Vector
assign
in interface Vector
values
- a double[] of values
public Vector assign(Vector other)
Vector
assign
in interface Vector
other
- a Vector
public Vector assign(UnaryFunction function)
Vector
assign
in interface Vector
function
- a UnaryFunction to apply
public Vector assign(Vector other, BinaryFunction function)
Vector
assign
in interface Vector
other
- a Vector containing the second arguments to the functionfunction
- a BinaryFunction to apply
public Vector assign(BinaryFunction f, double y)
Vector
assign
in interface Vector
f
- a BinaryFunction to be appliedy
- a double value to be argument to the function
public int size()
Vector
size
in interface Vector
public boolean isDense()
isDense
in interface Vector
Vector
implementation should be considered dense -- that it explicitly
represents every valuepublic boolean isSequentialAccess()
isSequentialAccess
in interface Vector
Vector
should be considered to be iterable in index order in an efficient way.
In particular this implies that Vector.iterator()
and Vector.iterateNonZero()
return elements
in ascending order by index.public java.util.Iterator<Vector.Element> iterator()
Vector
Vector.getElement(int)
for the given index
iterator
in interface java.lang.Iterable<Vector.Element>
iterator
in interface Vector
Iterator
over all elementspublic java.util.Iterator<Vector.Element> iterateNonZero()
Vector
Vector.getElement(int)
for the given index
iterateNonZero
in interface Vector
Iterator
over all non-zero elementspublic Vector.Element getElement(int index)
Vector
getElement
in interface Vector
index
- Index of the Vector.Element required
public Vector divide(double x)
Vector
divide
in interface Vector
x
- a double value
public double dot(Vector x)
Vector
dot
in interface Vector
x
- a Vector
public double get(int index)
Vector
get
in interface Vector
index
- an int index
public double getQuick(int index)
Vector
getQuick
in interface Vector
index
- an int index
public NamedVector like()
Vector
like
in interface Vector
public Vector minus(Vector x)
Vector
minus
in interface Vector
x
- a Vector
public Vector normalize()
Vector
normalize
in interface Vector
public Vector normalize(double power)
Vector
Double.POSITIVE_INFINITY
(max element). Again, see the Wikipedia page for more info
normalize
in interface Vector
power
- 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 Vector
public Vector logNormalize(double power)
Vector
logNormalize
in interface Vector
power
- The power to use. Must be > 1. Cannot be Double.POSITIVE_INFINITY
.
public double norm(double power)
Vector
Double.POSITIVE_INFINITY
(max element). Again, see the Wikipedia page for
more info.
norm
in interface Vector
power
- The power to use.Vector.normalize(double)
public double maxValue()
maxValue
in interface Vector
public int maxValueIndex()
maxValueIndex
in interface Vector
public double minValue()
minValue
in interface Vector
public int minValueIndex()
minValueIndex
in interface Vector
public Vector plus(double x)
Vector
plus
in interface Vector
x
- a double
public Vector plus(Vector x)
Vector
plus
in interface Vector
x
- a Vector
public void set(int index, double value)
Vector
set
in interface Vector
index
- an int index into the receivervalue
- a double value to setpublic void setQuick(int index, double value)
Vector
setQuick
in interface Vector
index
- an int index into the receivervalue
- a double value to setpublic int getNumNondefaultElements()
Vector
getNumNondefaultElements
in interface Vector
public Vector times(double x)
Vector
times
in interface Vector
x
- a double argument
public Vector times(Vector x)
Vector
times
in interface Vector
x
- a Vector argument
public Vector viewPart(int offset, int length)
Vector
viewPart
in interface Vector
offset
- an int offset into the receiverlength
- the cardinality of the desired result
public double zSum()
Vector
zSum
in interface Vector
public Matrix cross(Vector other)
Vector
cross
in interface Vector
other
- another Vector
public double aggregate(BinaryFunction aggregator, UnaryFunction map)
Vector
aggregate
in interface Vector
aggregator
- 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, BinaryFunction aggregator, BinaryFunction combiner)
Vector
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.
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 Vector
other
- a vector to aggregate in combination with
public double getLengthSquared()
Vector
getLengthSquared
in interface Vector
public double getDistanceSquared(Vector v)
Vector
getDistanceSquared
in interface Vector
public void addTo(Vector v)
Vector
addTo
in interface Vector
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |