org.jscience.mathematics.algebraic.matrices
Class IntegerVector

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.IntegerVector
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 IntegerVector
extends AbstractIntegerVector
implements java.lang.Cloneable, java.io.Serializable

An array-based implementation of an integer vector.

See Also:
Serialized Form

Field Summary
protected  int[] vector
          Array containing the components of the vector.
 
Constructor Summary
IntegerVector(AbstractIntegerVector vec)
          Constructs a vector by copying a vector.
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)
          DOCUMENT ME!
 java.lang.Object clone()
          Clone vector into a new vector.
 boolean equals(java.lang.Object a, double tol)
          Compares two Integer vectors for equality.
 int getPrimitiveElement(int n)
          Returns a component of this vector.
 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 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)
          DOCUMENT ME!
 void setAllElements(int r)
          Sets the value of all elements of the vector.
 void setElement(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)
          DOCUMENT ME!
 int sumSquares()
          Returns the sum of the squares of the components.
 AbstractComplexVector toComplexVector()
          Converts this vector to a complex vector.
 AbstractDoubleVector toDoubleVector()
          Converts this vector to a double 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

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

IntegerVector

public IntegerVector(AbstractIntegerVector vec)
Constructs a vector by copying a vector.

Parameters:
vec - an assigned value
Method Detail

equals

public boolean equals(java.lang.Object a,
                      double tol)
Compares two Integer vectors for equality.

Overrides:
equals in class AbstractIntegerVector
Parameters:
a - a Integer vector.
tol - DOCUMENT ME!
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 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.

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

Specified by:
setElement in class AbstractIntegerVector
Parameters:
n - index of the vector component
x - an integer
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

norm

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

Overrides:
norm in class AbstractIntegerVector
Parameters:
n - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.ArithmeticException - DOCUMENT ME!

norm

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

Overrides:
norm in class AbstractIntegerVector
Returns:
DOCUMENT ME!
Throws:
java.lang.ArithmeticException - DOCUMENT ME!

infNorm

public int infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class AbstractIntegerVector
Returns:
DOCUMENT ME!
Throws:
java.lang.ArithmeticException - DOCUMENT ME!

sumSquares

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

Overrides:
sumSquares in class AbstractIntegerVector
Returns:
DOCUMENT ME!
Throws:
java.lang.ArithmeticException - DOCUMENT ME!

mass

public int mass()
Returns the mass.

Overrides:
mass in class AbstractIntegerVector
Returns:
DOCUMENT ME!
Throws:
java.lang.ArithmeticException - 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 v)
Returns the addition of this vector and another.

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

add

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

Overrides:
add in class AbstractIntegerVector
Parameters:
v - an integer vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the vectors are different sizes.

add

public IntegerVector add(IntegerVector v)
DOCUMENT ME!

Parameters:
v - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!

subtract

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

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

subtract

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

Overrides:
subtract in class AbstractIntegerVector
Parameters:
v - an integer vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the vectors are different sizes.

subtract

public IntegerVector subtract(IntegerVector v)
DOCUMENT ME!

Parameters:
v - DOCUMENT ME!
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 x)
Returns the multiplication of this vector by a scalar.

Overrides:
scalarMultiply in class AbstractIntegerVector
Parameters:
x - an integer
Returns:
DOCUMENT ME!

scalarProduct

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

Overrides:
scalarProduct in class AbstractIntegerVector
Parameters:
v - an integer vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the vectors are different sizes.

scalarProduct

public int scalarProduct(IntegerVector v)
DOCUMENT ME!

Parameters:
v - DOCUMENT ME!
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.