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
-
SymbolicFunction()
- Creates a SymbolicFunction instance; use initialize(...) to specify the function.
-
evaluate(double)
- Evaluates a SymbolicFunction of one variable.
-
evaluate(double, double)
- Evaluates a SymbolicFunction of two variables.
-
evaluate(double, double, double)
- Evaluates a SymbolicFunctio of three variables.
-
evaluate(double, double, double, double)
- Evaluates a SymbolicFunctio of four variables.
-
evaluate(double[])
- Evaluates a SymbolicFunction of n variables.
-
getConstantCount()
- Returns the number of symbolic constants in the function.
-
getConstantName(int)
- Returns the name of the ith symbolic constant in the function.
-
getConstantValue(int)
- Returns the value of the ith symbolic constant in the function.
-
getConstructorString()
- Returns the string used to specify the function.
-
getVariableCount()
- Returns the number of independent variables in the function.
-
getVariableName(int)
- Returns the name of the ith independent variable in the function.
-
initialize(String)
- Initializes the SymbolicFunction instance to a function of a single variable x.
-
initialize(String[], String)
- Initializes the SymbolicFunction instance to a function of n variables.
-
initialize(String[], String[], double[], String)
- Initializes the SymbolicFunction instance to a function of n variables with m symbolic constants, e.g.
-
main(String[])
-
-
setConstantValue(String, double)
- Sets the value of the symbolic constant in the function.
SymbolicFunction
public SymbolicFunction()
- Creates a SymbolicFunction instance; use initialize(...) to specify the function.
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.
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.
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.
evaluate
public double evaluate(double x)
- Evaluates a SymbolicFunction of one variable.
- Returns:
- double
evaluate
public double evaluate(double x1,
double x2)
- Evaluates a SymbolicFunction of two variables.
- Returns:
- double
evaluate
public double evaluate(double x1,
double x2,
double x3)
- Evaluates a SymbolicFunctio of three variables.
- Returns:
- double
evaluate
public double evaluate(double x1,
double x2,
double x3,
double x4)
- Evaluates a SymbolicFunctio of four variables.
- Returns:
- double
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
getConstructorString
public String getConstructorString()
- Returns the string used to specify the function.
getVariableCount
public int getVariableCount()
- Returns the number of independent variables in the function.
getVariableName
public String getVariableName(int i)
- Returns the name of the ith independent variable in the function.
Indexing starts at 0.
getConstantCount
public int getConstantCount()
- Returns the number of symbolic constants in the function.
getConstantName
public String getConstantName(int i)
- Returns the name of the ith symbolic constant in the function.
Indexing starts at 0.
getConstantValue
public double getConstantValue(int i)
- Returns the value of the ith symbolic constant in the function.
Indexing starts at 0.
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
main
public static void main(String args[])