## gov.sandia.cognition.math.matrix.mtj Class AbstractMTJVector

java.lang.Object
gov.sandia.cognition.util.AbstractCloneableSerializable
gov.sandia.cognition.math.AbstractRing<VectorType>
gov.sandia.cognition.math.matrix.AbstractVectorSpace<Vector,VectorEntry>
gov.sandia.cognition.math.matrix.AbstractVector
gov.sandia.cognition.math.matrix.mtj.AbstractMTJVector

All Implemented Interfaces:
Vector, Vectorizable, VectorSpace<Vector,VectorEntry>, Ring<Vector>, CloneableSerializable, Serializable, Cloneable, Iterable<VectorEntry>
Direct Known Subclasses:
DenseVector, SparseVector

@CodeReview(reviewer="Jonathan McClain",
date="2006-05-19",
changesNeeded=false,
comments="Comments marked throughout the file with / / / on first column.")
@PublicationReference(author="Bjorn-Ove Heimsund",
title="Matrix Toolkits for Java (MTJ)",
type=WebPage,
year=2006,
url="http://ressim.berlios.de/",
notes="All subclasses essentially wrap one of MTJ\'s vector classes.")
@SoftwareReference(name="Matrix Toolkits for Java (MTJ)",
version="0.9.6",
url="http://ressim.berlios.de/",
public abstract class AbstractMTJVectorextends AbstractVectorimplements Serializable

Implementation of the Vector interface that relies on MTJ Vectors, but does not specify sparse or dense storage.

Since:
1.0
Author:
Kevin R. Dixon
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  AbstractMTJVector(no.uib.cipr.matrix.Vector internalVector)
Creates a new instance of AbstractMTJVector

Method Summary
 AbstractMTJVector clone()
This makes public the clone method on the Object class and removes the exception that it throws.
 double dotProduct(AbstractMTJVector other)
Inner Vector product between two Vectors
 double dotProduct(Vector other)
Inner Vector product between two Vectors
 void dotTimesEquals(Vector other)
Inline element-wise multiplication of this and other
 int getDimensionality()
Returns the number of elements in the Vector
 double getElement(int index)
Gets the zero-based indexed element from the Vector
protected  no.uib.cipr.matrix.Vector getInternalVector()
Getter for internalVector
 Iterator<VectorEntry> iterator()

 void minusEquals(AbstractMTJVector other)
Inline subtraction of the elements of other from the elements of this
 void minusEquals(Vector other)
Inline arithmetic subtraction of other from this
 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)
abstract  AbstractMTJMatrix outerProduct(AbstractMTJVector other)
Computes the outer matrix product between the two vectors
 AbstractMTJMatrix outerProduct(Vector other)
Computes the outer matrix product between the two vectors
 void plusEquals(AbstractMTJVector other)
Inline addition of this and the other vector
 void plusEquals(Vector other)
Inline arithmetic addition of this and other
 void scaledMinusEquals(double scaleFactor, AbstractMTJVector other)
Subtracts from this vector the scaled version of the other given vector.
 void scaledPlusEquals(double scaleFactor, AbstractMTJVector other)
Adds to this vector the scaled version of the other given vector.
 void scaledPlusEquals(double scaleFactor, Vector other)
Inline arithmetic addition of this and other after element-wise scaling of other by scaleFactor.
 void scaleEquals(double scaleFactor)
Inline element-wise scaling of this by scaleFactor
 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.Vector internalVector)
Setter for internalVector
 Vector times(AbstractMTJMatrix matrix)
Premultiplies the matrix by the vector "this"
 Vector times(Matrix matrix)
Premultiplies the matrix by the vector "this"
 void zero()
Zeros out all elements of this, so that the following are equivalent r1.scaleEquals( 0.0 ); and r1.zero(); Furthermore, r1.zero(); anything.dotTimes( r1 ).equals( r1 );

Methods inherited from class gov.sandia.cognition.math.matrix.AbstractVector
assertDimensionalityEquals, assertEqualDimensionality, assertSameDimensionality, checkSameDimensionality, convertFromVector, convertToVector, dotDivide, dotDivideEquals, equals, 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.Vector
isSparse, stack, subVector

Methods inherited from interface gov.sandia.cognition.math.matrix.VectorSpace
angle, cosine, euclideanDistance, euclideanDistanceSquared, 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

### AbstractMTJVector

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

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

### clone

public AbstractMTJVector clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface Vector
Specified by:
clone in interface Vectorizable
Specified by:
clone in interface Ring<Vector>
Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractRing<Vector>
Returns:
A clone of this object.

### getDimensionality

public int getDimensionality()
Description copied from interface: Vector
Returns the number of elements in the Vector

Specified by:
getDimensionality in interface Vector
Returns:
number of elements in the Vector

### getElement

public double getElement(int index)
Description copied from interface: Vector
Gets the zero-based indexed element from the Vector

Specified by:
getElement in interface Vector
Parameters:
index - zero-based index
Returns:
zero-based indexed element in the Vector

### setElement

public void setElement(int index,
double value)
Description copied from interface: Vector
Sets the zero-based indexed element in the Vector from the specified value

Specified by:
setElement in interface Vector
Parameters:
index - zero-based index
value - value to set the element in the Vector

### times

