jmathlib.core.tokens.numbertokens
Class DoubleNumberToken

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.NumberToken
                      extended by jmathlib.core.tokens.numbertokens.DoubleNumberToken
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ErrorCodes, TokenConstants

public class DoubleNumberToken
extends NumberToken

See Also:
Serialized Form

Field Summary
static DoubleNumberToken j
          Constant value set to j
static DoubleNumberToken one
          Constant value set to 1
static DoubleNumberToken zero
          Constant value set to 0
 
Fields inherited from class jmathlib.core.tokens.NumberToken
IMAG, REAL
 
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
DoubleNumberToken()
          Constructor creating empty number token
DoubleNumberToken(double _value)
          Constructor creating a scalar taking the numbers value as a double
DoubleNumberToken(double[][] _values)
          Constructor taking the numbers value as a double[][]
DoubleNumberToken(double[][][] _values)
          Constructor taking the numbers value as a double[][][]
DoubleNumberToken(double[][] _real, double[][] _imaginary)
          Constructor taking the numbers value as two double[][]
DoubleNumberToken(double _real, double _imaginary)
          Constructor taking the numbers value as a pair of double values representing real and imaginary part
DoubleNumberToken(int[] _sizeA, double[] _reValues, double[] _imValues)
          Constructor for multidimensional array
DoubleNumberToken(int _dy, int _dx, double[] _reValues, double[] _imValues)
           
DoubleNumberToken(java.lang.String _real, java.lang.String _imaginary)
          Constructor taking the numbers value as a string
 
Method Summary
 OperandToken add(OperandToken arg)
          add arg to this object for a number token
 double arg(int y, int x)
          calculate the arg of the complex number at y, x
 OperandToken conjugate()
          Complex function - calculates the complex conjugate of the number
 OperandToken ctranspose()
          calculate the conjugate transpose of a matrix
 double[] divide(double[] arg1, double[] arg2)
          divide two complex numbers and return a complex number again, pay special attention to infinity and not a number
 OperandToken divide(OperandToken arg)
          divide this object by arg for a number token
 boolean equals(java.lang.Object arg)
          Check if two tokens are equal
 OperandToken factorial()
          Standard functions - calculates the factorial of the number
 double factorial(double amount)
          Calulates the factorial of a real value
 OperandToken getElement(int n)
           
 DataToken getElementSized(int y, int x)
          return a new Number Token of size y*x
 int getIntValue(int y, int x)
           
 double[][] getReValues()
           
 double getValueAbs(int y, int x)
           
 double getValueArg(int y, int x)
           
 double[] getValueComplex(int n)
           
 double[] getValueComplex(int y, int x)
           
 double getValueIm()
           
 double getValueIm(int n)
           
 double getValueIm(int[] index)
           
 double getValueIm(int y, int x)
           
 double getValueRe()
           
 double getValueRe(int n)
           
 double getValueRe(int[] index)
           
 double getValueRe(int y, int x)
           
 double[][] getValuesIm()
           
 double[][] getValuesRe()
           
 boolean isComplex()
           
 boolean isImaginary()
           
 boolean isNull()
          Checks if this operand is zero
 boolean isReal()
           
 OperandToken leftDivide(OperandToken arg)
          left divide
 OperandToken mPower(OperandToken arg)
          The value to raise it to the matrix power of
 double[] multiply(double[] arg1, double[] arg2)
          Multiplies two complex numbers
 OperandToken multiply(OperandToken arg)
          multiply arg by this object for a number token
 OperandToken negate()
          standard function - returns the negative of the number
 OperandToken power(OperandToken arg)
          Raise this object to the power of arg
 OperandToken scalarDivide(OperandToken arg)
          scalar divide arg by this object for a number token
 OperandToken scalarLeftDivide(OperandToken arg)
          scalar left divide
 OperandToken scalarMultiply(OperandToken arg)
          scalar multiply arg by this object for a number token
 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, double _real, double _imag)
           
 void setValue(int n, double _real, double _imag)
           
 void setValue(int y, int x, double _real, double _imag)
          Set value at position y, x
 void setValueComplex(int n, double[] _value)
           
 void setValueComplex(int y, int x, double[] _value)
          Set value at position y, x
 OperandToken subtract(OperandToken arg)
          subtract arg from this object for a number token
 java.lang.String toString()
          return the number as a string
 java.lang.String toString(double[] _values)
          create string representation of (complex) double values
 OperandToken transpose()
          calculate the transpose of a matrix
 
