JSci.maths.vectors
Class AbstractIntegerVector

java.lang.Object
  extended by JSci.maths.vectors.MathVector
      extended by JSci.maths.vectors.AbstractIntegerVector
All Implemented Interfaces:
java.io.Serializable, Module.Member, AbelianGroup.Member, Member
Direct Known Subclasses:
Integer2Vector, Integer3Vector, IntegerVector

public abstract class AbstractIntegerVector
extends MathVector

The AbstractIntegerVector class encapsulates vectors containing integers.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class JSci.maths.vectors.MathVector
N
 
Constructor Summary
protected AbstractIntegerVector(int dim)
           
 
Method Summary
abstract  AbstractIntegerVector add(AbstractIntegerVector v)
          Returns the addition of this vector and another.
 boolean equals(java.lang.Object obj)
          Compares two integer vectors for equality.
abstract  int getComponent(int n)
          Returns a component of this vector.
 java.lang.Object getSet()
           
 int hashCode()
          Returns a hashcode for this vector.
 double infNorm()
          Returns the linfinity-norm.
 double norm()
          Returns the l2-norm (magnitude).
 double norm(int n)
          Returns the ln-norm.
abstract  AbstractIntegerVector scalarMultiply(int x)
          Returns the multiplication of this vector by a scalar.
abstract  int scalarProduct(AbstractIntegerVector v)
          Returns the scalar product of this vector and another.
abstract  void setComponent(int n, int x)
          Sets the value of a component of this vector.
abstract  AbstractIntegerVector subtract(AbstractIntegerVector v)
          Returns the subtraction of this vector by another.
 AbstractDoubleVector toDoubleVector()
          Converts this vector to a double vector.
 java.lang.String toString()
          Returns a comma delimited string representing the value of this vector.
 
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
 
Methods inherited from interface JSci.maths.algebras.Module.Member
scalarMultiply
 
Methods inherited from interface JSci.maths.groups.AbelianGroup.Member
add, negate, subtract
 

Constructor Detail

AbstractIntegerVector

protected AbstractIntegerVector(int dim)
Method Detail

equals

public boolean equals(java.lang.Object obj)
Compares two integer vectors for equality. Two vectors are considered to be equal if the norm of their difference is zero.

Overrides:
equals in class java.lang.Object
Parameters:
obj - an integer vector

toString

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

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Returns a hashcode for this vector.

Overrides:
hashCode in class java.lang.Object

toDoubleVector

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

Returns:
a double vector

getComponent

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

Parameters:
n - index of the vector component
Throws:
VectorDimensionException - If attempting to access an invalid component.

setComponent

public abstract void setComponent(int n,
                                  int x)
Sets the value of a component of this vector.

Parameters:
n - index of the vector component
x - an integer
Throws:
VectorDimensionException - If attempting to access an invalid component.

getSet

public java.lang.Object getSet()

norm

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


norm

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

Specified by:
norm in class MathVector

infNorm

public double infNorm()
Returns the linfinity-norm.


add

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

Parameters:
v - an integer vector
Throws:
VectorDimensionException - If the vectors are different sizes.

subtract

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

Parameters:
v - an integer vector
Throws:
VectorDimensionException - If the vectors are different sizes.

scalarMultiply

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

Parameters:
x - an integer

scalarProduct

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

Parameters:
v - an integer vector
Throws:
VectorDimensionException - If the vectors are different sizes.