public class RandomAccessSparseVector extends AbstractVector
AbstractVector.LocalElement
Vector.Element
lengthSquared
Constructor and Description |
---|
RandomAccessSparseVector()
For serialization purposes only.
|
RandomAccessSparseVector(int cardinality) |
RandomAccessSparseVector(int cardinality,
int initialCapacity) |
RandomAccessSparseVector(RandomAccessSparseVector other,
boolean shallowCopy) |
RandomAccessSparseVector(Vector other) |
Modifier and Type | Method and Description |
---|---|
Vector |
assign(Vector other)
Assign the other vector values to the receiver
|
RandomAccessSparseVector |
clone()
Return a copy of the recipient
|
double |
getIteratorAdvanceCost()
Gets an estimate of the cost (in number of operations) it takes to advance an iterator through the nonzero
elements of this vector.
|
double |
getLookupCost()
Gets an estimate of the cost (in number of operations) it takes to lookup a random element in this vector.
|
int |
getNumNondefaultElements()
Return the number of values in the recipient which are not the default value.
|
int |
getNumNonZeroElements()
Return the number of non zero elements in the vector.
|
double |
getQuick(int index)
Return the value at the given index, without checking bounds
|
void |
incrementQuick(int index,
double increment)
Increment the value at the given index by the given value.
|
boolean |
isAddConstantTime()
This is "sort of" constant, but really it might resize the array.
|
boolean |
isDense() |
boolean |
isSequentialAccess() |
Iterator<Vector.Element> |
iterateNonZero()
NOTE: this implementation reuses the Vector.Element instance for each call of next().
|
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
AbstractVector.getElement(int) for the given index |
RandomAccessSparseVector |
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 |
mergeUpdates(OrderedIntDoubleMapping updates)
Merge a set of (index, value) pairs into the vector.
|
void |
setQuick(int index,
double value)
Set the value at the given index, without checking bounds
|
String |
toString() |
aggregate, aggregate, all, asFormatString, assign, assign, assign, assign, assign, createOptimizedCopy, cross, divide, dot, dotSelf, equals, get, getDistanceSquared, getElement, getLengthSquared, hashCode, invalidateCachedLength, logNormalize, logNormalize, logNormalize, maxValue, maxValueIndex, minus, minValue, minValueIndex, nonZeroes, norm, normalize, normalize, plus, plus, set, size, sparseVectorToString, times, times, toString, viewPart, zSum
public RandomAccessSparseVector()
public RandomAccessSparseVector(int cardinality)
public RandomAccessSparseVector(int cardinality, int initialCapacity)
public RandomAccessSparseVector(Vector other)
public RandomAccessSparseVector(RandomAccessSparseVector other, boolean shallowCopy)
protected Matrix matrixLike(int rows, int columns)
AbstractVector
matrixLike
in class AbstractVector
rows
- the row cardinalitycolumns
- the column cardinalitypublic RandomAccessSparseVector clone()
Vector
clone
in interface Vector
clone
in class AbstractVector
public String toString()
toString
in class AbstractVector
public Vector assign(Vector other)
Vector
assign
in interface Vector
assign
in class AbstractVector
other
- a Vectorpublic void mergeUpdates(OrderedIntDoubleMapping updates)
Vector
updates
- an ordered mapping of indices to values to be merged in.public boolean isDense()
public boolean isSequentialAccess()
public double getQuick(int index)
Vector
index
- an int indexpublic void setQuick(int index, double value)
Vector
index
- an int index into the receivervalue
- a double value to setpublic void incrementQuick(int index, double increment)
Vector
incrementQuick
in interface Vector
incrementQuick
in class AbstractVector
index
- an int index into the receiverincrement
- sets the value at the given index to value + increment;public RandomAccessSparseVector like()
Vector
public int getNumNondefaultElements()
Vector
public int getNumNonZeroElements()
Vector
getNumNonZeroElements
in interface Vector
getNumNonZeroElements
in class AbstractVector
public double getLookupCost()
Vector
public double getIteratorAdvanceCost()
Vector
public boolean isAddConstantTime()
public Iterator<Vector.Element> iterateNonZero()
iterateNonZero
in class AbstractVector
Iterator
over the Elements.AbstractVector.getElement(int)
public Iterator<Vector.Element> iterator()
AbstractVector
AbstractVector.getElement(int)
for the given indexiterator
in class AbstractVector
Iterator
over all elementsCopyright © 2008–2015 The Apache Software Foundation. All rights reserved.