JSci.maths.vectors
Class IntegerVector

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

public class IntegerVector
extends AbstractIntegerVector

An array-based implementation of an integer vector.

See Also:
Serialized Form

Field Summary
protected  int[] vector
          Array containing the components of the vector.
 
Fields inherited from class JSci.maths.vectors.MathVector
N
 
Constructor Summary
IntegerVector(int dim)
          Constructs an empty vector.
IntegerVector(int[] array)
          Constructs a vector by wrapping an array.
 
Method Summary
 AbelianGroup.Member add(AbelianGroup.Member v)
          Returns the addition of this vector and another.
 AbstractIntegerVector add(AbstractIntegerVector v)
          Returns the addition of this vector and another.
 IntegerVector add(IntegerVector v)
           
 boolean equals(java.lang.Object a)
          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 x)
          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 v)
          Returns the scalar product of this vector and another.
 int scalarProduct(IntegerVector v)
           
 void setComponent(int n, int x)
          Sets the value of a component of this vector.
 AbelianGroup.Member subtract(AbelianGroup.Member v)
          Returns the subtraction of this vector by another.
 AbstractIntegerVector subtract(AbstractIntegerVector v)
          Returns the subtraction of this vector by another.
 IntegerVector subtract(IntegerVector v)
           
 AbstractComplexVector toComplexVector()
          Converts this vector to a complex vector.
 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.AbstractIntegerVector
getSet, 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

vector

protected int[] vector
Array containing the components of the vector.

Constructor Detail

IntegerVector

public IntegerVector(int dim)
Constructs an empty vector.

Parameters:
dim - the dimension of the vector.

IntegerVector

public IntegerVector(int[] array)
Constructs a vector by wrapping an array.

Parameters:
array - an assigned value
Method Detail

equals

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

Overrides:
equals in class AbstractIntegerVector
Parameters:
a - an integer 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 vector to a double vector.

Overrides:
toDoubleVector in class AbstractIntegerVector
Returns:
a double vector

toComplexVector

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

Returns:
a complex 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 x)
Sets the value of a component of this vector.

Specified by:
setComponent in class AbstractIntegerVector
Parameters:
n - index of the vector component
x - an integer
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 v)
Returns the addition of this vector and another.

Parameters:
v - a group member

add

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

Specified by:
add in class AbstractIntegerVector
Parameters:
v - an integer vector
Throws:
VectorDimensionException - If the vectors are different sizes.

add

public IntegerVector add(IntegerVector v)

subtract

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

Parameters:
v - a group member

subtract

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

Specified by:
subtract in class AbstractIntegerVector
Parameters:
v - an integer vector
Throws:
VectorDimensionException - If the vectors are different sizes.

subtract

public IntegerVector subtract(IntegerVector v)

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 x)
Returns the multiplication of this vector by a scalar.

Specified by:
scalarMultiply in class AbstractIntegerVector
Parameters:
x - an integer

scalarProduct

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

Specified by:
scalarProduct in class AbstractIntegerVector
Parameters:
v - an integer vector
Throws:
VectorDimensionException - If the vectors are different sizes.

scalarProduct

public int scalarProduct(IntegerVector v)