Class graph.ParseFunction
All Packages  Class Hierarchy  This Package  Previous  Next  Index
  Class graph.ParseFunction
java.lang.Object
   |
   +----graph.ScanString
           |
           +----graph.ParseFunction
  -  public class ParseFunction
  -  extends ScanString
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.
List of recognised commands
  -  ( ) parenthesis , comma
  
-  +, -, unary -, unary +
  
-  *, /
  
-  ^ (raise to a power)
  
-  pi, e, All the constants in class SpecialFunction
  
-  log
  
-  sin, cos, tan
  
-  asin, acos, atan
  
-  sqrt
  
-  rand
  
-  exp
  
-  remainder
  
-  atan2
  
-  All the functions in class SpecialFunction
  
-  Independent variables x,y,z
  
-  Scientific notation using "e", "E", "d", "D".
  -  Version:
  
-  1.8, 1996/08/12 23:37:08
  
-  Author:
  
-  Leigh Brookshaw
   
  -   debug debug
-  Debug variable.
   
  -   ParseFunction() ParseFunction()
-  Instantiate the class
  
-   ParseFunction(String) ParseFunction(String)
-  Instantiate the class and define the string to parse.
   
  -   getResult() getResult()
-  Return the solution of the function if it has no independent values
or they have already been set using the set methods
  
-   getResult(double) getResult(double)
-  Return the solution of the function given the independent values
  
-   getResult(double, double) getResult(double, double)
-  Return the solution of the function given the independent values
  
-   getResult(double, double, double) getResult(double, double, double)
-  Return the solution of the function given the independent values
  
-   getResults(int, double[]) getResults(int, double[])
-  Return an array of solutions given an array of x values
  
-   getResults(int, double[], double[]) getResults(int, double[], double[])
-  Return an array of solutions given an array of x values and y values
  
-   getResults(int, double[], double[], double[]) getResults(int, double[], double[], double[])
-  Return an array of solutions given an array of x values, y values
and z values.
  
-   getVariables() 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.
  
-   parse() parse()
-  Parse the previously set string
  
-   parse(String) parse(String)
-  Parse the string.
  
-   setX(double) setX(double)
-  Set the value of the independent variable X.
  
-   setY(double) setY(double)
-  Set the value of the independent variable Y.
  
-   setZ(double) setZ(double)
-  Set the value of the independent variable Z.
   
 debug
debug
  public boolean debug
  -  Debug variable. If set true debug output is printed.
   
 ParseFunction
ParseFunction
  public ParseFunction()
  -  Instantiate the class
 ParseFunction
ParseFunction
  public ParseFunction(String s)
  -  Instantiate the class and define the string to parse.
  
    -  Parameters:
    
-  s - The string to be parsed.
  
 
   
 parse
parse
  public boolean parse(String s)
  -  Parse the string.
  
    -  Parameters:
    
-  s - The string to parse
    
-  Returns:
    
-  true if it was successful, false otherwise.
  
 
 parse
parse
  public boolean parse()
  -  Parse the previously set string
  
    -  Returns:
    
-  true if it was successful, false otherwise.
  
 
 getResult
getResult
  public double getResult(double x,
                          double y,
                          double z) throws Exception
  -  Return the solution of the function given the independent values
  
    -  Parameters:
    
-  x - indpendent x value
    -  y - indpendent y value
    -  z - indpendent z value
    
-  Returns:
    
-  solution of the function
  
 
 getResult
getResult
  public double getResult(double x,
                          double y) throws Exception
  -  Return the solution of the function given the independent values
  
    -  Parameters:
    
-  x - indpendent x value
    -  y - indpendent y value
    
-  Returns:
    
-  solution of the function
  
 
 getResult
getResult
  public double getResult(double x) throws Exception
  -  Return the solution of the function given the independent values
  
    -  Parameters:
    
-  x - indpendent x value
    
-  Returns:
    
-  solution of the function
  
 
 getResult
getResult
  public double getResult() throws Exception
  -  Return the solution of the function if it has no independent values
or they have already been set using the set methods
  
    -  Returns:
    
-  solution of the function
    
-  See Also:
    
-  setX(), setY(), setZ()
  
 
 getResults
getResults
  public double[] getResults(int n,
                             double x[]) throws Exception
  -  Return an array of solutions given an array of x values
  
    -  Parameters:
    
-  n - number of values to process in the input array
    -  x - Array containing the x values.
    
-  Returns:
    
-  Array containing the solutions.
    
-  Throws: Exception
    
-  Generic exception if the array index n<=0, or x is null. 
 
 getResults
getResults
  public double[] getResults(int n,
                             double x[],
                             double y[]) throws Exception
  -  Return an array of solutions given an array of x values and y values
  
    -  Parameters:
    
-  n - number of values to process in the input array
    -  x - Array containing the x values.
    -  y - Array containing the y values.
    
-  Returns:
    
-  Array containing the solutions.
    
-  Throws: Exception
    
-  Generic exception if the array index n<=0, or x is null, or y is null. 
 
 getResults
getResults
  public double[] getResults(int n,
                             double x[],
                             double y[],
                             double z[]) throws Exception
  -  Return an array of solutions given an array of x values, y values
and z values.
  
    -  Parameters:
    
-  n - number of values to process in the input array
    -  x - Array containing the x values.
    -  y - Array containing the y values.
    
-  Returns:
    
-  Array containing the solutions.
    
-  Throws: Exception
    
-  Generic exception if the array index n<=0, or x is null, or y is null, or z is null. 
 
 getVariables
getVariables
  public 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.
 setX
setX
  public void setX(double x)
  -  Set the value of the independent variable X.
 setY
setY
  public void setY(double y)
  -  Set the value of the independent variable Y.
 setZ
setZ
  public void setZ(double z)
  -  Set the value of the independent variable Z.
All Packages  Class Hierarchy  This Package  Previous  Next  Index