org.jscience.mathematics.algebraic.matrices
Class AbstractBooleanVector

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.AbstractBooleanVector
All Implemented Interfaces:
java.io.Serializable, Algebra.Member, Ring.Member, AbelianGroup.Member, Hypermatrix, Matrix, Module.Member, VectorSpace.Member, Vector, Member
Direct Known Subclasses:
BooleanVector

public abstract class AbstractBooleanVector
extends AbstractVector

The AbstractBooleanVector class encapsulates vectors containing booleans.

See Also:
Serialized Form

Constructor Summary
protected AbstractBooleanVector(int dim)
          Creates a new AbstractBooleanVector object.
 
Method Summary
 AbstractBooleanVector add(AbstractBooleanVector v)
          Returns the addition of this vector and another.
 AbstractBooleanVector and(AbstractBooleanVector v)
          Returns the and of this vector and another.
 BooleanVector andNot(BooleanVector v)
          Clears all of the Boolean in receiver whose corresponding bit is set in the other BooleanVector (A = A \ B).
 boolean equals(java.lang.Object a)
          Compares two integer vectors for equality.
 AbstractBooleanVector getColumn(int j)
          Returns the ith column.
 Boolean getElement(int n)
          Returns an element of this vector.
abstract  boolean getPrimitiveElement(int n)
          Returns an element of this vector (this is the fastest way of getting an element for this kind of matrix).
 AbstractBooleanVector getRow(int i)
          Returns the ith row.
 AbstractBooleanVector getSubVector(int k1, int k2)
          Computes a sub vector from the parameters index.
abstract  int hashCode()
          Returns a hashcode for this NON EMPTY vector.
 AbstractBooleanVector mapElements(PrimitiveMapping f)
          Applies a function on all the vector components.
 AbelianGroup.Member negate()
          Returns the negative (not) of this vector.
 AbstractBooleanVector not()
          Returns the not of this vector and another.
 AbstractBooleanVector or(AbstractBooleanVector v)
          Returns the or of this vector and another.
static AbstractBooleanVector read(java.io.BufferedReader input)
          Read a vector from a stream.
 AbstractBooleanVector reverse()
          Invert vector elements order from the last to the first.
 VectorSpace.Member scalarDivide(Field.Member x)
          Returns the division of this matrix by a scalar.
 AbstractBooleanVector scalarMultiply(boolean x)
          Returns the multiplication of this vector by a scalar.
 int scalarProduct(AbstractBooleanVector v)
          Returns the scalar product of this vector and another.
 void setAllElements(boolean r)
          Sets the value of all elements of the vector.
 void setColumn(int j, AbstractBooleanVector v)
          Returns the ith column.
abstract  void setElement(int n, boolean x)
          Sets the value of an element of this vector.
 void setElement(int n, Boolean x)
          Sets the value of a component of this vector.
 void setRow(int i, AbstractBooleanVector v)
          Returns the ith row.
 AbstractBooleanVector setSubVector(int k, AbstractBooleanVector v)
          Set a sub vector.
 AbstractBooleanVector subtract(AbstractBooleanVector v)
          Returns the subtraction of this vector by another.
 AbstractComplexVector toComplexVector()
          Converts this vector to a complex vector.
 AbstractDoubleVector toDoubleVector()
          Converts this vector to a double vector.
 AbstractIntegerVector toIntegerVector()
          Converts this vector to a integer vector.
 Matrix toMatrix()
          Projects the vector to the corresponding (n, 1) matrix class.
 boolean[] toPrimitiveArray()
          Projects the vector to an array.
 java.lang.String toString()
          Returns a comma delimited string representing the value of this vector.
 Matrix transpose()
          DOCUMENT ME!
 AbstractBooleanVector xor(AbstractBooleanVector v)
          Returns the xor of this vector and another.
 
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
clone, 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
 
Methods inherited from interface org.jscience.mathematics.algebraic.modules.Module.Member
scalarMultiply
 
Methods inherited from interface org.jscience.mathematics.algebraic.groups.AbelianGroup.Member
add, subtract
 
Methods inherited from interface org.jscience.mathematics.algebraic.fields.Ring.Member
multiply
 

Constructor Detail

AbstractBooleanVector

protected AbstractBooleanVector(int dim)
Creates a new AbstractBooleanVector object.

Parameters:
dim - DOCUMENT ME!
Method Detail

toString

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

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

hashCode

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

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

toIntegerVector

public AbstractIntegerVector toIntegerVector()
Converts this vector to a integer vector.

Returns:
a double vector

toDoubleVector

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

Returns:
a double vector

toComplexVector

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

Returns:
a complex vector

getPrimitiveElement

