|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.data.Token
ptolemy.data.MatrixToken
Abstract base class for tokens that contain a 2-D matrix. This class defines methods for type conversion among different matrix tokens. The implementation in this base class just throws an exception. Derived classes should override those methods where the corresponding conversion can be achieved without loss of information.
| Yellow (wbwu) |
| Green (neuendor) |
| Field Summary | |
static int |
DO_COPY
A constant indicating to constructors that contents of an argument 2-D matrix should be copied. |
static int |
DO_NOT_COPY
A constant indicating to constructors not to copy the contents of an argument 2-D matrix, but instead to just copy the pointer to the matrix. |
| Constructor Summary | |
MatrixToken()
|
|
| Method Summary | |
protected MatrixToken |
_add(MatrixToken rightArgument)
Return a new token whose value is the value of the argument Token added to the value of this Token. |
protected MatrixToken |
_addElement(Token rightArgument)
Return a new token whose value is the value of the argument Token added to the value of each element of this Token. |
protected MatrixToken |
_divideElement(Token rightArgument)
Return a new token whose elements are the result of dividing the elements of this token by the argument. |
protected BooleanToken |
_isCloseTo(MatrixToken token,
double distance)
Test whether the value of this token is close to the first argument, where "close" means that the distance between their elements is less than or equal to the second argument. |
protected BooleanToken |
_isEqualTo(MatrixToken rightArgument)
Test for equality of the values of this Token and the argument Token. |
protected MatrixToken |
_moduloElement(Token rightArgument)
Return a new token whose elements are the modulo of the elements of this token by the argument. |
protected MatrixToken |
_multiply(MatrixToken rightArgument)
Return a new token whose value is the value of this token multiplied by the value of the argument token. |
protected MatrixToken |
_multiplyElement(Token rightArgument)
Return a new token whose value is the value of this token multiplied by the value of the argument scalar token. |
protected MatrixToken |
_subtract(MatrixToken rightArgument)
Return a new token whose value is the value of the argument token subtracted from the value of this token. |
protected MatrixToken |
_subtractElement(Token rightArgument)
Return a new token whose value is the value of the argument Token subtracted from the value of each element of this Token. |
protected MatrixToken |
_subtractElementReverse(Token rightArgument)
Return a new token whose value is the value of each element of this Token subtracted from the value the argument Token. |
Token |
add(Token rightArgument)
Return a new token whose value is the sum of this token and the argument. |
Token |
addReverse(Token leftArgument)
Return a new token whose value is the sum of this token and the argument. |
static MatrixToken |
arrayToMatrix(Token[] tokens,
int rows,
int columns)
Create a new instance of a MatrixToken subclass with the given number of rows and columns. |
static MatrixToken |
arrayToMatrix(Type type,
Token[] tokens,
int rows,
int columns)
Create a new instance of a MatrixToken subclass with the given element type and number of rows and columns. |
static Type |
arrayToMatrixReturnType(Type type1,
Type type2,
Type type3)
Return the (exact) return type of the arrayToMatrix function above. |
Complex[][] |
complexMatrix()
Return a copy of the content of this token as a 2-D Complex matrix. |
static MatrixToken |
create(Token[] tokens,
int rows,
int columns)
Deprecated. Use arrayToMatrix() instead. |
static Token[] |
createSequence(Token start,
Token increment,
int length)
Create an array of tokens of the given length. |
static Type |
createSequenceReturnType(Type type1,
Type type2,
Type type3)
Return the (exact) return type of the createSequence function above. |
static Token[] |
createTokenSequence(Token start,
Token increment,
int length)
Deprecated. Use createSequence() instead. |
static int |
determineSequenceLength(ScalarToken start,
ScalarToken increment,
ScalarToken end)
Count the number of tokens differing by the given increment that fit in a range between the given start token and the given end token. |
Token |
divide(Token rightArgument)
Return a new token whose value is the value of this token divided by the value of the argument token. |
Token |
divideReverse(Token leftArgument)
Return a new token whose value is the value of the argument token divided by the value of this token. |
double[][] |
doubleMatrix()
Return the content of this token as a 2-D double matrix. |
abstract int |
getColumnCount()
Return the number of columns of the matrix. |
abstract Token |
getElementAsToken(int row,
int column)
Return the element of the matrix at the specified row and column wrapped in a token. |
abstract Type |
getElementType()
Return the Type of the tokens contained in this matrix token. |
abstract int |
getRowCount()
Return the number of rows of the matrix. |
int[][] |
intMatrix()
Return the content of this token as a 2-D integer matrix. |
BooleanToken |
isCloseTo(Token rightArgument,
double epsilon)
Test whether the value of this Token is close to the argument Token. |
BooleanToken |
isEqualTo(Token rightArgument)
Test for equality of the values of this Token and the argument Token. |
long[][] |
longMatrix()
Return the content of this matrix as a 2-D long matrix. |
static ArrayToken |
matrixToArray(MatrixToken matrix)
Create a new instance of ArrayToken that contains the values in the specified matrix. |
static Type |
matrixToArrayReturnType(Type type)
Return the (exact) return type of the toArray function above. |
Token |
modulo(Token rightArgument)
Return a new token whose value is this token modulo the value of the argument token. |
Token |
moduloReverse(Token leftArgument)
Return a new token whose value is the value of the argument token modulo the value of this token. |
Token |
multiply(Token rightArgument)
Return a new token whose value is the value of this token multiplied by the value of the argument token. |
Token |
multiplyReverse(Token leftArgument)
Return a new token whose value is the value of the argument token multiplied by the value of this token. |
Token |
oneRight()
Return a new Token representing the right multiplicative identity. |
Token |
subtract(Token rightArgument)
Return a new token whose value is the value of the argument token subtracted from the value of this token. |
Token |
subtractReverse(Token leftArgument)
Return a new token whose value is the value of this token subtracted from the value of the argument token. |
ArrayToken |
toArray()
Return an ArrayToken containing the all the values of this matrix token. |
static Type |
toArrayReturnType(Type type)
Return the (exact) return type of the toArray function above. |
java.lang.String |
toString()
Return the value of this token as a string that can be parsed by the expression language to recover a token with the same value. |
| Methods inherited from class ptolemy.data.Token |
getType, isCloseTo, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, one, pow, zero, zeroReturnType |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int DO_COPY
public static final int DO_NOT_COPY
| Constructor Detail |
public MatrixToken()
| Method Detail |
public Token add(Token rightArgument)
throws IllegalActionException
add in class TokenrightArgument - The token to add to this token.
IllegalActionException - If the argument token
and this token are of incomparable types, or the operation
does not make sense for the given types.
public Token addReverse(Token leftArgument)
throws IllegalActionException
addReverse in class TokenleftArgument - The token to add this token to.
IllegalActionException - If the argument token
is not of a type that can be added to this token, or
the units of this token and the argument token are not the same.
public static MatrixToken arrayToMatrix(Token[] tokens,
int rows,
int columns)
throws IllegalActionException
IllegalActionException - If no type exists for the
matrix token, or the array of tokens is not the right size, or
the array is null.
public static MatrixToken arrayToMatrix(Type type,
Token[] tokens,
int rows,
int columns)
throws IllegalActionException
IllegalActionException - If the type is not possible,
or the array of tokens is not the right size, or the array is
null.
public static Type arrayToMatrixReturnType(Type type1,
Type type2,
Type type3)
throws IllegalActionException
type1 - The type of the first argument to the
corresponding function.type2 - The type of the second argument to the
corresponding function.type3 - The type of the third argument to the
corresponding function.
IllegalActionException
public Complex[][] complexMatrix()
throws IllegalActionException
IllegalActionException - If the token cannot be represented
as requested (always thrown in this base class).
public static MatrixToken create(Token[] tokens,
int rows,
int columns)
throws IllegalActionException
IllegalActionException - If no type exists for the
matrix token, or the array of tokens is not the right size, or
the array is null.
public static Token[] createSequence(Token start,
Token increment,
int length)
throws IllegalActionException
start - The value of the first element of the returned array.increment - The difference between elements in the array.length - The size of the array to create, which must not be
negative.
IllegalActionException - If the length is negative, or
tokens of the given type cannot be added together.
public static Type createSequenceReturnType(Type type1,
Type type2,
Type type3)
throws IllegalActionException
type1 - The type of the first argument to the
corresponding function.type2 - The type of the second argument to the
corresponding function.type3 - The type of the third argument to the
corresponding function.
IllegalActionException
public static Token[] createTokenSequence(Token start,
Token increment,
int length)
throws IllegalActionException
start - The value of the first element of the returned array.increment - The difference between elements in the array.length - The size of the array to create, which must not be
negative.
IllegalActionException - If the length is negative, or
tokens of the given type cannot be added together.
public static int determineSequenceLength(ScalarToken start,
ScalarToken increment,
ScalarToken end)
throws IllegalActionException
IllegalActionException - If the length of the
sequence cannot be determined, or the tokens provided do not
support the zero, isEqualTo, isLessThan, add, divide, or
subtract operations, or is not convertible to a double token.
public final Token divide(Token rightArgument)
throws IllegalActionException
divide in class TokenrightArgument - The token that divides this token.
IllegalActionException - If the operation
does not make sense for the given types.
public Token divideReverse(Token leftArgument)
throws IllegalActionException
divideReverse in class TokenleftArgument - The token to be divided by the value of this token.
IllegalActionException - If the argument token and
this token are of incomparable types, or the operation does
not make sense for the given types.
public double[][] doubleMatrix()
throws IllegalActionException
IllegalActionException - If the token cannot be represented
as requested (always thrown in this base class).public abstract int getColumnCount()
public abstract Token getElementAsToken(int row,
int column)
throws java.lang.ArrayIndexOutOfBoundsException
row - The row index of the desired element.column - The column index of the desired element.
java.lang.ArrayIndexOutOfBoundsException - If the specified
row or column number is outside the range of the matrix.public abstract Type getElementType()
public abstract int getRowCount()
public int[][] intMatrix()
throws IllegalActionException
IllegalActionException - If the token cannot be represented
as requested (always thrown in this base class).
public final BooleanToken isCloseTo(Token rightArgument,
double epsilon)
throws IllegalActionException
isCloseTo in class TokenrightArgument - The token to test closeness of this token with.epsilon - The value that we use to determine whether two
tokens are close. In this base class, the epsilon argument is
ignored.
IllegalActionException - If the argument token is
not of a type that can be compared with this token.isEqualTo(ptolemy.data.Token)
public final BooleanToken isEqualTo(Token rightArgument)
throws IllegalActionException
isEqualTo in class TokenrightArgument - The token with which to test equality.
IllegalActionException - If this method is not
supported by the derived class.isCloseTo(ptolemy.data.Token, double)
public long[][] longMatrix()
throws IllegalActionException
IllegalActionException - If the token cannot be represented
as requested (always thrown in this base class).public static ArrayToken matrixToArray(MatrixToken matrix)
public static Type matrixToArrayReturnType(Type type)
type - The type of the argument to the corresponding function.
public final Token modulo(Token rightArgument)
throws IllegalActionException
modulo in class TokenrightArgument - The token that performs modulo on this token.
IllegalActionException - If the operation
does not make sense for the given types.
public final Token moduloReverse(Token leftArgument)
throws IllegalActionException
moduloReverse in class TokenleftArgument - The token to apply modulo to by the value
of this token.
IllegalActionException - If the the operation does
not make sense for the given types.
public final Token multiply(Token rightArgument)
throws IllegalActionException
multiply in class TokenrightArgument - The token to multiply this token by.
IllegalActionException - If the argument token
and this token are of incomparable types, or the operation
does not make sense for the given types.
public final Token multiplyReverse(Token leftArgument)
throws IllegalActionException
multiplyReverse in class TokenleftArgument - The token to be multiplied by the value of
this token.
IllegalActionException - If the argument token
is not of a type that can be multiplied by this token.
public Token oneRight()
throws IllegalActionException
IllegalActionException - If this method is not
supported by the derived class.
public final Token subtract(Token rightArgument)
throws IllegalActionException
subtract in class TokenrightArgument - The token to subtract from this token.
IllegalActionException - If the argument token
and this token are of incomparable types, or the operation
does not make sense for the given types.
public final Token subtractReverse(Token leftArgument)
throws IllegalActionException
subtractReverse in class TokenleftArgument - The token to subtract this token from.
IllegalActionException - If the argument token is not
of a type that can be subtracted to this token, or the units
of this token and the argument token are not the same.public ArrayToken toArray()
public static Type toArrayReturnType(Type type)
type - The type of the argument to the corresponding function.
public java.lang.String toString()
toString in class Token
protected MatrixToken _add(MatrixToken rightArgument)
throws IllegalActionException
rightArgument - The token to add to this token.
IllegalActionException - If this method is not
supported by the derived class.
protected MatrixToken _addElement(Token rightArgument)
throws IllegalActionException
rightArgument - The token to add to this token.
IllegalActionException - If this operation is not
supported by the derived class.
protected MatrixToken _divideElement(Token rightArgument)
throws IllegalActionException
rightArgument - The token that divides this token.
IllegalActionException - If this operation is not
supported by the derived class.
protected BooleanToken _isCloseTo(MatrixToken token,
double distance)
throws IllegalActionException
token - The matrix token to compare to this token.distance - The specified distance.
IllegalActionException - If a derived class throws it.
protected BooleanToken _isEqualTo(MatrixToken rightArgument)
throws IllegalActionException
rightArgument - The token to compare to this token.
IllegalActionException - If this method is not
supported by a derived class.
protected MatrixToken _moduloElement(Token rightArgument)
throws IllegalActionException
rightArgument - The token that performs modulo on this token.
IllegalActionException - If this operation is not
supported by the derived class.
protected MatrixToken _multiply(MatrixToken rightArgument)
throws IllegalActionException
rightArgument - The token to multiply this token by.
IllegalActionException - If this method is not
supported by the derived class.
protected MatrixToken _multiplyElement(Token rightArgument)
throws IllegalActionException
rightArgument - The token to multiply this token by.
IllegalActionException - If this method is not
supported by the derived class.
protected MatrixToken _subtract(MatrixToken rightArgument)
throws IllegalActionException
rightArgument - The token to subtract from this token.
IllegalActionException - If this method is not
supported by the derived class.
protected MatrixToken _subtractElement(Token rightArgument)
throws IllegalActionException
rightArgument - The token to subtract from this token.
IllegalActionException - If this operation is not
supported by the derived class.
protected MatrixToken _subtractElementReverse(Token rightArgument)
throws IllegalActionException
rightArgument - The token to subtract this token from.
IllegalActionException - If this operation is not
supported by the derived class.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||