@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/", license=LGPL, licenseVersion="2.1", licenseURL="http://ressim.berlios.de/") public abstract class AbstractMTJVector extends AbstractVector implements java.io.Serializable
Vector.IndexValueConsumer, Vector.IndexValueTransform
VectorSpace.Entry
DEFAULT_DELIMITER
Modifier | Constructor and Description |
---|---|
protected |
AbstractMTJVector(no.uib.cipr.matrix.Vector internalVector)
Creates a new instance of AbstractMTJVector
|
Modifier and Type | Method and Description |
---|---|
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)
The inner product of this vector with the given vector.
|
void |
dotTimesEquals(Vector other)
Inline element-wise multiplication of
this and
other |
double |
get(int index)
Gets the value of element of the vector at the zero-based index.
|
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
|
void |
increment(int index,
double value)
Increments the value of the given index by the given value.
|
java.util.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
|
Matrix |
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 |
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.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 ); |
assertDimensionalityEquals, assertEqualDimensionality, assertSameDimensionality, checkSameDimensionality, convertFromVector, convertToVector, decrement, decrement, dotDivide, dotDivideEquals, equals, equals, euclideanDistanceSquared, forEachElement, forEachEntry, forEachNonZero, hashCode, increment, stack, toArray, toString, toString, toString, transform, transform, transformEquals, transformEquals, transformNonZeros, transformNonZeros, transformNonZerosEquals, transformNonZerosEquals, valuesAsList
angle, cosine, dot, euclideanDistance, isUnitVector, isUnitVector, isZero, norm, norm1, normInfinity, sum, unitVector, unitVectorEquals
dotTimes, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlus
finalize, getClass, notify, notifyAll, wait, wait, wait
countNonZeros, getEntryCount, getVectorFactory, isSparse, subVector
angle, cosine, dot, euclideanDistance, getMaxValue, getMinValue, isUnitVector, isUnitVector, norm, norm1, normInfinity, sum, unitVector, unitVectorEquals
dotTimes, isZero, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlus
protected AbstractMTJVector(no.uib.cipr.matrix.Vector internalVector)
internalVector
- Internal MTJ-based vector that does the heavy liftingpublic AbstractMTJVector clone()
AbstractCloneableSerializable
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.clone
in interface Vector
clone
in interface Vectorizable
clone
in interface Ring<Vector>
clone
in interface CloneableSerializable
clone
in class AbstractRing<Vector>
public int getDimensionality()
Vector
getDimensionality
in interface Vector
public double get(int index)
Vector
getElement
.public void set(int index, double value)
Vector
setElement
.public double getElement(int index)
Vector
getElement
in interface Vector
index
- zero-based indexpublic void setElement(int index, double value)
Vector
setElement
in interface Vector
index
- zero-based indexvalue
- value to set the element in the Vectorpublic void increment(int index, double value)
Vector
increment
in interface Vector
increment
in class AbstractVector
index
- The index of the dimension to increment.value
- The value to add.public Vector times(Matrix matrix)
Vector
times
in interface Vector
times
in class AbstractVector
matrix
- Matrix to premultiply by "this", must have the same number of rows as
the dimensionality of "this"public Vector times(AbstractMTJMatrix matrix)
matrix
- Matrix to premultiply by "this", must have the same number of rows as
the dimensionality of "this"protected no.uib.cipr.matrix.Vector getInternalVector()
protected void setInternalVector(no.uib.cipr.matrix.Vector internalVector)
internalVector
- internal MTJ-based vector that does the heavy liftingpublic double norm2()
VectorSpace
norm2
in interface VectorSpace<Vector,VectorEntry>
norm2
in class AbstractVectorSpace<Vector,VectorEntry>
public double norm2Squared()
VectorSpace
norm2Squared
in interface VectorSpace<Vector,VectorEntry>
norm2Squared
in class AbstractVectorSpace<Vector,VectorEntry>
public void plusEquals(Vector other)
Ring
this
and other
plusEquals
in interface Ring<Vector>
plusEquals
in class AbstractVector
other
- object to add to this
public void plusEquals(AbstractMTJVector other)
other
- Vector to which to add the elements of this, must be the
same dimension as thispublic void minusEquals(Vector other)
Ring
other
from
this
minusEquals
in interface Ring<Vector>
minusEquals
in class AbstractVector
other
- object to subtract from this
public void minusEquals(AbstractMTJVector other)
other
- Vector from which to subtract the elements of this, must be the
same dimension as thispublic double dotProduct(Vector other)
VectorSpace
dotProduct
in interface VectorSpace<Vector,VectorEntry>
dotProduct
in class AbstractVector
other
- The Vector with which to compute the dot product with this.
Must have the same dimensionality as this.public double dotProduct(AbstractMTJVector other)
other
- the Vector with which to compute the dot product with this,
must be the same dimension as thispublic void dotTimesEquals(Vector other)
Ring
this
and
other
dotTimesEquals
in interface Ring<Vector>
dotTimesEquals
in class AbstractVector
other
- elements of other will be multiplied to the corresponding
elements of this
public void scaleEquals(double scaleFactor)
Ring
this
by
scaleFactor
scaleEquals
in interface Ring<Vector>
scaleEquals
in class AbstractVectorSpace<Vector,VectorEntry>
scaleFactor
- amount to scale the elements of this
public void scaledPlusEquals(double scaleFactor, Vector other)
Ring
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.scaledPlusEquals
in interface Ring<Vector>
scaledPlusEquals
in class AbstractVector
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.public void scaledPlusEquals(double scaleFactor, AbstractMTJVector other)
scaleFactor
- The scale factor to use.other
- The other vector to scale and then add to this vector.public void scaledMinusEquals(double scaleFactor, AbstractMTJVector other)
scaleFactor
- The scale factor to use.other
- The other vector to scale and then subtract from this vector.public java.util.Iterator<VectorEntry> iterator()
iterator
in interface java.lang.Iterable<VectorEntry>
public void zero()
Ring
this
, so that the following are
equivalent
r1.scaleEquals( 0.0 );
and
r1.zero();
Furthermore,
r1.zero(); anything.dotTimes( r1 ).equals( r1 );public Matrix outerProduct(Vector other)
Vector
outerProduct
in interface Vector
outerProduct
in class AbstractVector
other
- post-multiplied Vector with which to compute the outer productpublic abstract AbstractMTJMatrix outerProduct(AbstractMTJVector other)
other
- post-multiplied Vector with which to compute the outer product