Class cam.symfun.SymbolicFunction

java.lang.Object
   |
   +----cam.symfun.SymbolicFunction

public class SymbolicFunction
extends Object
An instance of class SymbolicFunction implements a double valued function (of an arbitrary number of double arguments) as specified by an initialization character string (i.e. symbolic initialization).

The syntax for the initialization string is that of general Java expressions. The initialization string can contain references to Java math functions (those in java.math) as well as symbolic constants. The method evaluate(...) is used to evaluate a SymbolicFuntion instance.

Samples

Version:
3/30/98
Author:
Chris Anderson (C) UCLA

Constructor Index

 o SymbolicFunction()
Creates a SymbolicFunction instance; use initialize(...) to specify the function.

Method Index

 o evaluate(double)
Evaluates a SymbolicFunction of one variable.
 o evaluate(double, double)
Evaluates a SymbolicFunction of two variables.
 o evaluate(double, double, double)
Evaluates a SymbolicFunctio of three variables.
 o evaluate(double, double, double, double)
Evaluates a SymbolicFunctio of four variables.
 o evaluate(double[])
Evaluates a SymbolicFunction of n variables.
 o getConstantCount()
Returns the number of symbolic constants in the function.
 o getConstantName(int)
Returns the name of the ith symbolic constant in the function.
 o getConstantValue(int)
Returns the value of the ith symbolic constant in the function.
 o getConstructorString()
Returns the string used to specify the function.
 o getVariableCount()
Returns the number of independent variables in the function.
 o getVariableName(int)
Returns the name of the ith independent variable in the function.
 o initialize(String)
Initializes the SymbolicFunction instance to a function of a single variable x.
 o initialize(String[], String)
Initializes the SymbolicFunction instance to a function of n variables.
 o initialize(String[], String[], double[], String)
Initializes the SymbolicFunction instance to a function of n variables with m symbolic constants, e.g.
 o main(String[])
 o setConstantValue(String, double)
Sets the value of the symbolic constant in the function.

Constructors

 o SymbolicFunction
 public SymbolicFunction()
Creates a SymbolicFunction instance; use initialize(...) to specify the function.

Methods

 o initialize
 public int initialize(String expressionString) throws Exception
Initializes the SymbolicFunction instance to a function of a single variable x.

Parameters:
expressionString - A java.lang.String specifying the function in the variable x
e.g. x^2 + 3.0 + cos(x).
Throws: Exception
If an exeception is thrown, the detail message of the exception (obtained with getMessage()) returns a string indicating the source of the initialization error.
 o initialize
 public int initialize(String V[],
                       String expressionString) throws Exception
Initializes the SymbolicFunction instance to a function of n variables.

Parameters:
V. - An array of java.lang.String of length n specifying the independent variables
e.g. for a function of two variables x and y V[0] = "x"; V[1] ="y";.
expressionString - A java.lang.String specifying the function in the independent variables.
Throws: Exception
If an exeception is thrown, the detail message of the exception (obtained with getMessage()) returns a string indicating the source of the initialization error.
 o initialize
 public int initialize(String V[],
                       String C[],
                       double Cvalues[],
                       String expressionString) throws Exception
Initializes the SymbolicFunction instance to a function of n variables with m symbolic constants, e.g. the function specified as a*x^2 + b*x + c is a function of one variable, x,and three symboic constants "a","b" and "c".

Parameters:
V. - An array of java.lang.String of length n specifying the independent variables
C. - An array of java.lang.String of length m specifying the symbolic constants
Cvalues. - An array of java.lang.double of length m specifying the initial values for the symbolic constants
expressionString - A java.lang.String specifying the function in the independent variables and symbolic constants.
Throws: Exception
If an exeception is thrown, the detail message of the exception (obtained with getMessage()) returns a string indicating the source of the initialization error.
 o evaluate
 public double evaluate(double x)
Evaluates a SymbolicFunction of one variable.

Returns:
double
 o evaluate
 public double evaluate(double x1,
                        double x2)
Evaluates a SymbolicFunction of two variables.

Returns:
double
 o evaluate
 public double evaluate(double x1,
                        double x2,
                        double x3)
Evaluates a SymbolicFunctio of three variables.

Returns:
double
 o evaluate
 public double evaluate(double x1,
                        double x2,
                        double x3,
                        double x4)
Evaluates a SymbolicFunctio of four variables.

Returns:
double
 o evaluate
 public double evaluate(double x[])
Evaluates a SymbolicFunction of n variables.

Parameters:
x - double array of size n containing values for evaluation.
Returns:
double
 o getConstructorString
 public String getConstructorString()
Returns the string used to specify the function.

 o getVariableCount
 public int getVariableCount()
Returns the number of independent variables in the function.

 o getVariableName
 public String getVariableName(int i)
Returns the name of the ith independent variable in the function. Indexing starts at 0.

 o getConstantCount
 public int getConstantCount()
Returns the number of symbolic constants in the function.

 o getConstantName
 public String getConstantName(int i)
Returns the name of the ith symbolic constant in the function. Indexing starts at 0.

 o getConstantValue
 public double getConstantValue(int i)
Returns the value of the ith symbolic constant in the function. Indexing starts at 0.

 o setConstantValue
 public void setConstantValue(String S,
                              double x)
Sets the value of the symbolic constant in the function. Indexing starts at 0. param S String name of the symbolic constant param x double value for the symbolic constant

 o main
 public static void main(String args[])