public Vector times(Matrix matrix)
Description copied from interface: Vector
Premultiplies the matrix by the vector "this"

Specified by:
times in interface Vector
Parameters:
matrix - Matrix to premultiply by "this", must have the same number of rows as the dimensionality of "this"
Returns:
Vector of dimension equal to the number of columns of "matrix"

### times

public Vector times(AbstractMTJMatrix matrix)
Premultiplies the matrix by the vector "this"

Parameters:
matrix - Matrix to premultiply by "this", must have the same number of rows as the dimensionality of "this"
Returns:
Vector of dimension equal to the number of columns of "matrix"

### getInternalVector

protected no.uib.cipr.matrix.Vector getInternalVector()
Getter for internalVector

Returns:
MTJ-based internal vector that does the heavy lifting

### setInternalVector

protected void setInternalVector(no.uib.cipr.matrix.Vector internalVector)
Setter for internalVector

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

### norm2

public double norm2()
Description copied from interface: VectorSpace
2-norm of the vector (aka Euclidean distance of the vector)

Specified by:
norm2 in interface VectorSpace<Vector,VectorEntry>
Overrides:
norm2 in class AbstractVectorSpace<Vector,VectorEntry>
Returns:
2-norm of the vector, [0,\infty)

### norm2Squared

public double norm2Squared()
Description copied from interface: VectorSpace
Squared 2-norm of the vector (aka squared Euclidean distance of the vector)

Specified by:
norm2Squared in interface VectorSpace<Vector,VectorEntry>
Overrides:
norm2Squared in class AbstractVectorSpace<Vector,VectorEntry>
Returns:
Squared 2-norm of the vector, [0,\infty)

### plusEquals

public void plusEquals(Vector other)
Description copied from interface: Ring
Inline arithmetic addition of this and other

Specified by:
plusEquals in interface Ring<Vector>
Parameters:
other - object to add to this

### plusEquals

public void plusEquals(AbstractMTJVector other)
Inline addition of this and the other vector

Parameters:
other - Vector to which to add the elements of this, must be the same dimension as this

### minusEquals

public void minusEquals(Vector other)
Description copied from interface: Ring
Inline arithmetic subtraction of other from this

Specified by:
minusEquals in interface Ring<Vector>
Parameters:
other - object to subtract from this

### minusEquals

public void minusEquals(AbstractMTJVector other)
Inline subtraction of the elements of other from the elements of this

Parameters:
other - Vector from which to subtract the elements of this, must be the same dimension as this

### dotProduct

public double dotProduct(Vector other)
Description copied from interface: VectorSpace
Inner Vector product between two Vectors

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

### dotProduct

public double dotProduct(AbstractMTJVector 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)

### dotTimesEquals

public void dotTimesEquals(Vector other)
Description copied from interface: Ring
Inline element-wise multiplication of this and other

Specified by:
dotTimesEquals in interface Ring<Vector>
Parameters:
other - elements of other will be multiplied to the corresponding elements of this

### scaleEquals

public void scaleEquals(double scaleFactor)
Description copied from interface: Ring
Inline element-wise scaling of this by scaleFactor

Specified by:
scaleEquals in interface Ring<Vector>
Overrides:
scaleEquals in class AbstractVectorSpace<Vector,VectorEntry>
Parameters:
scaleFactor - amount to scale the elements of this

### scaledPlusEquals

public void scaledPlusEquals(double scaleFactor,
Vector other)
Description copied from interface: Ring
Inline arithmetic addition of this and other after element-wise scaling of other by scaleFactor. If this is x, other is y, and scaleFactor is a, then this method is equivalent to x += a * y. It is typically a more efficient way of doing this.plusEquals(other.scale(scaleFactor)) since it can avoid intermediate object creation.

Specified by:
scaledPlusEquals in interface Ring<Vector>
Parameters:
scaleFactor - The scale factor to multiply by the elements of other before adding to the elements of this.
other - Object to scale and then add to this.

### scaledPlusEquals

public void scaledPlusEquals(double scaleFactor,
AbstractMTJVector other)
Adds to this vector the scaled version of the other given vector.

Parameters:
scaleFactor - The scale factor to use.
other - The other vector to scale and then add to this vector.

### scaledMinusEquals

public void scaledMinusEquals(double scaleFactor,
AbstractMTJVector other)
Subtracts from this vector the scaled version of the other given vector.

Parameters:
scaleFactor - The scale factor to use.
other - The other vector to scale and then subtract from this vector.

### iterator

public Iterator<VectorEntry> iterator()
Specified by:
iterator in interface Iterable<VectorEntry>

### zero

public void zero()
Description copied from interface: Ring
Zeros out all elements of this, so that the following are equivalent r1.scaleEquals( 0.0 ); and r1.zero(); Furthermore, r1.zero(); anything.dotTimes( r1 ).equals( r1 );

Specified by:
zero in interface Ring<Vector>
Overrides:
zero in class AbstractRing<Vector>

### outerProduct

public AbstractMTJMatrix outerProduct(Vector other)
Description copied from interface: Vector
Computes the outer matrix product between the two vectors

Specified by:
outerProduct in interface Vector
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

### outerProduct

public abstract AbstractMTJMatrix outerProduct(AbstractMTJVector other)
Computes the outer matrix product between the two vectors

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