org.jscience.mathematics.algebraic.matrices
Class RingVector

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

The RingVector class provides an object for encapsulating vectors over an arbitrary ring.

See Also:
Serialized Form

Field Summary
protected  Ring.Member[] vector
          Array containing the elements of the vector .
 
Constructor Summary
RingVector(int dim)
          Constructs an empty vector.
RingVector(Ring.Member[] array)
          Constructs a vector by wrapping an array.
RingVector(RingVector vec)
          Constructs a vector by copying a vector.
 
Method Summary
 AbelianGroup.Member add(AbelianGroup.Member m)
          Returns the addition of this vector and another.
 RingVector add(RingVector v)
          Returns the addition of this vector and another.
 java.lang.Object clone()
          Clone vector into a new vector.
 boolean equals(java.lang.Object v)
          Compares two vectors for equality.
 RingVector getColumn(int j)
          Returns the ith column.
 java.lang.Number getElement(int i)
          Returns an element of the vector.
 Ring.Member getPrimitiveElement(int i)
          Returns an element of this vector (this is the fastest way of getting an element for this kind of matrix).
 RingVector getRow(int i)
          Returns the ith row.
 RingVector mapElements(NumberMapping f)
          Applies a function on all the vector components.
 Ring.Member multiply(Ring.Member r)
          DOCUMENT ME!
 AbelianGroup.Member negate()
          Returns the negative of this vector.
 VectorSpace.Member scalarDivide(Field.Member x)
          Returns the division of this vector by a scalar.
 Module.Member scalarMultiply(Ring.Member r)
          Returns the multiplication of this vector by a scalar.
 void setAllElements(Ring.Member r)
          Sets the value of all elements of the vector.
 void setElement(int i, Ring.Member r)
          Sets the value of an element of the vector.
 AbelianGroup.Member subtract(AbelianGroup.Member m)
          Returns the subtraction of this vector and another.
 RingVector subtract(RingVector v)
          Returns the subtraction of this vector and another.
 RingVector tensorProduct(RingVector m)
          Returns the tensor product of this vector and another.
 Ring.Member[] toPrimitiveArray()
          Projects the vector to an array.
 java.lang.String toString()
          Returns a string representing this vector.
 RingMatrix transpose()
          DOCUMENT ME!
 
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, hashCode, 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 Ring.Member[] vector
Array containing the elements of the vector .

Constructor Detail

RingVector

public RingVector(int dim)
Constructs an empty vector.

Parameters:
dim - the dimension of the vector.

RingVector

public RingVector(Ring.Member[] array)
Constructs a vector by wrapping an array.

Parameters:
array - an assigned value

RingVector

public RingVector(RingVector vec)
Constructs a vector by copying a vector.

Parameters:
vec - an assigned value
Method Detail

equals

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

Overrides:
equals in class java.lang.Object
Parameters:
v - a vector
Returns:
DOCUMENT ME!

toString

public java.lang.String toString()
Returns a string representing this vector.

Overrides:
toString in class java.lang.Object
Returns:
DOCUMENT ME!

getElement

public java.lang.Number getElement(int i)
Returns an element of the vector.

Specified by:
getElement in interface Vector
Specified by:
getElement in class AbstractVector
Parameters:
i - row index of the element
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If attempting to access an invalid element.

getPrimitiveElement

public Ring.Member getPrimitiveElement(int i)
Returns an element of this vector (this is the fastest way of getting an element for this kind of matrix).

Parameters:
i - index of the vector element.
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If attempting to access an invalid element.

getRow

public RingVector getRow(int i)
Returns the ith row.

Specified by:
getRow in interface Matrix
Parameters:
i - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!

getColumn

public RingVector getColumn(int j)
Returns the ith column.

Specified by:
getColumn in interface Matrix
Parameters:
j - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!

setElement

public void setElement(int i,
                       Ring.Member r)
Sets the value of an element of the vector.

Parameters:
i - row index of the element
r - a ring element
Throws:
IllegalDimensionException - If attempting to access an invalid element.

setAllElements

public void setAllElements(Ring.Member r)
Sets the value of all elements of the vector.

Parameters:
r - a ring element

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 m)
Returns the addition of this vector and another.

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

add

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

Parameters:
v - a vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the vectors are different sizes.

subtract

public AbelianGroup.Member subtract(AbelianGroup.Member m)
Returns the subtraction of this vector and another.

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

subtract

public RingVector subtract(RingVector v)
Returns the subtraction of this vector and another.

Parameters:
v - a vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the vectors are different sizes.

multiply

public Ring.Member multiply(Ring.Member r)
DOCUMENT ME!

Specified by:
multiply in interface Ring.Member
Parameters:
r - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!
java.lang.IllegalArgumentException - DOCUMENT ME!

scalarMultiply

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

Specified by:
scalarMultiply in interface Module.Member
Parameters:
r - a ring element.
Returns:
DOCUMENT ME!

scalarDivide

public VectorSpace.Member scalarDivide(Field.Member x)
Returns the division of this vector by a scalar.

Specified by:
scalarDivide in interface VectorSpace.Member
Parameters:
x - a field element.
Returns:
DOCUMENT ME!

tensorProduct

public RingVector tensorProduct(RingVector m)
Returns the tensor product of this vector and another.

Parameters:
m - DOCUMENT ME!
Returns:
DOCUMENT ME!

transpose

public RingMatrix transpose()
DOCUMENT ME!

Specified by:
transpose in interface Matrix
Returns:
DOCUMENT ME!

mapElements

public RingVector mapElements(NumberMapping f)
Applies a function on all the vector components.

Parameters:
f - a user-defined function.
Returns:
a Number vector.
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

toPrimitiveArray

public Ring.Member[] toPrimitiveArray()
Projects the vector to an array.

Returns:
an double array.

clone

public java.lang.Object clone()
Clone vector into a new vector.

Overrides:
clone in class java.lang.Object
Returns:
the cloned vector.