public class DenseVector extends AbstractVector
AbstractVector.LocalElementVector.ElementlengthSquared| Constructor and Description |
|---|
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)
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAll(Vector v) |
Vector |
assign(DenseVector vector) |
Vector |
assign(double value)
Assign the value to all elements of the receiver
|
DenseVector |
clone()
Return a copy of the recipient
|
double |
dot(Vector x)
Return the dot product of the recipient and the argument
|
protected double |
dotSelf() |
boolean |
equals(Object o)
Determines whether this
Vector represents the same logical vector as another
object. |
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()
Return true iff adding a new (nonzero) element takes constant time for this vector.
|
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
AbstractVector.getElement(int) for the given index |
DenseVector |
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)
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
|
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, createOptimizedCopy, cross, divide, 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, toString, zSumpublic DenseVector()
public DenseVector(double[] values)
values - - array of valuespublic DenseVector(double[] values,
boolean shallowCopy)
public DenseVector(DenseVector values, boolean shallowCopy)
public DenseVector(int cardinality)
cardinality - - number of values in the vectorpublic DenseVector(Vector vector)
vector - The vector to copypublic double dot(Vector x)
Vectordot in interface Vectordot in class AbstractVectorx - a Vectorprotected Matrix matrixLike(int rows, int columns)
AbstractVectormatrixLike in class AbstractVectorrows - the row cardinalitycolumns - the column cardinalitypublic DenseVector clone()
Vectorclone in interface Vectorclone in class AbstractVectorpublic boolean isDense()
public boolean isSequentialAccess()
protected double dotSelf()
dotSelf in class AbstractVectorpublic double getQuick(int index)
Vectorindex - an int indexpublic DenseVector like()
Vectorpublic Vector like(int cardinality)
Vectorpublic void setQuick(int index,
double value)
Vectorindex - an int index into the receivervalue - a double value to setpublic void incrementQuick(int index,
double increment)
VectorincrementQuick in interface VectorincrementQuick in class AbstractVectorindex - an int index into the receiverincrement - sets the value at the given index to value + increment;public Vector assign(double value)
Vectorassign in interface Vectorassign in class AbstractVectorvalue - a double valuepublic int getNumNondefaultElements()
Vectorpublic int getNumNonZeroElements()
VectorgetNumNonZeroElements in interface VectorgetNumNonZeroElements in class AbstractVectorpublic Vector assign(DenseVector vector)
public void mergeUpdates(OrderedIntDoubleMapping updates)
Vectorupdates - an ordered mapping of indices to values to be merged in.public Vector viewPart(int offset, int length)
VectorviewPart in interface VectorviewPart in class AbstractVectoroffset - an int offset into the receiverlength - the cardinality of the desired resultpublic double getLookupCost()
Vectorpublic double getIteratorAdvanceCost()
Vectorpublic boolean isAddConstantTime()
Vectorpublic Iterator<Vector.Element> iterateNonZero()
iterateNonZero in class AbstractVectorIterator over all non-zero elementspublic Iterator<Vector.Element> iterator()
AbstractVectorAbstractVector.getElement(int) for the given indexiterator in class AbstractVectorIterator over all elementspublic boolean equals(Object o)
AbstractVectorVector represents the same logical vector as another
object. Two Vectors are equal (regardless of implementation) if the value at
each index is the same, and the cardinalities are the same.equals in class AbstractVectorpublic void addAll(Vector v)
Copyright © 2008–2015 The Apache Software Foundation. All rights reserved.