org.jscience.mathematics.algebraic.matrices
Class Integer2Vector

java.lang.Object
  extended by org.jscience.mathematics.algebraic.AbstractHypermatrix
      extended by org.jscience.mathematics.algebraic.AbstractMatrix
          extended by org.jscience.mathematics.algebraic.AbstractVector
              extended by org.jscience.mathematics.algebraic.matrices.AbstractIntegerVector
                  extended by org.jscience.mathematics.algebraic.matrices.Integer2Vector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Algebra.Member, Ring.Member, AbelianGroup.Member, Hypermatrix, Matrix, Module.Member, VectorSpace.Member, Vector, Member

public class Integer2Vector
extends AbstractIntegerVector
implements java.lang.Cloneable, java.io.Serializable

An optimised implementation of a 2D integer vector.

See Also:
Serialized Form

Field Summary
 int x
          DOCUMENT ME!
 int y
          DOCUMENT ME!
 
Constructor Summary
Integer2Vector()
          Constructs an empty 2-vector.
Integer2Vector(int[] array)
          Constructs a 2-vector.
Integer2Vector(Integer2Vector vec)
          Constructs a 2-vector.
Integer2Vector(int x, int y)
          Constructs a 2-vector.
 
Method Summary
 AbelianGroup.Member add(AbelianGroup.Member vec)
          Returns the addition of this vector and another.
 AbstractIntegerVector add(AbstractIntegerVector vec)
          Returns the addition of this vector and another.
 java.lang.Object clone()
          Clone vector into a new vector.
 boolean equals(java.lang.Object obj)
          Compares two integer vectors for equality.
 int getPrimitiveElement(int n)
          Returns a component of this vector.
 int getX()
          DOCUMENT ME!
 int getY()
          DOCUMENT ME!
 int infNorm()
          Returns the linfinity-norm.
 AbstractDoubleVector mapElements(PrimitiveMapping f)
          Applies a function on all the vector components.
 int mass()
          Returns the mass.
 AbelianGroup.Member negate()
          Returns the negative of this vector.
 double norm()
          Returns the l2-norm (magnitude).
 double norm(int n)
          Returns the ln-norm.
 AbstractIntegerVector scalarMultiply(int k)
          Returns the multiplication of this vector by a scalar.
 Module.Member scalarMultiply(Ring.Member x)
          Returns the multiplication of this vector by a scalar.
 int scalarProduct(AbstractIntegerVector vec)
          Returns the scalar product of this vector and another.
 void setAllElements(int r)
          Sets the value of all elements of the vector.
 void setElement(int n, int value)
          Sets the value of a component of this vector.
 void setX(int d)
          DOCUMENT ME!
 void setY(int d)
          DOCUMENT ME!
 AbelianGroup.Member subtract(AbelianGroup.Member vec)
          Returns the subtraction of this vector by another.
 AbstractIntegerVector subtract(AbstractIntegerVector vec)
          Returns the subtraction of this vector by another.
 int sumSquares()
          Returns the sum of the squares of the components.
 AbstractComplexVector toComplexVector()
          Converts this 2-vector to a complex 2-vector.
 AbstractDoubleVector toDoubleVector()
          Converts this 2-vector to a double 2-vector.
 int[] toPrimitiveArray()
          Projects the vector to an array.
 java.lang.String toString()
          Returns a comma delimited string representing the value of this vector.
 
Methods inherited from class org.jscience.mathematics.algebraic.matrices.AbstractIntegerVector
abs, equals, getColumn, getElement, getRow, getSubVector, hashCode, max, mean, min, multiply, read, reverse, scalarDivide, setColumn, setElement, setRow, setSubVector, standardDeviation, tensorProduct, toMatrix, transpose, variance
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractVector
getDimension, getElement, getInvalidElementMsg, toArray, toArray
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractMatrix
getElement, getInvalidElementMsg, numColumns, numRows, print, print, print, print, toArray
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractHypermatrix
getDimensions, numDimensions, numElements, numElements, toArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jscience.mathematics.algebraic.Matrix
numColumns, numRows, toArray
 
Methods inherited from interface org.jscience.mathematics.algebraic.Hypermatrix
getDimensions, getElement, numDimensions, numElements, numElements, toArray
 

Field Detail

x

public int x
DOCUMENT ME!


y

public int y
DOCUMENT ME!

Constructor Detail

Integer2Vector

public Integer2Vector()
Constructs an empty 2-vector.


Integer2Vector

public Integer2Vector(int x,
                      int y)
Constructs a 2-vector.

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

Integer2Vector

public Integer2Vector(int[] array)
Constructs a 2-vector.

Parameters:
array - DOCUMENT ME!

Integer2Vector

public Integer2Vector(Integer2Vector vec)
Constructs a 2-vector.

Parameters:
vec - DOCUMENT ME!
Method Detail

equals

public boolean equals(java.lang.Object obj)
Compares two integer vectors for equality.

Overrides:
equals in class AbstractIntegerVector
Parameters:
obj - a integer 2-vector
Returns:
DOCUMENT ME!

toString

public java.lang.String toString()
Returns a comma delimited string representing the value of this vector.

Overrides:
toString in class AbstractIntegerVector
Returns:
DOCUMENT ME!

toDoubleVector

public AbstractDoubleVector toDoubleVector()
Converts this 2-vector to a double 2-vector.

Overrides:
toDoubleVector in class AbstractIntegerVector
Returns:
a double 2-vector

toComplexVector

public AbstractComplexVector toComplexVector()
Converts this 2-vector to a complex 2-vector.

Overrides:
toComplexVector in class AbstractIntegerVector
Returns:
a complex 2-vector

getPrimitiveElement

public int getPrimitiveElement(int n)
Returns a component of this vector.

Specified by:
getPrimitiveElement in class AbstractIntegerVector
Parameters:
n - index of the vector component
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If attempting to access an invalid component.

setElement

public void setElement(int n,
                       int value)
Sets the value of a component of this vector. Should only be used to initialise this vector.

Specified by:
setElement in class AbstractIntegerVector
Parameters:
n - index of the vector component
value - a number
Throws:
IllegalDimensionException - If attempting to access an invalid component.

setAllElements

public void setAllElements(int r)
Sets the value of all elements of the vector.

Overrides:
setAllElements in class AbstractIntegerVector
Parameters:
r - a int element

getX

public int getX()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getY

public int getY()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setX

public void setX(int d)
DOCUMENT ME!

Parameters:
d - DOCUMENT ME!

setY

public void setY(int d)
DOCUMENT ME!

Parameters:
d - DOCUMENT ME!

norm

public double norm(int n)
Returns the ln-norm.

Overrides:
norm in class AbstractIntegerVector
Parameters:
n - DOCUMENT ME!
Returns:
DOCUMENT ME!

norm

public double norm()
Returns the l2-norm (magnitude).

Overrides:
norm in class AbstractIntegerVector
Returns:
DOCUMENT ME!

infNorm

public int infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class AbstractIntegerVector
Returns:
DOCUMENT ME!

sumSquares

public int sumSquares()
Returns the sum of the squares of the components.

Overrides:
sumSquares in class AbstractIntegerVector
Returns:
DOCUMENT ME!

mass

public int mass()
Returns the mass.

Overrides:
mass in class AbstractIntegerVector
Returns:
DOCUMENT ME!

negate

public AbelianGroup.Member negate()
Returns the negative of this vector.

Specified by:
negate in interface AbelianGroup.Member
Returns:
DOCUMENT ME!

add

public AbelianGroup.Member add(AbelianGroup.Member vec)
Returns the addition of this vector and another.

Specified by:
add in interface AbelianGroup.Member
Parameters:
vec - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

add

public AbstractIntegerVector add(AbstractIntegerVector vec)
Returns the addition of this vector and another.

Overrides:
add in class AbstractIntegerVector
Parameters:
vec - a integer 2-vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!

subtract

public AbelianGroup.Member subtract(AbelianGroup.Member vec)
Returns the subtraction of this vector by another.

Specified by:
subtract in interface AbelianGroup.Member
Parameters:
vec - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

subtract

public AbstractIntegerVector subtract(AbstractIntegerVector vec)
Returns the subtraction of this vector by another.

Overrides:
subtract in class AbstractIntegerVector
Parameters:
vec - a integer 2-vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!

scalarMultiply

public Module.Member scalarMultiply(Ring.Member x)
Returns the multiplication of this vector by a scalar.

Specified by:
scalarMultiply in interface Module.Member
Parameters:
x - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

scalarMultiply

public AbstractIntegerVector scalarMultiply(int k)
Returns the multiplication of this vector by a scalar.

Overrides:
scalarMultiply in class AbstractIntegerVector
Parameters:
k - a integer
Returns:
a integer 2-vector

scalarProduct

public int scalarProduct(AbstractIntegerVector vec)
Returns the scalar product of this vector and another.

Overrides:
scalarProduct in class AbstractIntegerVector
Parameters:
vec - a integer 2-vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!

mapElements

public AbstractDoubleVector mapElements(PrimitiveMapping f)
Applies a function on all the vector components.

Overrides:
mapElements in class AbstractIntegerVector
Parameters:
f - a user-defined function.
Returns:
a double vector.

toPrimitiveArray

public int[] toPrimitiveArray()
Projects the vector to an array.

Overrides:
toPrimitiveArray in class AbstractIntegerVector
Returns:
an integer array.

clone

public java.lang.Object clone()
Clone vector into a new vector.

Overrides:
clone in class java.lang.Object
Returns:
the cloned vector.