Methods inherited from class jmathlib.core.tokens.NumberToken
evaluate, getElement, index2n, isNumeric, isScalar, setElement, yx2n
 
Methods inherited from class jmathlib.core.tokens.DataToken
checkEqualDimensions, getDataType, getDimensions, getNumberOfElements, getSize, getSizeX, getSizeY
 
Methods inherited from class jmathlib.core.tokens.OperandToken
asArray, Children, derivative, expand, integral, isLeaf, mpower, simplify, subst
 
Methods inherited from class jmathlib.core.tokens.Token
isDisplayResult, setDisplayResult, toMathMlString
 
Methods inherited from class jmathlib.core.interpreter.RootObject
clone, getContextList, getDebug, getFunctionManager, getGlobalVariables, getGraphicsManager, getInterpreter, getPluginsManager, getVariable, getVariables, getWorkingDirectory, setConstants, setDebug, setWorkingDirectory, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

one

public static final DoubleNumberToken one
Constant value set to 1


zero

public static final DoubleNumberToken zero
Constant value set to 0


j

public static final DoubleNumberToken j
Constant value set to j

Constructor Detail

DoubleNumberToken

public DoubleNumberToken()
Constructor creating empty number token


DoubleNumberToken

public DoubleNumberToken(double _value)
Constructor creating a scalar taking the numbers value as a double

Parameters:
_value - = the numbers value as a double

DoubleNumberToken

public DoubleNumberToken(double[][] _values)
Constructor taking the numbers value as a double[][]

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

DoubleNumberToken

public DoubleNumberToken(java.lang.String _real,
                         java.lang.String _imaginary)
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

DoubleNumberToken

public DoubleNumberToken(double _real,
                         double _imaginary)
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
_imaginary - = the numbers imaginary value as a double

DoubleNumberToken

public DoubleNumberToken(double[][] _real,
                         double[][] _imaginary)
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

DoubleNumberToken

public DoubleNumberToken(double[][][] _values)
Constructor taking the numbers value as a double[][][]

Parameters:
_values - = the numbers value as a 3D array of double

DoubleNumberToken

public DoubleNumberToken(int _dy,
                         int _dx,
                         double[] _reValues,
                         double[] _imValues)
Parameters:
_dy -
_dx -
_reValues -
_imValues -

DoubleNumberToken

public DoubleNumberToken(int[] _sizeA,
                         double[] _reValues,
                         double[] _imValues)
Constructor for multidimensional array

Parameters:
_sizeA -
_reValues -
_imValues -
Method Detail

getElementSized

public DataToken getElementSized(int y,
                                 int x)
return a new Number Token of size y*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

getValueRe

public double getValueRe()
Returns:
the real value of the first number

getValueRe

public double getValueRe(int y,
                         int x)
Parameters:
y -
x -
Returns:
the real value of the number at position y, x

getValueRe

public double getValueRe(int[] index)
Parameters:
index -
Returns:

getValueRe

public double getValueRe(int n)
Parameters:
n -
Returns:

getIntValue

public int getIntValue(int y,
                       int x)
Returns:
the real value of the number at position y, x as an integer

getValueIm

public double getValueIm()
Returns:
the imaginary value of the first number

getValueIm

public double getValueIm(int y,
                         int x)
Returns:
the imaginary value of the number at position y, x

getValueIm

public double getValueIm(int[] index)
Parameters:
index -
Returns:

getValueIm

public double getValueIm(int n)
Parameters:
n -
Returns:

getValueAbs

public double getValueAbs(int y,
                          int x)
Returns:
the absolute value of the number at position y, x

getValueArg

public double getValueArg(int y,
                          int x)
Returns:
the angle of the number at position y, x in radians

getValuesRe

public double[][] getValuesRe()
Returns:
the real values of the number

getReValues

public double[][] getReValues()
Returns:
the real values of the number

getValuesIm

public double[][] getValuesIm()
Returns:
the imaginary values of the number

getElement

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

setElement

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

getValueComplex

public double[] getValueComplex(int y,
                                int x)
Parameters:
y - = y position in matrix
x - = x position in matrix
Returns:
an array of double representing the element at y,x

getValueComplex

public double[] getValueComplex(int n)
Parameters:
n -
Returns:

setValueComplex

public void setValueComplex(int n,
                            double[] _value)
Parameters:
n -
_value -

setValueComplex

public void setValueComplex(int y,
                            int x,
                            double[] _value)
Set value at position y, x

Parameters:
y - = y position in matrix
x - = x position in matrix
_value - = the value to set it to as an array of doubles

setValue

public void setValue(int y,
                     int x,
                     double _real,
                     double _imag)
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,
                     double _real,
                     double _imag)
Parameters:
n -
_real -
_imag -

setValue

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

toString

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

Overrides:
toString in class NumberToken
Returns:
a string representation of the token

toString

public java.lang.String toString(double[] _values)
create string representation of (complex) double values

Parameters:
_values[]={REAL,IMAG} - real and imaginary part of number

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

arg

public double arg(int y,
                  int x)
calculate the arg of the complex number at y, x


add

public OperandToken add(OperandToken arg)
add arg to this object for a number token

Overrides:
add in class OperandToken
Parameters:
= - the value to add to it
Returns:
the result as an OperandToken

subtract

public OperandToken subtract(OperandToken arg)
subtract arg from this object for a number token

Overrides:
subtract in class OperandToken
Parameters:
= - the value to subtract
Returns:
the result as an OperandToken

power

public OperandToken power(OperandToken arg)
Raise this object to the power of arg

Overrides:
power in class OperandToken
Parameters:
= - the value to raise it to the power of
Returns:
the result as an OperandToken

mPower

public OperandToken mPower(OperandToken arg)
The value to raise it to the matrix power of

Overrides:
mPower in class OperandToken
Parameters:
arg -
Returns:

multiply

public OperandToken multiply(OperandToken arg)
multiply arg by this object for a number token

Overrides:
multiply in class OperandToken
Parameters:
arg - = the value to multiply it by
Returns:
the result as an OperandToken

multiply

public double[] multiply(double[] arg1,
                         double[] arg2)
Multiplies two complex numbers

Parameters:
arg1 - = the first complex number as an array of double
arg2 - = the second complex number as an array of double
Returns:
the result as an array of double

divide

public OperandToken divide(OperandToken arg)
divide this object by arg for a number token

Overrides:
divide in class OperandToken
Parameters:
arg - = the value to divide it by
Returns:
the result as an OperandToken

divide

public double[] divide(double[] arg1,
                       double[] arg2)
divide two complex numbers and return a complex number again, pay special attention to infinity and not a number

Parameters:
arg1 - = the first complex number as an array of double
arg2 - = the second complex number as an array of double
Returns:
the result as an array of double

scalarMultiply

public OperandToken scalarMultiply(OperandToken arg)
scalar multiply arg by this object for a number token

Overrides:
scalarMultiply in class OperandToken
Parameters:
arg - = the amount to multiply it by
Returns:
the result as an OperandToken

scalarDivide

public OperandToken scalarDivide(OperandToken arg)
scalar divide arg by this object for a number token

Overrides:
scalarDivide in class OperandToken
Parameters:
arg - = the amount to divide it by
Returns:
the result as an OperandToken

leftDivide

public OperandToken leftDivide(OperandToken arg)
left divide

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

scalarLeftDivide

public OperandToken scalarLeftDivide(OperandToken arg)
scalar left divide

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

transpose

public OperandToken transpose()
calculate the transpose of a matrix

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

ctranspose

public OperandToken ctranspose()
calculate the conjugate transpose of a matrix

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

negate

public OperandToken negate()
standard function - returns the negative of the number

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

factorial

public OperandToken factorial()
Standard functions - calculates the factorial of the number

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

factorial

public double factorial(double amount)
Calulates the factorial of a real value

Parameters:
amount - = the number to calc the factorial of
Returns:
the result as a double

conjugate

public OperandToken conjugate()
Complex function - calculates the complex conjugate of the number


isNull

public boolean isNull()
Checks if this operand is zero

Overrides:
isNull in class OperandToken
Returns:
true if this number == 0 or that all values are 0 for a matrix

isReal

public boolean isReal()
Returns:
true if this number token is a real matrix, without an imaginary part

isImaginary

public boolean isImaginary()
Returns:
true if this number token is an imaginary matrix, without a real part

isComplex

public boolean isComplex()
Returns:
true if this number token is a complex matrix with both real and imaginary parts