|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--org.PingOO.DLAI.lib.graph.ScanString
|
+--org.PingOO.DLAI.lib.graph.ParseFunction
This class will parse a function definition and solve it returning the value. The function may have upto 3 independent variables in it (x,y,z).
Known Bugs This class is not fool proof. If the answer is wrong then use the parenthesis to force the order of evaluation. The most likely place this will be needed is in the use of the power command. The exponent is not evaluated correctly if it begins with a unary operator.
| Field Summary | |
(package private) static int |
ACOS
|
(package private) static int |
ACOSH
|
(package private) static int |
ADD
|
(package private) static int |
ASIN
|
(package private) static int |
ASINH
|
(package private) static int |
ATAN
|
(package private) static int |
ATAN2
|
(package private) static int |
ATANH
|
(package private) static int |
AVOGADRO
|
(package private) static int |
BOLTZMAN
|
(package private) static int |
CHISQ
|
(package private) static int |
CHISQC
|
(package private) static int |
COMMA
|
(package private) static int |
COS
|
(package private) static int |
COSH
|
boolean |
debug
Debug variable. |
(package private) static int |
DIVIDE
|
(package private) static int |
E
|
(package private) static int |
ECHARGE
|
(package private) static int |
EMASS
|
(package private) static int |
ENDGROUP
|
(package private) static int |
ERF
|
(package private) static int |
ERFC
|
(package private) static int |
EXP
|
(package private) static int |
FAC
|
(package private) static int |
GAMMA
|
(package private) static int |
GASCONSTANT
|
(package private) static int |
GRAV
|
(package private) static int |
GRAVACC
|
(package private) static int |
GROUP
|
(package private) static int |
IGAM
|
(package private) static int |
IGAMC
|
private boolean |
independent_x
|
private boolean |
independent_y
|
private boolean |
independent_z
|
(package private) static int |
J0
|
(package private) static int |
J1
|
(package private) static int |
JN
|
(package private) static int |
LIGHTSPEED
|
(package private) static int |
LOG
|
(package private) static int |
LOG10
|
(package private) static int |
MULTIPLY
|
(package private) static int |
NORMAL
|
(package private) static int |
PI
|
(package private) static int |
PLANCK
|
(package private) static int |
PMASS
|
(package private) static int |
POISSON
|
(package private) static int |
POISSONC
|
(package private) static int |
POWER
|
(package private) static int |
RAD
|
(package private) static int |
RANDOM
|
(package private) static int |
REMAINDER
|
private Node |
root
|
(package private) static int |
SIN
|
(package private) static int |
SINH
|
(package private) static int |
SQRT
|
(package private) static int |
STEFANBOLTZ
|
(package private) static int |
SUBTRACT
|
(package private) static int |
TAN
|
(package private) static int |
TANH
|
private double |
x
|
(package private) static int |
X
|
private double |
y
|
(package private) static int |
Y
|
(package private) static int |
Y0
|
(package private) static int |
Y1
|
(package private) static int |
YN
|
private double |
z
|
(package private) static int |
Z
|
| Fields inherited from class org.PingOO.DLAI.lib.graph.ScanString |
buffer,
count,
EOS,
ERROR,
kwlength,
kwords,
NUMBER,
nval,
position,
string,
sval,
UNKNOWN |
| Constructor Summary | |
ParseFunction()
Instantiate the class |
|
ParseFunction(java.lang.String s)
Instantiate the class and define the string to parse. |
|
| Method Summary | |
private double |
evaluate(Node node)
|
private double |
evaluateIntrinsic(Node node)
|
private double |
evaluateOp(Node node)
|
double |
getResult()
Return the solution of the function if it has no independent values or they have already been set using the set methods |
double |
getResult(double x)
Return the solution of the function given the independent values |
double |
getResult(double x,
double y)
Return the solution of the function given the independent values |
double |
getResult(double x,
double y,
double z)
Return the solution of the function given the independent values |
double[] |
getResults(int n,
double[] x)
Return an array of solutions given an array of x values |
double[] |
getResults(int n,
double[] x,
double[] y)
Return an array of solutions given an array of x values and y values |
double[] |
getResults(int n,
double[] x,
double[] y,
double[] z)
Return an array of solutions given an array of x values, y values and z values. |
boolean[] |
getVariables()
Return a boolean array with index 0 true if the independent variable x was found in the function, index 1 true if y was found, and index 2 true if z was found. |
boolean |
parse()
Parse the previously set string |
boolean |
parse(java.lang.String s)
Parse the string. |
private int |
parseString(Node node)
|
private void |
reOrderNodes(Node node)
|
void |
setX(double x)
Set the value of the independent variable X. |
void |
setY(double y)
Set the value of the independent variable Y. |
void |
setZ(double z)
Set the value of the independent variable Z. |
| Methods inherited from class org.PingOO.DLAI.lib.graph.ScanString |
addKeyWord,
getKeyValue,
nextWord,
resetKeyWords,
setString |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
static final int GROUP
static final int ENDGROUP
static final int ADD
static final int SUBTRACT
static final int DIVIDE
static final int MULTIPLY
static final int LOG
static final int POWER
static final int PI
static final int E
static final int SIN
static final int COS
static final int TAN
static final int X
static final int Y
static final int Z
static final int ASIN
static final int ACOS
static final int ATAN
static final int RAD
static final int SQRT
static final int RANDOM
static final int LOG10
static final int EXP
static final int REMAINDER
static final int COMMA
static final int ATAN2
static final int J0
static final int J1
static final int JN
static final int SINH
static final int COSH
static final int TANH
static final int ASINH
static final int ACOSH
static final int ATANH
static final int Y0
static final int Y1
static final int YN
static final int FAC
static final int GAMMA
static final int ERF
static final int ERFC
static final int NORMAL
static final int POISSONC
static final int POISSON
static final int CHISQC
static final int CHISQ
static final int IGAM
static final int IGAMC
static final int BOLTZMAN
static final int ECHARGE
static final int EMASS
static final int PMASS
static final int GRAV
static final int PLANCK
static final int LIGHTSPEED
static final int STEFANBOLTZ
static final int AVOGADRO
static final int GASCONSTANT
static final int GRAVACC
private Node root
private boolean independent_x
private boolean independent_y
private boolean independent_z
private double x
private double y
private double z
public boolean debug
| Constructor Detail |
public ParseFunction()
public ParseFunction(java.lang.String s)
s - The string to be parsed.| Method Detail |
public boolean parse(java.lang.String s)
s - The string to parsepublic boolean parse()
public double getResult(double x,
double y,
double z)
throws java.lang.Exception
x - indpendent x valuey - indpendent y valuez - indpendent z value
public double getResult(double x,
double y)
throws java.lang.Exception
x - indpendent x valuey - indpendent y value
public double getResult(double x)
throws java.lang.Exception
x - indpendent x value
public double getResult()
throws java.lang.Exception
ParseFunction.setX(),
ParseFunction.setY(),
ParseFunction.setZ()
public double[] getResults(int n,
double[] x)
throws java.lang.Exception
n - number of values to process in the input arrayx - Array containing the x values.
public double[] getResults(int n,
double[] x,
double[] y)
throws java.lang.Exception
n - number of values to process in the input arrayx - Array containing the x values.y - Array containing the y values.
public double[] getResults(int n,
double[] x,
double[] y,
double[] z)
throws java.lang.Exception
n - number of values to process in the input arrayx - Array containing the x values.y - Array containing the y values.public boolean[] getVariables()
public void setX(double x)
public void setY(double y)
public void setZ(double z)
private int parseString(Node node)
private double evaluate(Node node)
throws java.lang.Exception
private double evaluateOp(Node node)
throws java.lang.Exception
private double evaluateIntrinsic(Node node)
throws java.lang.Exception
private void reOrderNodes(Node node)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||