@CodeReview(reviewer="Jonathan McClain", date="2006-05-19", changesNeeded=true, comments="Comments marked with / / /", response=@CodeReviewResponse(respondent="Kevin R. Dixon",date="2006-05-22",moreChangesNeeded=false,comments="Fixed comments for writeObject() and readObject()")) @PublicationReference(author="Bjorn-Ove Heimsund", title="MTJ DenseVector javadoc", type=WebPage, year=2006, url="http://ressim.berlios.de/doc/no/uib/cipr/matrix/DenseVector.html") public class DenseVector extends AbstractMTJVector implements java.io.Serializable
Vector.IndexValueConsumer, Vector.IndexValueTransform
VectorSpace.Entry
DEFAULT_DELIMITER
Modifier | Constructor and Description |
---|---|
protected |
DenseVector(AbstractMTJVector vector)
Copy constructor
|
protected |
DenseVector(DenseVector vector)
Creates a new instance of DenseVector
|
protected |
DenseVector(no.uib.cipr.matrix.DenseVector internalVector)
Creates a new instance of DenseVector
|
protected |
DenseVector(double... values)
Creates a new instance of DenseVector
|
protected |
DenseVector(int numDimensions)
Creates a new instance of DenseVector
|
protected |
DenseVector(Vector vector)
Copy constructor for DenseVector
|
protected |
DenseVector(VectorReader reader)
Creates a new instance of DenseVector
|
Modifier and Type | Method and Description |
---|---|
int |
countNonZeros()
Counts the number of non-zero entries in the vector.
|
boolean |
equals(Vector other,
double effectiveZero)
Determines if two RingType objects are effectively equal
|
double |
euclideanDistanceSquared(Vector other)
Squared Euclidean distance between
this and
other , which is the 2-norm between the difference of the
Vectors |
void |
forEachElement(Vector.IndexValueConsumer consumer)
Applies the given function to each element in this vector.
|
void |
forEachEntry(Vector.IndexValueConsumer consumer)
Applies the given function to each active entry in this vector.
|
void |
forEachNonZero(Vector.IndexValueConsumer consumer)
Applies the given function to each non-zero entry in this vector.
|
double |
get(int index)
Gets the value of element of the vector at the zero-based index.
|
double[] |
getArray()
Returns the underlying double array for this DenseVector
|
int |
getDimensionality()
Returns the number of elements in the Vector
|
double |
getElement(int index)
Gets the zero-based indexed element from the Vector
|
int |
getEntryCount()
Gets the number of active entries in the vector.
|
double |
getMaxValue()
The maximum value associated with any key in the vector.
|
double |
getMinValue()
The minimum value associated with any key in the vector.
|
VectorFactory<?> |
getVectorFactory()
Gets a vector factory associated with this kind of vector.
|
boolean |
isSparse()
Returns true if this vector has a potentially sparse underlying
structure.
|
DenseMatrix |
outerProduct(AbstractMTJVector other)
Computes the outer matrix product between the two vectors
|
void |
set(int index,
double value)
Sets the value for an element at the zero-based index from the vector.
|
void |
setElement(int index,
double value)
Sets the zero-based indexed element in the Vector from the specified value
|
protected void |
setInternalVector(no.uib.cipr.matrix.DenseVector internalVector)
Sets the internalVector using MTJ's DenseVector
|
protected void |
setInternalVector(no.uib.cipr.matrix.Vector internalVector)
Setter for internalVector
|
DenseVector |
stack(Vector other)
Stacks "other" below "this" and returns the stacked Vector
|
DenseVector |
subVector(int minIndex,
int maxIndex)
Gets a subvector of "this", specified by the inclusive indices
|
double |
sum()
Computes the sum of the elements in the vector.
|
void |
transformEquals(UnivariateScalarFunction function)
Applies the given function to each of the elements of this vector and
sets them to the result.
|
void |
transformEquals(Vector.IndexValueTransform function)
Applies the given function to each of the elements of this vector and
sets them to the result.
|
void |
transformNonZerosEquals(UnivariateScalarFunction function)
Applies the given function to each of the non-zero elements of this
vector and sets them to the result.
|
void |
transformNonZerosEquals(Vector.IndexValueTransform function)
Applies the given function to each of the non-zero elements of this
vector and sets them to the result.
|
clone, dotProduct, dotProduct, dotTimesEquals, getInternalVector, increment, iterator, minusEquals, minusEquals, norm2, norm2Squared, outerProduct, plusEquals, plusEquals, scaledMinusEquals, scaledPlusEquals, scaledPlusEquals, scaleEquals, times, times, zero
assertDimensionalityEquals, assertEqualDimensionality, assertSameDimensionality, checkSameDimensionality, convertFromVector, convertToVector, decrement, decrement, dotDivide, dotDivideEquals, equals, hashCode, increment, toArray, toString, toString, toString, transform, transform, transformNonZeros, transformNonZeros, valuesAsList
angle, cosine, dot, euclideanDistance, isUnitVector, isUnitVector, isZero, norm, norm1, normInfinity, unitVector, unitVectorEquals
dotTimes, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlus
finalize, getClass, notify, notifyAll, wait, wait, wait
angle, cosine, dot, euclideanDistance, isUnitVector, isUnitVector, norm, norm1, normInfinity, unitVector, unitVectorEquals
dotTimes, isZero, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlus
protected DenseVector(int numDimensions)
numDimensions
- Number of dimensions in the Vectorprotected DenseVector(DenseVector vector)
vector
- Vector from which to populate the elements of this, will not be modifiedprotected DenseVector(Vector vector)
vector
- Vector from which to populate the elements of this, will not be modifiedprotected DenseVector(AbstractMTJVector vector)
vector
- Vector to copyprotected DenseVector(double... values)
values
- The array of values to give the vectorprotected DenseVector(no.uib.cipr.matrix.DenseVector internalVector)
internalVector
- Internal MTJ-based vector that does the heavy liftingprotected DenseVector(VectorReader reader) throws java.io.IOException
reader
- takes in information from a java streamjava.io.IOException
- if the stream is invalidprotected void setInternalVector(no.uib.cipr.matrix.Vector internalVector)
AbstractMTJVector
setInternalVector
in class AbstractMTJVector
internalVector
- internal MTJ-based vector that does the heavy liftingprotected void setInternalVector(no.uib.cipr.matrix.DenseVector internalVector)
internalVector
- internal MTJ-based DenseVectorpublic double getElement(int index)
Vector
getElement
in interface Vector
getElement
in class AbstractMTJVector
index
- zero-based indexpublic void setElement(int index, double value)
Vector
setElement
in interface Vector
setElement
in class AbstractMTJVector
index
- zero-based indexvalue
- value to set the element in the Vectorpublic double get(int index)
Vector
getElement
.get
in interface Vector
get
in class AbstractMTJVector
index
- The zero-based index. Must be between 0 (inclusive) and the
dimensionality of the vector (exclusive).public void set(int index, double value)
Vector
setElement
.set
in interface Vector
set
in class AbstractMTJVector
index
- The zero-based index. Must be between 0 (inclusive) and the
dimensionality of the vector (exclusive).value
- The value at the index in the vector.public int getDimensionality()
Vector
getDimensionality
in interface Vector
getDimensionality
in class AbstractMTJVector
public boolean equals(Vector other, double effectiveZero)
Ring
equals
in interface Ring<Vector>
equals
in class AbstractVector
other
- RingType to compare against this
effectiveZero
- tolerance threshold for element-wise equalitypublic double euclideanDistanceSquared(Vector other)
VectorSpace
this
and
other
, which is the 2-norm between the difference of the
VectorseuclideanDistanceSquared
in interface VectorSpace<Vector,VectorEntry>
euclideanDistanceSquared
in class AbstractVector
other
- Vector to which to compute the squared distance, must be the
same dimension as thispublic DenseMatrix outerProduct(AbstractMTJVector other)
AbstractMTJVector
outerProduct
in class AbstractMTJVector
other
- post-multiplied Vector with which to compute the outer productpublic DenseVector stack(Vector other)
Vector
stack
in interface Vector
stack
in class AbstractVector
other
- Vector to stack below "this"public DenseVector subVector(int minIndex, int maxIndex)
public void transformEquals(UnivariateScalarFunction function)
Vector
transformEquals
in interface Vector
transformEquals
in class AbstractVector
function
- The function from double to double to apply.public void transformEquals(Vector.IndexValueTransform function)
Vector
transformEquals
in interface Vector
transformEquals
in class AbstractVector
function
- The function from index and value to double to apply.public void transformNonZerosEquals(UnivariateScalarFunction function)
Vector
transformNonZerosEquals
in interface Vector
transformNonZerosEquals
in class AbstractVector
function
- The function from double to double to apply to the non-zero
elements.public void transformNonZerosEquals(Vector.IndexValueTransform function)
Vector
transformNonZerosEquals
in interface Vector
transformNonZerosEquals
in class AbstractVector
function
- The function from index and value to double to apply to non-zero
elements.public void forEachElement(Vector.IndexValueConsumer consumer)
Vector
forEachElement
in interface Vector
forEachElement
in class AbstractVector
consumer
- The consumer for the entries. It is called for each element in
the vector, in order by increasing index.public void forEachEntry(Vector.IndexValueConsumer consumer)
Vector
forEachEntry
in interface Vector
forEachEntry
in class AbstractVector
consumer
- The consumer for the entries. It is called for each active entry in
the vector, in order by increasing index.public void forEachNonZero(Vector.IndexValueConsumer consumer)
Vector
forEachNonZero
in interface Vector
forEachNonZero
in class AbstractVector
consumer
- The consumer for the non-zero entries. It is called for each
non-zero entry in the vector, in order by increasing index.public double sum()
VectorSpace
sum
in interface VectorSpace<Vector,VectorEntry>
sum
in class AbstractVectorSpace<Vector,VectorEntry>
public double getMinValue()
VectorSpace
getMinValue
in interface VectorSpace<Vector,VectorEntry>
public double getMaxValue()
VectorSpace
getMaxValue
in interface VectorSpace<Vector,VectorEntry>
public double[] getArray()
public boolean isSparse()
Vector
public VectorFactory<?> getVectorFactory()
Vector
getVectorFactory
in interface Vector
public int getEntryCount()
Vector
getEntryCount
in interface Vector
public int countNonZeros()
Vector
countNonZeros
in interface Vector