|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mahout.math.AbstractVector
org.apache.mahout.math.RandomAccessSparseVector
public class RandomAccessSparseVector
Implements vector that only stores non-zero doubles
Nested Class Summary | |
---|---|
class |
RandomAccessSparseVector.Element
|
Field Summary | |
---|---|
protected OpenIntDoubleHashMap |
values
|
Fields inherited from class org.apache.mahout.math.AbstractVector |
---|
lengthSquared, size |
Constructor Summary | |
---|---|
RandomAccessSparseVector()
For serialization purposes only. |
|
RandomAccessSparseVector(int cardinality)
|
|
RandomAccessSparseVector(int cardinality,
int size)
|
|
RandomAccessSparseVector(RandomAccessSparseVector other,
boolean shallowCopy)
|
|
RandomAccessSparseVector(java.lang.String name,
int cardinality)
|
|
RandomAccessSparseVector(java.lang.String name,
int cardinality,
int size)
|
|
RandomAccessSparseVector(Vector other)
|
Method Summary | |
---|---|
void |
addTo(Vector v)
Add the elements to the other vector and results are stored in that vector. |
Vector |
assign(Vector other)
Assign the other matrix values to the receiver |
RandomAccessSparseVector |
clone()
Return a copy of the recipient |
double |
dot(Vector x)
Return the dot product of the recipient and the argument |
boolean |
equals(java.lang.Object o)
Indicate whether the two objects are the same or not. |
Vector.Element |
getElement(int index)
Return an object of Vector.Element representing an element of this Vector. |
int |
getNumNondefaultElements()
Return the number of values in the recipient |
double |
getQuick(int index)
Return the value at the given index, without checking bounds |
java.util.Iterator<Vector.Element> |
iterateAll()
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 |
java.util.Iterator<Vector.Element> |
iterateNonZero()
NOTE: this implementation reuses the Vector.Element instance for each call of next(). |
RandomAccessSparseVector |
like()
Return an empty matrix of the same underlying class as the receiver |
Vector |
like(int newCardinality)
Return an empty matrix of the same underlying class as the receiver and of the given cardinality |
protected Matrix |
matrixLike(int rows,
int columns)
Subclasses must override to return an appropriately sparse or dense result |
void |
setQuick(int index,
double value)
Set the value at the given index, without checking bounds |
Methods inherited from class org.apache.mahout.math.AbstractVector |
---|
aggregate, aggregate, asFormatString, assign, assign, assign, assign, assign, cross, decodeVector, divide, dotSelf, equivalent, get, get, getDistanceSquared, getLabelBindings, getLengthSquared, getName, hashCode, maxValue, maxValueIndex, minus, norm, normalize, normalize, plus, plus, set, set, set, setLabelBindings, setName, size, strictEquivalence, times, times, viewPart, zSum |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected OpenIntDoubleHashMap values
Constructor Detail |
---|
public RandomAccessSparseVector()
public RandomAccessSparseVector(int cardinality)
public RandomAccessSparseVector(int cardinality, int size)
public RandomAccessSparseVector(java.lang.String name, int cardinality)
public RandomAccessSparseVector(java.lang.String name, int cardinality, int size)
public RandomAccessSparseVector(Vector other)
public RandomAccessSparseVector(RandomAccessSparseVector other, boolean shallowCopy)
Method Detail |
---|
protected Matrix matrixLike(int rows, int columns)
AbstractVector
matrixLike
in class AbstractVector
rows
- the row cardinalitycolumns
- the column cardinality
public RandomAccessSparseVector clone()
Vector
clone
in interface Vector
clone
in class AbstractVector
public Vector assign(Vector other)
Vector
assign
in interface Vector
assign
in class AbstractVector
other
- a Vector
public double getQuick(int index)
Vector
index
- an int index
public void setQuick(int index, double value)
Vector
index
- an int index into the receivervalue
- a double value to setpublic int getNumNondefaultElements()
Vector
public RandomAccessSparseVector like()
Vector
public Vector like(int newCardinality)
Vector
newCardinality
- an int specifying the desired cardinality
public java.util.Iterator<Vector.Element> iterateNonZero()
NonZeroIterator
over the Elements.getElement(int)
public java.util.Iterator<Vector.Element> iterateAll()
Vector
Vector.getElement(int)
for the given index
Iterator
over all elementspublic boolean equals(java.lang.Object o)
Vector
s can be equal
even if the underlying implementation is not equal.
equals
in class java.lang.Object
o
- The object to compare
AbstractVector.equivalent(Vector, Vector)
public Vector.Element getElement(int index)
Vector
index
- Index of the Vector.Element required
public void addTo(Vector v)
Vector
addTo
in interface Vector
addTo
in class AbstractVector
public double dot(Vector x)
Vector
dot
in interface Vector
dot
in class AbstractVector
x
- a Vector
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |