JSci.maths.vectors
Class Integer2Vector

java.lang.Object
  extended byJSci.maths.vectors.MathVector
      extended byJSci.maths.vectors.AbstractIntegerVector
          extended byJSci.maths.vectors.Integer2Vector
All Implemented Interfaces:
AbelianGroup.Member, Member, Module.Member, java.io.Serializable

public final class Integer2Vector
extends AbstractIntegerVector

An optimised implementation of a 2D integer vector.

See Also:
Serialized Form

Field Summary
protected  int x
           
protected  int y
           
 
Fields inherited from class JSci.maths.vectors.MathVector
N
 
Constructor Summary
Integer2Vector()
          Constructs an empty 2-vector.
Integer2Vector(int[] array)
          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.
 boolean equals(java.lang.Object obj)
          Compares two integer vectors for equality.
 int getComponent(int n)
          Returns a component of this vector.
 double infNorm()
          Returns the linfinity-norm.
 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 setComponent(int n, int value)
          Sets the value of a component of this vector.
 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.
 AbstractComplexVector toComplexVector()
          Converts this 2-vector to a complex 2-vector.
 AbstractDoubleVector toDoubleVector()
          Converts this 2-vector to a double 2-vector.
 java.lang.String toString()
          Returns a comma delimited string representing the value of this vector.
 
Methods inherited from class JSci.maths.vectors.AbstractIntegerVector
hashCode
 
Methods inherited from class JSci.maths.vectors.MathVector
dimension, getInvalidComponentMsg
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

protected int x

y

protected int y
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.

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

toString

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

Overrides:
toString in class AbstractIntegerVector

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.

Returns:
a complex 2-vector

getComponent

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

Specified by:
getComponent in class AbstractIntegerVector
Parameters:
n - index of the vector component
Throws:
VectorDimensionException - If attempting to access an invalid component.

setComponent

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

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

norm

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

Overrides:
norm in class AbstractIntegerVector

norm

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

Overrides:
norm in class AbstractIntegerVector

infNorm

public double infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class AbstractIntegerVector

negate

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


add

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

Parameters:
vec - a group member

add

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

Specified by:
add in class AbstractIntegerVector
Parameters:
vec - a integer 2-vector

subtract

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

Parameters:
vec - a group member

subtract

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

Specified by:
subtract in class AbstractIntegerVector
Parameters:
vec - a integer 2-vector

scalarMultiply

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

Parameters:
x - a ring member

scalarMultiply

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

Specified by:
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.

Specified by:
scalarProduct in class AbstractIntegerVector
Parameters:
vec - a integer 2-vector