|
||||||||||
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.DenseVector
public class DenseVector
Implements vector as an array of doubles
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.mahout.math.AbstractVector |
---|
AbstractVector.LocalElement |
Nested classes/interfaces inherited from interface org.apache.mahout.math.Vector |
---|
Vector.Element |
Field Summary |
---|
Fields inherited from class org.apache.mahout.math.AbstractVector |
---|
lengthSquared |
Constructor Summary | |
---|---|
DenseVector()
For serialization purposes only |
|
DenseVector(DenseVector values,
boolean shallowCopy)
|
|
DenseVector(double[] values)
Construct a new instance using provided values |
|
DenseVector(double[] values,
boolean shallowCopy)
|
|
DenseVector(int cardinality)
Construct a new instance of the given cardinality |
|
DenseVector(Vector vector)
Copy-constructor (for use in turning a sparse vector into a dense one, for example) |
Method Summary | |
---|---|
void |
addAll(Vector v)
|
Vector |
assign(DenseVector vector)
|
Vector |
assign(double value)
Assign the value to all elements of 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 |
DenseVector |
clone()
Return a copy of the recipient |
double |
dotSelf()
|
boolean |
equals(Object o)
Determines whether this Vector represents the same logical vector as another
object. |
double |
getLengthSquared()
Return the sum of squares of all elements in the vector. |
int |
getNumNondefaultElements()
Return the number of values in the recipient which are not the default value. |
double |
getQuick(int index)
Return the value at the given index, without checking bounds |
boolean |
isDense()
|
boolean |
isSequentialAccess()
|
Iterator<Vector.Element> |
iterateNonZero()
Returns an iterator that traverses this Vector from 0 to cardinality-1, in that order. |
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 |
DenseVector |
like()
Return an empty vector of the same underlying class as the receiver |
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 |
Vector |
viewPart(int offset,
int length)
Return a new vector containing the subset of the recipient |
Methods inherited from class org.apache.mahout.math.AbstractVector |
---|
aggregate, aggregate, asFormatString, assign, assign, assign, assign, cross, divide, dot, get, getDistanceSquared, getElement, hashCode, logNormalize, logNormalize, logNormalize, maxValue, maxValueIndex, minus, minValue, minValueIndex, norm, normalize, normalize, plus, plus, set, size, times, times, toString, toString, zSum |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DenseVector()
public DenseVector(double[] values)
public DenseVector(double[] values, boolean shallowCopy)
public DenseVector(DenseVector values, boolean shallowCopy)
public DenseVector(int cardinality)
public DenseVector(Vector vector)
vector
- Method Detail |
---|
protected Matrix matrixLike(int rows, int columns)
AbstractVector
matrixLike
in class AbstractVector
rows
- the row cardinalitycolumns
- the column cardinality
public DenseVector clone()
Vector
clone
in interface Vector
clone
in class AbstractVector
public boolean isDense()
public boolean isSequentialAccess()
public double dotSelf()
dotSelf
in class AbstractVector
public double getQuick(int index)
Vector
index
- an int index
public DenseVector like()
Vector
public void setQuick(int index, double value)
Vector
index
- an int index into the receivervalue
- a double value to setpublic Vector assign(double value)
Vector
assign
in interface Vector
assign
in class AbstractVector
value
- a double value
public Vector assign(Vector other, DoubleDoubleFunction function)
Vector
assign
in interface Vector
assign
in class AbstractVector
other
- a Vector containing the second arguments to the functionfunction
- a DoubleDoubleFunction to apply
public Vector assign(DenseVector vector)
public int getNumNondefaultElements()
Vector
public Vector viewPart(int offset, int length)
Vector
viewPart
in interface Vector
viewPart
in class AbstractVector
offset
- an int offset into the receiverlength
- the cardinality of the desired result
public Iterator<Vector.Element> iterateNonZero()
Iterator
over all non-zero elementspublic Iterator<Vector.Element> iterator()
Vector
Vector.getElement(int)
for the given index
Iterator
over all elementspublic boolean equals(Object o)
AbstractVector
Vector
represents the same logical vector as another
object. Two Vector
s are equal (regardless of implementation) if the value at
each index is the same, and the cardinalities are the same.
equals
in class AbstractVector
public double getLengthSquared()
Vector
getLengthSquared
in interface Vector
getLengthSquared
in class AbstractVector
public void addAll(Vector v)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |