Overview Package Class Tree Deprecated Index Help
PREV CLASS NEXT CLASS FRAMES NO FRAMES All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

ptolemy.data
Class BooleanMatrixToken

java.lang.Object
 extended byptolemy.data.Token
 extended byptolemy.data.MatrixToken
 extended byptolemy.data.BooleanMatrixToken
All Implemented Interfaces:
java.io.Serializable

public class BooleanMatrixToken
extends MatrixToken

A token that contains a 2-D boolean matrix.

Since:
Ptolemy II 0.2
Version:
$Id: BooleanMatrixToken.java,v 1.63 2006年08月21日 15:20:12 cxh Exp $
Author:
Yuhong Xiong, Steve Neuendorffer
See Also:
Serialized Form
Accepted Rating:
Yellow (cxh)
Proposed Rating:
Green (neuendor)

Field Summary
Fields inherited from class ptolemy.data.MatrixToken
_nils, DO_COPY, DO_NOT_COPY
Fields inherited from class ptolemy.data.Token
NIL
Constructor Summary
BooleanMatrixToken()
Construct an BooleanMatrixToken with a one by one matrix.
BooleanMatrixToken(boolean[][] value)
Construct a BooleanMatrixToken with the specified 2-D matrix.
BooleanMatrixToken(java.lang.String init)
Construct a BooleanMatrixToken from the specified string.
BooleanMatrixToken(Token[] tokens, int rows, int columns)
Construct an BooleanMatrixToken from the specified array of tokens.
Method Summary
protected boolean[][] _createIdentity(int dim)
Return an new identity matrix with the specified dimension.
boolean[][] booleanMatrix()
Return a copy of the contained 2-D matrix.
static BooleanMatrixToken convert(Token token)
Convert the specified token into an instance of BooleanMatrixToken.
boolean equals(java.lang.Object object)
Return true if the argument is an instance of BooleanMatrixToken of the same dimensions and the corresponding elements of the matrices are equal.
int getColumnCount()
Return the number of columns in the matrix.
Token getElementAsToken(int row, int column)
Return the element of the matrix at the specified row and column in a BooleanToken.
boolean getElementAt(int row, int column)
Return the element of the contained matrix at the specified row and column.
Type getElementType()
Return the Type of the tokens contained in this matrix token.
int getRowCount()
Return the number of rows in the matrix.
Type getType()
Return the type of this token.
int hashCode()
Return a hash code value for this token.
Token one()
Return a new Token representing the left multiplicative identity.
Token oneRight()
Return a new Token representing the right multiplicative identity.
Token zero()
Return a new Token representing the additive identity.
Methods inherited from class ptolemy.data.MatrixToken
_add, _addElement, _divideElement, _elementIsNil, _isCloseTo, _isEqualTo, _moduloElement, _multiply, _multiplyElement, _subtract, _subtractElement, _subtractElementReverse, add, addReverse, arrayToMatrix, arrayToMatrix, arrayToMatrixReturnType, complexMatrix, create, createSequence, createSequenceReturnType, createTokenSequence, determineSequenceLength, divide, divideReverse, doubleMatrix, intMatrix, isCloseTo, isEqualTo, longMatrix, matrixToArray, matrixToArrayReturnType, modulo, moduloReverse, multiply, multiplyReverse, subtract, subtractReverse, toArray, toArrayReturnType, toString
Methods inherited from class ptolemy.data.Token
isCloseTo, isNil, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, notSupportedNullNilStringMessage, pow, zeroReturnType
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait

Constructor Detail

BooleanMatrixToken

public BooleanMatrixToken()
Construct an BooleanMatrixToken with a one by one matrix. The only element in the matrix has value false.


BooleanMatrixToken

public BooleanMatrixToken(boolean[][] value)
 throws IllegalActionException
Construct a BooleanMatrixToken with the specified 2-D matrix. This method makes a copy of the matrix and stores the copy, so changes on the specified matrix after this token is constructed will not affect the content of this token.

Parameters:
value - The 2-D boolean matrix.
Throws:
IllegalActionException - If the specified matrix is null.

BooleanMatrixToken

public BooleanMatrixToken(java.lang.String init)
 throws IllegalActionException
Construct a BooleanMatrixToken from the specified string.

Parameters:
init - A string expression of a boolean matrix.
Throws:
IllegalActionException - If the string does not contain a parsable boolean matrix.

BooleanMatrixToken

public BooleanMatrixToken(Token[] tokens,
 int rows,
 int columns)
 throws IllegalActionException
