gov.sandia.cognition.math.matrix.mtj
Class DenseVector

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.math.AbstractRing<VectorType>
          extended by gov.sandia.cognition.math.matrix.AbstractVectorSpace<Vector,VectorEntry>
              extended by gov.sandia.cognition.math.matrix.AbstractVector
                  extended by gov.sandia.cognition.math.matrix.mtj.AbstractMTJVector
                      extended by gov.sandia.cognition.math.matrix.mtj.DenseVector
All Implemented Interfaces:
Vector, Vectorizable, VectorSpace<Vector,VectorEntry>, Ring<Vector>, CloneableSerializable, Serializable, Cloneable, Iterable<VectorEntry>
Direct Known Subclasses:
Vector1, Vector2, Vector3

@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 Serializable

A generally useful vector representation that allocates a fixed-size underlying vector, based on MTJ's DenseVector

Since:
1.0
Author:
Kevin R. Dixon
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface gov.sandia.cognition.math.matrix.VectorSpace
VectorSpace.Entry
 
Field Summary
 
Fields inherited from class gov.sandia.cognition.math.matrix.AbstractVector
DEFAULT_DELIMITER
 
Constructor Summary
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
 
Method Summary
 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
 double[] getArray()
          Returns the underlying double array for this DenseVector
 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
protected  void setInternalVector(no.uib.cipr.matrix.DenseVector internalVector)
          Sets the internalVector using MTJ's DenseVector
 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
 
Methods inherited from class gov.sandia.cognition.math.matrix.mtj.AbstractMTJVector
clone, dotProduct, dotProduct, dotTimesEquals, getDimensionality, getElement, getInternalVector, iterator, minusEquals, minusEquals, norm2, norm2Squared, outerProduct, plusEquals, plusEquals, scaledMinusEquals, scaledPlusEquals, scaledPlusEquals, scaleEquals, setElement, setInternalVector, times, times, zero
 
Methods inherited from class gov.sandia.cognition.math.matrix.AbstractVector
assertDimensionalityEquals, assertEqualDimensionality, assertSameDimensionality, checkSameDimensionality, convertFromVector, convertToVector, dotDivide, dotDivideEquals, equals, hashCode, toArray, toString, toString, toString, transform, transformEquals, transformNonZeros, transformNonZerosEquals
 
Methods inherited from class gov.sandia.cognition.math.matrix.AbstractVectorSpace
angle, cosine, euclideanDistance, isUnitVector, isUnitVector, isZero, norm, norm1, normInfinity, sum, unitVector, unitVectorEquals
 
Methods inherited from class gov.sandia.cognition.math.AbstractRing
dotTimes, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlus
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.math.matrix.VectorSpace
angle, cosine, euclideanDistance, isUnitVector, isUnitVector, norm, norm1, normInfinity, sum, unitVector, unitVectorEquals
 
Methods inherited from interface gov.sandia.cognition.math.Ring
dotTimes, isZero, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlus
 

Constructor Detail

DenseVector

protected DenseVector(int numDimensions)
Creates a new instance of DenseVector

Parameters:
numDimensions - Number of dimensions in the Vector

DenseVector

protected DenseVector(DenseVector vector)
Creates a new instance of DenseVector

Parameters:
vector - Vector from which to populate the elements of this, will not be modified

DenseVector

protected DenseVector(Vector vector)
Copy constructor for DenseVector

Parameters:
vector - Vector from which to populate the elements of this, will not be modified

DenseVector

protected DenseVector(AbstractMTJVector vector)
Copy constructor

Parameters:
vector - Vector to copy

DenseVector

protected DenseVector(double[] values)
Creates a new instance of DenseVector

Parameters:
values - The array of values to give the vector

DenseVector

protected DenseVector(no.uib.cipr.matrix.DenseVector internalVector)
Creates a new instance of DenseVector

Parameters:
internalVector - Internal MTJ-based vector that does the heavy lifting

DenseVector

protected DenseVector(VectorReader reader)
               throws IOException
Creates a new instance of DenseVector

Parameters:
reader - takes in information from a java stream
Throws:
IOException - if the stream is invalid
Method Detail

setInternalVector

protected void setInternalVector(no.uib.cipr.matrix.DenseVector internalVector)
Sets the internalVector using MTJ's DenseVector

Parameters:
internalVector - internal MTJ-based DenseVector

equals

public boolean equals(Vector other,
                      double effectiveZero)
Description copied from interface: Ring
Determines if two RingType objects are effectively equal

Specified by:
equals in interface Ring<Vector>
Overrides:
equals in class AbstractVector
Parameters:
other - RingType to compare against this
effectiveZero - tolerance threshold for element-wise equality
Returns:
True if the two objects are equal, false otherwise

euclideanDistanceSquared

public double euclideanDistanceSquared(Vector other)
Description copied from interface: VectorSpace
Squared Euclidean distance between this and other, which is the 2-norm between the difference of the Vectors

Specified by:
euclideanDistanceSquared in interface VectorSpace<Vector,VectorEntry>
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)

outerProduct

public DenseMatrix outerProduct(AbstractMTJVector other)
Description copied from class: AbstractMTJVector
Computes the outer matrix product between the two vectors

Specified by:
outerProduct in class AbstractMTJVector
Parameters:
other - post-multiplied Vector with which to compute the outer product
Returns:
Outer matrix product, which will have dimensions (this.getDimensionality x other.getDimensionality) and WILL BE singular

stack

public DenseVector stack(Vector other)
Description copied from interface: Vector
Stacks "other" below "this" and returns the stacked Vector

Specified by:
stack in interface Vector
Parameters:
other - Vector to stack below "this"
Returns:
stacked Vector

subVector

public DenseVector subVector(int minIndex,
                             int maxIndex)
Gets a subvector of "this", specified by the inclusive indices

Specified by:
subVector in interface Vector
Parameters:
minIndex - minimum index to get (inclusive)
maxIndex - maximum index to get (inclusive)
Returns:
vector of dimension (maxIndex-minIndex+1)

getArray

public double[] getArray()
Returns the underlying double array for this DenseVector

Returns:
internal double array for this DenseVector

isSparse

public boolean isSparse()
Description copied from interface: Vector
Returns true if this vector has a potentially sparse underlying structure. This can indicate that it is faster to only process the non-zero elements rather than to do dense operations on it. Of course, even with a sparse structure, there may be no zero elements or conversely even with a non-sparse (dense) structure there may be many zero elements.

Specified by:
isSparse in interface Vector
Returns:
True if the vector has a potentially sparse structure. Otherwise, false.