@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.IndexValueTransformVectorSpace.EntryDEFAULT_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, zeroassertDimensionalityEquals, assertEqualDimensionality, assertSameDimensionality, checkSameDimensionality, convertFromVector, convertToVector, decrement, decrement, dotDivide, dotDivideEquals, equals, hashCode, increment, toArray, toString, toString, toString, transform, transform, transformNonZeros, transformNonZeros, valuesAsListangle, cosine, dot, euclideanDistance, isUnitVector, isUnitVector, isZero, norm, norm1, normInfinity, unitVector, unitVectorEqualsdotTimes, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlusfinalize, getClass, notify, notifyAll, wait, wait, waitangle, cosine, dot, euclideanDistance, isUnitVector, isUnitVector, norm, norm1, normInfinity, unitVector, unitVectorEqualsdotTimes, isZero, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlusprotected 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)
AbstractMTJVectorsetInternalVector in class AbstractMTJVectorinternalVector - 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)
VectorgetElement in interface VectorgetElement in class AbstractMTJVectorindex - zero-based indexpublic void setElement(int index,
double value)
VectorsetElement in interface VectorsetElement in class AbstractMTJVectorindex - zero-based indexvalue - value to set the element in the Vectorpublic double get(int index)
VectorgetElement.get in interface Vectorget in class AbstractMTJVectorindex - The zero-based index. Must be between 0 (inclusive) and the
dimensionality of the vector (exclusive).public void set(int index,
double value)
VectorsetElement.set in interface Vectorset in class AbstractMTJVectorindex - 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()
VectorgetDimensionality in interface VectorgetDimensionality in class AbstractMTJVectorpublic boolean equals(Vector other, double effectiveZero)
Ringequals in interface Ring<Vector>equals in class AbstractVectorother - RingType to compare against thiseffectiveZero - tolerance threshold for element-wise equalitypublic double euclideanDistanceSquared(Vector other)
VectorSpacethis and
other, which is the 2-norm between the difference of the
VectorseuclideanDistanceSquared in interface VectorSpace<Vector,VectorEntry>euclideanDistanceSquared in class AbstractVectorother - Vector to which to compute the squared distance, must be the
same dimension as thispublic DenseMatrix outerProduct(AbstractMTJVector other)
AbstractMTJVectorouterProduct in class AbstractMTJVectorother - post-multiplied Vector with which to compute the outer productpublic DenseVector stack(Vector other)
Vectorstack in interface Vectorstack in class AbstractVectorother - Vector to stack below "this"public DenseVector subVector(int minIndex, int maxIndex)
public void transformEquals(UnivariateScalarFunction function)
VectortransformEquals in interface VectortransformEquals in class AbstractVectorfunction - The function from double to double to apply.public void transformEquals(Vector.IndexValueTransform function)
VectortransformEquals in interface VectortransformEquals in class AbstractVectorfunction - The function from index and value to double to apply.public void transformNonZerosEquals(UnivariateScalarFunction function)
VectortransformNonZerosEquals in interface VectortransformNonZerosEquals in class AbstractVectorfunction - The function from double to double to apply to the non-zero
elements.public void transformNonZerosEquals(Vector.IndexValueTransform function)
VectortransformNonZerosEquals in interface VectortransformNonZerosEquals in class AbstractVectorfunction - The function from index and value to double to apply to non-zero
elements.public void forEachElement(Vector.IndexValueConsumer consumer)
VectorforEachElement in interface VectorforEachElement in class AbstractVectorconsumer - 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)
VectorforEachEntry in interface VectorforEachEntry in class AbstractVectorconsumer - 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)
VectorforEachNonZero in interface VectorforEachNonZero in class AbstractVectorconsumer - 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()
VectorSpacesum in interface VectorSpace<Vector,VectorEntry>sum in class AbstractVectorSpace<Vector,VectorEntry>public double getMinValue()
VectorSpacegetMinValue in interface VectorSpace<Vector,VectorEntry>public double getMaxValue()
VectorSpacegetMaxValue in interface VectorSpace<Vector,VectorEntry>public double[] getArray()
public boolean isSparse()
Vectorpublic VectorFactory<?> getVectorFactory()
VectorgetVectorFactory in interface Vectorpublic int getEntryCount()
VectorgetEntryCount in interface Vectorpublic int countNonZeros()
VectorcountNonZeros in interface Vector