JSci.maths
Class IntegerVector

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

public class IntegerVector
extends MathVector

The IntegerVector class encapsulates vectors containing integers.

Version:
2.1
Author:
Mark Hale
See Also:
Serialized Form

Field Summary
protected static int ARRAY_1D
          Storage format identifier.
protected  int[] vector
          Array containing the components of the vector.
 
Fields inherited from class JSci.maths.MathVector
CLASS_SPECIFIC, N, storageFormat
 
Constructor Summary
  IntegerVector(int dim)
          Constructs an empty vector.
  IntegerVector(int[] array)
          Constructs a vector by wrapping an array.
protected IntegerVector(int dim, int storeID)
           
 
Method Summary
 AbelianGroup.Member add(AbelianGroup.Member v)
          Returns the addition of this vector and another.
 IntegerVector add(IntegerVector v)
          Returns the addition of this vector and another.
 boolean equals(java.lang.Object a)
          Compares two integer vectors for equality.
 int getComponent(int n)
          Returns a component of this vector.
 int hashCode()
          Returns a hashcode for 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.
 IntegerVector 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(IntegerVector v)
          Returns the scalar product of this vector and another.
 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.
 IntegerVector subtract(IntegerVector v)
          Returns the subtraction of this vector by another.
 ComplexVector toComplexVector()
          Converts this vector to a complex vector.
 DoubleVector 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.MathVector
dimension, getInvalidComponentMsg
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ARRAY_1D

protected static final int ARRAY_1D
Storage format identifier.

See Also:
Constant Field Values

vector

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

Constructor Detail

IntegerVector

protected IntegerVector(int dim,
                        int storeID)

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 java.lang.Object
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 java.lang.Object

hashCode

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

Overrides:
hashCode in class java.lang.Object

toDoubleVector

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

Returns:
a double vector

toComplexVector

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

Returns:
a complex vector

getComponent

public 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 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.

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.


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 IntegerVector add(IntegerVector v)
Returns the addition of this vector and another.

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

subtract

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

Parameters:
v - a group member

subtract

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

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

scalarMultiply

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

Parameters:
x - a ring member

scalarMultiply

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

Parameters:
x - an integer

scalarProduct

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

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