gov.sandia.cognition.math.matrix

## Interface VectorSpace<VectorType extends VectorSpace<VectorType,?>,EntryType extends VectorSpace.Entry>

• ### Nested Class Summary

Nested Classes
Modifier and Type Interface and Description
static interface  VectorSpace.Entry
Entry into the VectorSpace
• ### Method Summary

All Methods
Modifier and Type Method and Description
double angle(VectorType other)
Computes the angle between two Vectors.
double cosine(VectorType other)
Computes the cosine between two Vectors
double dot(VectorType other)
The inner product of this vector with the given vector.
double dotProduct(VectorType other)
The inner product of this vector with the given vector.
double euclideanDistance(VectorType other)
Euclidean distance between this and other, which is the 2-norm between the difference of the Vectors
double euclideanDistanceSquared(VectorType other)
Squared Euclidean distance between this and other, which is the 2-norm between the difference of the Vectors
double getMaxValue()
The maximum value associated with any key in the vector.
double getMinValue()
The minimum value associated with any key in the vector.
boolean isUnitVector()
Determines if this vector is a unit vector (norm2 = 1.0).
boolean isUnitVector(double tolerance)
Determines if this vector is a unit vector within some tolerance for the 2-norm.
double norm(double power)
Returns the p-norm of the Vector with the given power.
double norm1()
1-norm of the vector (sum of absolute values in the vector)
double norm2()
2-norm of the vector (aka Euclidean distance of the vector)
double norm2Squared()
Squared 2-norm of the vector (aka squared Euclidean distance of the vector)
double normInfinity()
Returns the infinity norm of the Vector, which is the maximum absolute value of an element in the Vector.
double sum()
Computes the sum of the elements in the vector.
VectorType unitVector()
Returns the unit vector of this vector.
void unitVectorEquals()
Modifies this vector to be a the unit vector.
• ### Methods inherited from interface gov.sandia.cognition.math.Ring

clone, dotTimes, dotTimesEquals, equals, equals, isZero, isZero, minus, minusEquals, negative, negativeEquals, plus, plusEquals, scale, scaledMinus, scaledMinusEquals, scaledPlus, scaledPlusEquals, scaleEquals, zero
• ### Methods inherited from interface java.lang.Iterable

forEach, iterator, spliterator
• ### Method Detail

• #### sum

double sum()
Computes the sum of the elements in the vector.
Returns:
The sum of the elements in the vector.
Since:
3.0
• #### getMaxValue

double getMaxValue()
The maximum value associated with any key in the vector.
Returns:
The maximum value associated with any key in the vector. If the vector is empty, then Double.NEGATIVE_INFINITY is returned.
• #### getMinValue

double getMinValue()
The minimum value associated with any key in the vector.
Returns:
The minimum value associated with any key in the vector. If the vector is empty, then Double.POSITIVE_INFINITY is returned.
• #### norm1

double norm1()
1-norm of the vector (sum of absolute values in the vector)
Returns:
1-norm of the vector, [0,\infty)
• #### norm2

double norm2()
2-norm of the vector (aka Euclidean distance of the vector)
Returns:
2-norm of the vector, [0,\infty)
• #### norm2Squared

double norm2Squared()
Squared 2-norm of the vector (aka squared Euclidean distance of the vector)
Returns:
Squared 2-norm of the vector, [0,\infty)
• #### normInfinity

double normInfinity()
Returns the infinity norm of the Vector, which is the maximum absolute value of an element in the Vector.
Returns:
Maximum absolute value of any element in the Vector.
• #### norm

@PublicationReference(author="Wikipedia",
title="Vector norm, p-norm",
type=WebPage,
year=2011,
url="http://en.wikipedia.org/wiki/Vector_norm#p-norm")
double norm(double power)
Returns the p-norm of the Vector with the given power.
Parameters:
power - Power to exponentiate each entry, must be greater than 0.0, Double.POSITIVE_INFINITY
Returns:
p-norm with the given power.
• #### dot

double dot(VectorType other)
The inner product of this vector with the given vector. That is, the sum of each element of this vector times the corresponding element in the other vector. The same as dotProduct.
Parameters:
other - The Vector with which to compute the dot product with this. Must have the same dimensionality as this.
Returns:
The dot product. The value is between 0 and Infinity.
• #### dotProduct

double dotProduct(VectorType other)
The inner product of this vector with the given vector. That is, the sum of each element of this vector times the corresponding element in the other vector. The same as dot.
Parameters:
other - The Vector with which to compute the dot product with this. Must have the same dimensionality as this.
Returns:
The dot product. The value is between 0 and Infinity.
• #### angle

double angle(VectorType other)
Computes the angle between two Vectors.
Parameters:
other - Another vector with which to compute the angle. Must be the same dimensionality.
Returns:
The angle between the two vectors in [0, PI].
• #### cosine

double cosine(VectorType other)
Computes the cosine between two Vectors
Parameters:
other - another vector with which to compute the cosine, must be the same dimension as this
Returns:
cosine between the vectors, [0,1]
• #### euclideanDistance

double euclideanDistance(VectorType other)
Euclidean distance between this and other, which is the 2-norm between the difference of the Vectors
Parameters:
other - Vector to which to compute the distance, must be the same dimension as this
Returns:
this.minus( other ).norm2(), which is [0,\infty)
• #### euclideanDistanceSquared

double euclideanDistanceSquared(VectorType other)
Squared Euclidean distance between this and other, which is the 2-norm between the difference of the Vectors
Parameters:
other - Vector to which to compute the squared distance, must be the same dimension as this
Returns:
this.minus( other ).norm2Squared(), which is [0,\infty)
• #### unitVector

VectorType unitVector()
Returns the unit vector of this vector. That is, a vector in the same "direction" where the length (norm2) is 1.0. This is computed by dividing each element buy the length (norm2). If this vector is all zeros, then the vector returned will be all zeros.
Returns:
The unit vector of this vector.
• #### unitVectorEquals

void unitVectorEquals()
Modifies this vector to be a the unit vector. That is, a vector in the same "direction" where the length (norm2) is 1.0. This is computed by dividing each element buy the length (norm2). If this vector is all zeros, then this vector will all zeros.
• #### isUnitVector

boolean isUnitVector()
Determines if this vector is a unit vector (norm2 = 1.0).
Returns:
True if this vector is a unit vector; otherwise, false.
• #### isUnitVector

boolean isUnitVector(double tolerance)
Determines if this vector is a unit vector within some tolerance for the 2-norm.
Parameters:
tolerance - The tolerance around 1.0 to allow the length.
Returns:
True if this is a unit vector within the given tolerance; otherwise, false.