gov.sandia.cognition.math.matrix
Interface VectorSpace<VectorType extends VectorSpace<VectorType,?>,EntryType extends VectorSpace.Entry>

Type Parameters:
VectorType - Type of VectorSpace
EntryType - Type of entry for the iteration
All Superinterfaces:
Cloneable, CloneableSerializable, Iterable<EntryType>, Ring<VectorType>, Serializable
All Known Subinterfaces:
InfiniteVector<KeyType>, Vector, Vector1D, Vector2D, Vector3D
All Known Implementing Classes:
AbstractMTJVector, AbstractVector, AbstractVectorSpace, DefaultInfiniteVector, DenseVector, SparseVector, Vector1, Vector2, Vector3

@PublicationReference(author="Wikipedia",
                      title="Vector space",
                      type=WebPage,
                      year=2011,
                      url="http://en.wikipedia.org/wiki/Vector_space")
public interface VectorSpace<VectorType extends VectorSpace<VectorType,?>,EntryType extends VectorSpace.Entry>
extends Ring<VectorType>, Iterable<EntryType>

In the Foundry, a VectorSpace is a type of Ring that we can perform Vector-like operations on: norm, distances between Vectors, etc.

Since:
3.3.1
Author:
Kevin R. Dixon

Nested Class Summary
static interface VectorSpace.Entry
          Entry into the VectorSpace
 
Method Summary
 double angle(VectorType other)
          Computes the angle between two Vectors.
 double cosine(VectorType other)
          Computes the cosine between two Vectors
 double dotProduct(VectorType other)
          Inner Vector product between two Vectors
 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
 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
iterator
 

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

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.

dotProduct

double dotProduct(VectorType other)
Inner Vector product between two Vectors

Parameters:
other - the Vector with which to compute the dot product with this, must be the same dimension as this
Returns:
dot product, (0,\infty)

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.