public abstract boolean getPrimitiveElement(int n)
Returns an element of this vector (this is the fastest way of getting an element for this kind of matrix).

Parameters:
n - index of the vector element.
Returns:
DOCUMENT ME!

getElement

public Boolean getElement(int n)
Returns an element of this vector.

Specified by:
getElement in interface Vector
Specified by:
getElement in class AbstractVector
Parameters:
n - index of the vector element.
Returns:
DOCUMENT ME!

getRow

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

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

getColumn

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

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

setRow

public void setRow(int i,
                   AbstractBooleanVector v)
Returns the ith row.


setColumn

public void setColumn(int j,
                      AbstractBooleanVector v)
Returns the ith column.


setElement

public abstract void setElement(int n,
                                boolean x)
Sets the value of an element of this vector.

Parameters:
n - index of the vector element
x - an integer

setElement

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

Parameters:
n - index of the vector component
x - a boolean
Throws:
IllegalDimensionException - If attempting to access an invalid component.

setAllElements

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

Parameters:
r - a boolean element

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
Returns:
DOCUMENT ME!

scalarDivide

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

Parameters:
x - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

transpose

public Matrix transpose()
DOCUMENT ME!

Returns:
DOCUMENT ME!

and

public AbstractBooleanVector and(AbstractBooleanVector v)
Returns the and of this vector and another.

Parameters:
v - an boolean vector
Returns:
DOCUMENT ME!

andNot

public BooleanVector andNot(BooleanVector v)
Clears all of the Boolean in receiver whose corresponding bit is set in the other BooleanVector (A = A \ B). In other words, determines the difference (A=A\B) between two BooleanVectors.

Parameters:
v - a BooleanVector with which to mask the receiver.
Throws:
java.lang.IllegalArgumentException - if size() > other.size().

or

public AbstractBooleanVector or(AbstractBooleanVector v)
Returns the or of this vector and another.

Parameters:
v - an boolean vector
Returns:
DOCUMENT ME!

not

public AbstractBooleanVector not()
Returns the not of this vector and another.

Returns:
DOCUMENT ME!

xor

public AbstractBooleanVector xor(AbstractBooleanVector v)
Returns the xor of this vector and another.

Parameters:
v - an boolean vector
Returns:
DOCUMENT ME!

negate

public AbelianGroup.Member negate()
Returns the negative (not) of this vector.

Returns:
DOCUMENT ME!

add

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

Parameters:
v - an boolean vector
Returns:
DOCUMENT ME!

subtract

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

Parameters:
v - an boolean vector
Returns:
DOCUMENT ME!

scalarMultiply

public AbstractBooleanVector scalarMultiply(boolean x)
Returns the multiplication of this vector by a scalar.

Parameters:
x - an boolean
Returns:
DOCUMENT ME!

scalarProduct

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

Parameters:
v - an boolean vector
Returns:
DOCUMENT ME!

reverse

public AbstractBooleanVector reverse()
Invert vector elements order from the last to the first.


getSubVector

public AbstractBooleanVector getSubVector(int k1,
                                          int k2)
Computes a sub vector from the parameters index. If k1<0 k1 elements are added at the beginning of the returned vector If k2>getDimension() k2-getDimension() elements are added at the end of the returned vector Finally, if k1>k2 the vector is returned inverted.

Parameters:
k1 - the beginning index
k2 - the finishing index
Returns:
the sub vector.

setSubVector

public AbstractBooleanVector setSubVector(int k,
                                          AbstractBooleanVector v)
Set a sub vector. If k<0 the elements are added at the beginning of the returned vector If k+v.getDimension()>getDimension() k+v.getDimension()-getDimension() elements are added at the end of the returned vector

Parameters:
k - Initial row index to offset the patching vector
v - the patching vector

mapElements

public AbstractBooleanVector mapElements(PrimitiveMapping f)
Applies a function on all the vector components. We assume that the mapping is from int to int and that input values are only 0 or 1 meaning respectively false, true

Parameters:
f - a user-defined function.
Returns:
an boolean vector.

toPrimitiveArray

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

Returns:
a boolean array.

toMatrix

public Matrix toMatrix()
Projects the vector to the corresponding (n, 1) matrix class.

Returns:
an double matrix.

read

public static AbstractBooleanVector read(java.io.BufferedReader input)
                                  throws java.io.IOException
Read a vector from a stream. The format is DIFFERENT from the print method, so printed vector can be read back in (provided they were printed using US Locale). Elements are separated by whitespace, all the elements appear on a single line NOT a single column (use matrix.read() if you want this behavior).

Parameters:
input - the input stream.
Throws:
java.io.IOException