jmathlib.core.tokens
Class LogicalToken

java.lang.Object
  extended by jmathlib.core.interpreter.RootObject
      extended by jmathlib.core.tokens.Token
          extended by jmathlib.core.tokens.OperandToken
              extended by jmathlib.core.tokens.DataToken
                  extended by jmathlib.core.tokens.LogicalToken
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ErrorCodes, TokenConstants

public class LogicalToken
extends DataToken

See Also:
Serialized Form

Field Summary
private  boolean[] values
          data
 
Fields inherited from class jmathlib.core.tokens.DataToken
dataType, noElem, sizeA, sizeX, sizeY
 
Fields inherited from class jmathlib.core.tokens.Token
priority
 
Fields inherited from interface jmathlib.core.constants.TokenConstants
ADDSUB_PRIORITY, AND_PRIORITY, ANDAND_PRIORITY, ASSIGN_PRIORITY, BRACKET_PRIORITY, COMPARE_PRIORITY, CONCAT, MATRIX, MULDIV_PRIORITY, OR_PRIORITY, OROR_PRIORITY, PARAMETER, POWER_PRIORITY, RELATION_PRIORITY, SINGLE, ttDelimiter, ttNotSet, ttOperand, ttOperator
 
Fields inherited from interface jmathlib.core.constants.ErrorCodes
ERR_BRACKET_OPEN, ERR_BRACKET_ORDER, ERR_FUNCTION_NOT_FOUND, ERR_FUNCTION_NOT_IMPLEMENTED, ERR_INSUFFICIENT_PARAMETERS, ERR_INVALID_PARAMETER, ERR_LVALUE_REQUIRED, ERR_MATRIX_SINGULAR, ERR_NOT_SQUARE_MATRIX, ERR_OPNOTSUPPORTED, ERR_TOO_MANY_PARAMETERS, ERR_USER_ERROR, ERR_VARIABLE_NOTDEFINED, OK, OK_FUNCTION_PROCESS
 
Constructor Summary
LogicalToken()
          empty logical token
LogicalToken(boolean _value)
           
LogicalToken(boolean[][] _values)
          Constructor taking the numbers value as two double[][]
LogicalToken(double _real)
          Constructor taking the numbers value as a pair of double values representing real and imaginary part
LogicalToken(int[] _sizeA, boolean[] _values)
          Constructor for multidimensional array
LogicalToken(int _dy, int _dx, boolean[] _values)
           
LogicalToken(java.lang.String _real)
          Constructor taking the numbers value as a string
 
Method Summary
 boolean equals(java.lang.Object arg)
          Check if two tokens are equal
 OperandToken evaluate(Token[] operands, GlobalValues globals)
          Evaluate the token.
 DoubleNumberToken getDoubleNumberToken()
          conversion into a number token
 OperandToken getElement(int n)
           
 OperandToken getElement(int y, int x)
           
 DataToken getElementSized(int y, int x)
           
 boolean getValue(int n)
           
 boolean[][] getValues()
           
 int index2n(int[] index)
          Convert from index to n (e.g. index={2,3,5} -> n)
 boolean isScalar()
           
 void setElement(int y, int x, OperandToken num)
           
 void setElement(int n, OperandToken num)
           
 void setSize(int dy, int dx)
          increase/decrease the size of the current DoubleNumberToken to size y*x
 void setValue(int[] index, boolean _value)
           
 void setValue(int n, boolean _value)
           
 void setValue(int y, int x, boolean _value)
          Set value at position y, x
 java.lang.String toString()
          return the number as a string
private  java.lang.String toString(int[] dim, int i)
           
private  java.lang.String toString2d(int[] nn)
           
 OperandToken transpose()
          calculate the transpose of an array
protected  int yx2n(int y, int x)
          Convert y,x points to element number n
 
Methods inherited from class jmathlib.core.tokens.DataToken
checkEqualDimensions, getDataType, getDimensions, getNumberOfElements, getSize, getSizeX, getSizeY
 
Methods inherited from class jmathlib.core.tokens.OperandToken
add, asArray, Children, ctranspose, derivative, divide, expand, factorial, integral, isLeaf, isNull, isNumeric, leftDivide, mpower, mPower, multiply, negate, power, scalarDivide, scalarLeftDivide, scalarMultiply, simplify, subst, subtract
 
Methods inherited from class jmathlib.core.tokens.Token
isDisplayResult, setDisplayResult, toMathMlString, toString
 
Methods inherited from class jmathlib.core.interpreter.RootObject
clone, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

values

private boolean[] values
data

Constructor Detail

LogicalToken

public LogicalToken()
empty logical token


LogicalToken

public LogicalToken(java.lang.String _real)
Constructor taking the numbers value as a string

Parameters:
_real - = the numbers real value as a string
_imaginary - = the numbers imaginary value as a string

LogicalToken

public LogicalToken(double _real)
Constructor taking the numbers value as a pair of double values representing real and imaginary part

Parameters:
_real - = the numbers real value as a double

LogicalToken

public LogicalToken(boolean _value)
Parameters:
_value -

LogicalToken

public LogicalToken(boolean[][] _values)
Constructor taking the numbers value as two double[][]

Parameters:
_real - = the numbers value as a 2D array of double
_imaginary - = the numbers value as a 2D array of double

LogicalToken

public LogicalToken(int _dy,
                    int _dx,
                    boolean[] _values)
Parameters:
_dy -
_dx -
_reValues -
_imValues -

LogicalToken

public LogicalToken(int[] _sizeA,
                    boolean[] _values)
Constructor for multidimensional array

Parameters:
_sizeA -
_reValues -
Method Detail

yx2n

protected int yx2n(int y,
                   int x)
Convert y,x points to element number n

Parameters:
y -
x -
Returns:
n

index2n

public int index2n(int[] index)
Convert from index to n (e.g. index={2,3,5} -> n)

Parameters:
-
Returns:

getElementSized

public DataToken getElementSized(int y,
                                 int x)
Overrides:
getElementSized in class DataToken

setSize

public void setSize(int dy,
                    int dx)
increase/decrease the size of the current DoubleNumberToken to size y*x

Overrides:
setSize in class DataToken
Parameters:
dy - number of rows
dx - number of columns

getElement

public OperandToken getElement(int y,
                               int x)
Overrides:
getElement in class DataToken
Parameters:
y -
x -
Returns:

getElement

public OperandToken getElement(int n)
Overrides:
getElement in class DataToken
Parameters:
n -
Returns:

setElement

public void setElement(int y,
                       int x,
                       OperandToken num)
Overrides:
setElement in class DataToken
Parameters:
y -
x -
num -

setElement

public void setElement(int n,
                       OperandToken num)
Overrides:
setElement in class DataToken
Parameters:
n -
num -

getValue

public boolean getValue(int n)
Parameters:
n -
Returns:

getValues

public boolean[][] getValues()
Returns:

setValue

public void setValue(int y,
                     int x,
                     boolean _value)
Set value at position y, x

Parameters:
y - = y position in matrix
x - = x position in matrix
real - = real value
imag - = imaginary value

setValue

public void setValue(int n,
                     boolean _value)
Parameters:
n -
_real -
_imag -

setValue

public void setValue(int[] index,
                     boolean _value)
Parameters:
index - multidimensional index
_real -
_imag -

getDoubleNumberToken

public DoubleNumberToken getDoubleNumberToken()
conversion into a number token

Returns:

toString

public java.lang.String toString()
return the number as a string

Specified by:
toString in class Token
Returns:
a string representation of the token

toString

private java.lang.String toString(int[] dim,
                                  int i)
Parameters:
dim -
i -
Returns:

toString2d

private java.lang.String toString2d(int[] nn)
Parameters:
nn -
Returns:

evaluate

public OperandToken evaluate(Token[] operands,
                             GlobalValues globals)
Evaluate the token. This causes it to return itself

Specified by:
evaluate in class Token
Parameters:
operands - = an array of RootObject containing the tokens operands
Returns:
the result of the token evaluation as a RootObject

equals

public boolean equals(java.lang.Object arg)
Check if two tokens are equal

Overrides:
equals in class java.lang.Object
Parameters:
arg - = the object to check against

transpose

public OperandToken transpose()
calculate the transpose of an array

Overrides:
transpose in class OperandToken
Returns:
the result as an OperandToken

isScalar

public boolean isScalar()
Returns:
true if this number token is a scalar (1*1 matrix)

FOOTER

BOTTOM