public class VectorView extends AbstractVector
Modifier and Type | Class and Description |
---|---|
class |
VectorView.AllIterator |
class |
VectorView.NonZeroIterator |
AbstractVector.LocalElement
Vector.Element
Modifier and Type | Field and Description |
---|---|
protected int |
offset |
protected Vector |
vector |
lengthSquared
Constructor and Description |
---|
VectorView()
For serialization purposes only
|
VectorView(Vector vector,
int offset,
int cardinality) |
Modifier and Type | Method and Description |
---|---|
Vector |
clone()
Return a copy of the recipient
|
double |
getDistanceSquared(Vector v)
Get the square of the distance between this vector and the other vector.
|
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 |
getLengthSquared()
Return the sum of squares of all elements in the 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.
|
double |
getQuick(int index)
Return the value at the given index, without checking bounds
|
boolean |
isAddConstantTime()
Return true iff adding a new (nonzero) element takes constant time for this vector.
|
boolean |
isDense()
true if this implementation should be considered dense -- that it explicitly
represents every value
|
boolean |
isSequentialAccess()
true if this implementation should be considered to be iterable in index order in an efficient way.
|
Iterator<Vector.Element> |
iterateNonZero()
Iterates over all non-zero elements.
|
Iterator<Vector.Element> |
iterator()
Iterates over all elements
|
VectorView |
like()
Return an empty vector of the same underlying class as the receiver
|
Vector |
like(int cardinality)
Return a new empty vector of the same underlying class as the receiver with given cardinality
|
protected Matrix |
matrixLike(int rows,
int columns)
Subclasses must override to return an appropriately sparse or dense result
|
void |
mergeUpdates(OrderedIntDoubleMapping updates)
Used internally by assign() to update multiple indices and values at once.
|
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
|
aggregate, aggregate, all, asFormatString, assign, assign, assign, assign, assign, assign, createOptimizedCopy, cross, divide, dot, dotSelf, equals, get, getElement, getNumNonZeroElements, hashCode, incrementQuick, invalidateCachedLength, logNormalize, logNormalize, logNormalize, maxValue, maxValueIndex, minus, minValue, minValueIndex, nonZeroes, norm, normalize, normalize, plus, plus, set, size, sparseVectorToString, times, times, toString, toString, zSum
protected Vector vector
protected int offset
public VectorView()
public VectorView(Vector vector, int offset, int cardinality)
protected Matrix matrixLike(int rows, int columns)
AbstractVector
matrixLike
in class AbstractVector
rows
- the row cardinalitycolumns
- the column cardinalitypublic Vector clone()
Vector
clone
in interface Vector
clone
in class AbstractVector
public boolean isDense()
Vector
public boolean isSequentialAccess()
Vector
Vector.all()
and Vector.nonZeroes()
()} return elements
in ascending order by index.public VectorView like()
Vector
public Vector like(int cardinality)
Vector
cardinality
- - size of vectorVector
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 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 resultpublic Iterator<Vector.Element> iterateNonZero()
AbstractVector
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
iterateNonZero
in class AbstractVector
Iterator
over all non-zero elementspublic Iterator<Vector.Element> iterator()
AbstractVector
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
iterator
in class AbstractVector
Iterator
over all elementspublic double getLengthSquared()
Vector
getLengthSquared
in interface Vector
getLengthSquared
in class AbstractVector
public double getDistanceSquared(Vector v)
Vector
getDistanceSquared
in interface Vector
getDistanceSquared
in class AbstractVector
public double getLookupCost()
Vector
public double getIteratorAdvanceCost()
Vector
public boolean isAddConstantTime()
Vector
public void mergeUpdates(OrderedIntDoubleMapping updates)
If someone ever adds a new type of sparse vectors, this method must merge (index, value) pairs into the vector.
updates
- a mapping of indices to values to merge in the vector.Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.