Package evaluator
Class ExpressionEvaluator
java.lang.Object
evaluator.ExpressionEvaluator
- All Implemented Interfaces:
Evaluator
Implementation of the Evaluator interface
- Since:
- April 2025
- Version:
- 1.0
- Author:
- Saptarshi Dey
-
Field Summary
Fields inherited from interface evaluator.Evaluator
terminalSymbols
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorExpressionEvaluator
(Map<String, Complex> variables_) Parameterised constructor -
Method Summary
Modifier and TypeMethodDescriptioncomplexEvaluator
(String equation, boolean verbose) The function that connects all the modules together and computes the resultevaluateEquation
(String equation, int precision, boolean verbose) Wrapper for complexEvaluator functiongetVariable
(String variable) Getter to get individual variablesvoid
removeVariable
(String variable) Remove a variable from the variables Map Objectvoid
setVariable
(String variable, double value) Setter for the variables Map Object for real valuesvoid
setVariable
(String variable, Complex value) Setter for the variables Map Object for Complex valuesvoid
setVariables
(Map<String, Complex> variables_) Setter to set the whole variables Map Object at once
-
Constructor Details
-
ExpressionEvaluator
public ExpressionEvaluator()Default constructor -
ExpressionEvaluator
Parameterised constructor- Parameters:
variables_
- Map Object representing variables to be used while evaluating any function
-
-
Method Details
-
setVariable
Setter for the variables Map Object for Complex values- Parameters:
variable
- Name of the variablevalue
- Value of th variable
-
setVariable
Setter for the variables Map Object for real values- Parameters:
variable
- Name of the variablevalue
- Value of the variable
-
setVariables
Setter to set the whole variables Map Object at once- Parameters:
variables_
- Map object of all the variables
-
getVariable
Getter to get individual variables- Parameters:
variable
- Name of the variable- Returns:
- Complex number representing the value of the variable
-
removeVariable
Remove a variable from the variables Map Object- Parameters:
variable
- Name of the variable
-
complexEvaluator
The function that connects all the modules together and computes the result- Parameters:
equation
- String repesentation of the equationverbose
- Whether or not to show the computation- Returns:
- Resultant Complex number
- Throws:
Exception
-
evaluateEquation
Wrapper for complexEvaluator function- Specified by:
evaluateEquation
in interfaceEvaluator
- Parameters:
equation
- String repesentation of the equationprecision
- Precision of fractional part of the real and imaginary valuesverbose
- Whether or not to show the computation- Returns:
- String value representing the result
- Throws:
Exception
-