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

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
                          extended by gov.sandia.cognition.math.matrix.mtj.Vector2
All Implemented Interfaces:
Vector, Vector2D, Vectorizable, VectorSpace<Vector,VectorEntry>, Ring<Vector>, CloneableSerializable, Pair<Double,Double>, Serializable, Cloneable, Iterable<VectorEntry>

@CodeReview(reviewer="Justin Basilico",
            date="2006-07-26",
            changesNeeded=false,
            comments="Looks good.")
public class Vector2
extends DenseVector
implements Vector2D

Implements a two-dimensional MTJ DenseVector.

Since:
1.0
Author:
Justin Basilico
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
Vector2()
          Creates a new instance of Vector2 that is all zeros.
Vector2(double x, double y)
          Creates a new instance of Vector2 with the given coordinates.
Vector2(Vector other)
          Creates a new instance of Vector2 with values copied from the given vector.
Vector2(Vector2D other)
          Creates a new instance of Vector2 wi th values copied from the given vector.
 
Method Summary
 Vector2 clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 int getDimensionality()
          Returns the number of elements in the Vector
 Double getFirst()
          Gets the first object.
 Double getSecond()
          Gets the second object.
 double getX()
          Gets the value of the first dimension (x).
 double getY()
          Gets the value of the second dimension (y).
 void setX(double x)
          Sets the value of the first dimension (x).
 void setXY(double x, double y)
          Sets the value of both dimensions of the vector.
 void setY(double y)
          Sets the value of the second dimension (y).
 String toString()
          The String representation of the Vector2, which is "<x, y>".
 
Methods inherited from class gov.sandia.cognition.math.matrix.mtj.DenseVector
equals, euclideanDistanceSquared, getArray, isSparse, outerProduct, setInternalVector, stack, subVector
 
Methods inherited from class gov.sandia.cognition.math.matrix.mtj.AbstractMTJVector
dotProduct, dotProduct, dotTimesEquals, 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, 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
assertDimensionalityEquals, assertSameDimensionality, checkSameDimensionality, dotDivide, dotDivideEquals, getElement, isSparse, outerProduct, setElement, stack, subVector, times, toArray, toString, toString, transform, transformEquals, transformNonZeros, transformNonZerosEquals
 
Methods inherited from interface gov.sandia.cognition.math.matrix.VectorSpace
angle, cosine, dotProduct, euclideanDistance, euclideanDistanceSquared, isUnitVector, isUnitVector, norm, norm1, norm2, norm2Squared, normInfinity, sum, unitVector, unitVectorEquals
 
Methods inherited from interface gov.sandia.cognition.math.Ring
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
 
Methods inherited from interface gov.sandia.cognition.math.matrix.Vectorizable
convertFromVector, convertToVector
 

Constructor Detail

Vector2

public Vector2()
Creates a new instance of Vector2 that is all zeros.


Vector2

public Vector2(double x,
               double y)
Creates a new instance of Vector2 with the given coordinates.

Parameters:
x - The x-coordinate.
y - The y-coordinate.

Vector2

public Vector2(Vector other)
Creates a new instance of Vector2 with values copied from the given vector.

Parameters:
other - The other vector to copy.

Vector2

public Vector2(Vector2D other)
Creates a new instance of Vector2 wi th values copied from the given vector.

Parameters:
other - The other vector to copy.
Method Detail

clone

public Vector2 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 AbstractMTJVector
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
Overrides:
getDimensionality in class AbstractMTJVector
Returns:
number of elements in the Vector

getX

public double getX()
Description copied from interface: Vector2D
Gets the value of the first dimension (x).

Specified by:
getX in interface Vector2D
Returns:
The value of the first dimension (x).

setX

public void setX(double x)
Description copied from interface: Vector2D
Sets the value of the first dimension (x).

Specified by:
setX in interface Vector2D
Parameters:
x - The value for the first dimension (x).

getY

public double getY()
Description copied from interface: Vector2D
Gets the value of the second dimension (y).

Specified by:
getY in interface Vector2D
Returns:
The value of the second dimension (y).

setY

public void setY(double y)
Description copied from interface: Vector2D
Sets the value of the second dimension (y).

Specified by:
setY in interface Vector2D
Parameters:
y - The value of the second dimension (y).

setXY

public void setXY(double x,
                  double y)
Description copied from interface: Vector2D
Sets the value of both dimensions of the vector.

Specified by:
setXY in interface Vector2D
Parameters:
x - The value of the first dimension (x).
y - The value of the second dimension (y).

toString

public String toString()
The String representation of the Vector2, which is "<x, y>".

Specified by:
toString in interface Vector
Overrides:
toString in class AbstractVector
Returns:
The string "<x, y>".

getFirst

public Double getFirst()
Description copied from interface: Pair
Gets the first object.

Specified by:
getFirst in interface Pair<Double,Double>
Returns:
The first object.

getSecond

public Double getSecond()
Description copied from interface: Pair
Gets the second object.

Specified by:
getSecond in interface Pair<Double,Double>
Returns:
The second object.