Construct an BooleanMatrixToken from the specified array of tokens. The tokens in the array must be scalar tokens convertible into integers.

Parameters:
tokens - The array of tokens, which must contains rows*columns BooleanTokens.
rows - The number of rows in the matrix to be created.
columns - The number of columns in the matrix to be created.
Throws:
IllegalActionException - If the array of tokens is null, or the length of the array is not correct, or if one of the elements of the array is null, or if one of the elements of the array cannot be losslessly converted to a boolean.
Method Detail

booleanMatrix

public boolean[][] booleanMatrix()
Return a copy of the contained 2-D matrix. It is safe for the caller to modify the returned matrix.

Returns:
A 2-D boolean matrix.

convert

public static BooleanMatrixToken convert(Token token)
 throws IllegalActionException
Convert the specified token into an instance of BooleanMatrixToken. This method does lossless conversion. If the argument is already an instance of BooleanMatrixToken, it is returned without any change. Otherwise, if the argument is below BooleanMatrixToken in the type hierarchy, it is converted to an instance of BooleanMatrixToken or one of the subclasses of BooleanMatrixToken and returned. If none of the above conditions are met, an exception is thrown.

Parameters:
token - The token to be converted to a BooleanMatrixToken.
Returns:
A BooleanMatrixToken
Throws:
IllegalActionException - If the conversion cannot be carried out.

equals

public boolean equals(java.lang.Object object)
Return true if the argument is an instance of BooleanMatrixToken of the same dimensions and the corresponding elements of the matrices are equal.

Parameters:
object - An instance of Object.
Returns:
True if the argument is an instance of BooleanMatrixToken of the same dimensions and the corresponding elements of the matrices are equal.

getColumnCount

public int getColumnCount()
Return the number of columns in the matrix.

Specified by:
getColumnCount in class MatrixToken
Returns:
The number of columns in the matrix.

getElementAsToken

public Token getElementAsToken(int row,
 int column)
 throws java.lang.ArrayIndexOutOfBoundsException
Return the element of the matrix at the specified row and column in a BooleanToken.

Specified by:
getElementAsToken in class MatrixToken
Parameters:
row - The row index of the desired element.
column - The column index of the desired element.
Returns:
A BooleanToken containing the matrix element.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the specified row or column number is outside the range of the matrix.

getElementAt

public boolean getElementAt(int row,
 int column)
Return the element of the contained matrix at the specified row and column.

Parameters:
row - The row index of the desired element.
column - The column index of the desired element.
Returns:
The boolean at the specified matrix entry.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the specified row or column number is outside the range of the matrix.

getElementType

public Type getElementType()
Return the Type of the tokens contained in this matrix token.

Specified by:
getElementType in class MatrixToken
Returns:
BaseType.INT.

getRowCount

public int getRowCount()
Return the number of rows in the matrix.

Specified by:
getRowCount in class MatrixToken
Returns:
The number of rows in the matrix.

getType

public Type getType()
Return the type of this token.

Overrides:
getType in class Token
Returns:
BaseType.BOOLEAN_MATRIX

hashCode

public int hashCode()
Return a hash code value for this token. This method returns the number of elements with value true in the contained matrix.

Returns:
A hash code value for this token.

one

public Token one()
Return a new Token representing the left multiplicative identity. The returned token contains an identity matrix whose dimensions are the same as the number of rows of the matrix contained in this token.

Overrides:
one in class Token
Returns:
A new BooleanMatrixToken containing the left multiplicative identity.

oneRight

public Token oneRight()
Return a new Token representing the right multiplicative identity. The returned token contains an identity matrix whose dimensions are the same as the number of columns of the matrix contained in this token.

Overrides:
oneRight in class MatrixToken
Returns:
A new BooleanMatrixToken containing the right multiplicative identity.

zero

public Token zero()
Return a new Token representing the additive identity. The returned token contains a matrix whose elements are all zero, and the size of the matrix is the same as the matrix contained in this token.

Overrides:
zero in class Token
Returns:
A new IntMatrixToken containing the additive identity.

_createIdentity

protected boolean[][] _createIdentity(int dim)
Return an new identity matrix with the specified dimension. The matrix is square, so only one dimension specifier is needed.

Parameters:
dim - The dimension
Returns:
the identity matrix.

Overview Package Class Tree Deprecated Index Help
PREV CLASS NEXT CLASS FRAMES NO FRAMES All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

AltStyle によって変換されたページ (->オリジナル) /