Package one.empty3.library1.tree
Class AlgebraicTree
java.lang.Object
one.empty3.library1.tree.Tree
one.empty3.library1.tree.AlgebraicTree
Represents a mathematical expression tree.
Created by Manuel Dahmen on 15-12-16.
Updated by Manuel Dahmen on 05-02-24
-
Constructor Summary
ConstructorsConstructorDescriptionAlgebraicTree
(String formula) Constructs a new instance of theAlgebraicTree
class with the specified formula.AlgebraicTree
(String formula, Map<String, Double> parametersValues) Constructs a new instance of the AlgebraicTree class with the specified formula and parameter values. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a subformula to the given source tree node.boolean
addBracedExpression
(TreeNode src, String values) boolean
addFactors
(TreeNode t, String values) boolean
addFunction
(TreeNode t, String values) boolean
addFunctionBody
(TreeNode src, String values) boolean
addFunctionDefinition
(TreeNode t, String values) boolean
addMethodCall
(TreeNode t, String values) boolean
boolean
boolean
addVector2
(TreeNode t, String values) Constructs and returns an AlgebraicTree object.eval()
void
Removes all spaces, newlines, carriage returns, and tabs from the formula string.void
setParameter
(String s, Double d) Sets the parameter value for a given parameter name.void
setParametersValues
(Map<String, Double> parametersValues) void
setParametersValuesVec
(Map<String, String> parametersValuesVec) void
setParametersValuesVecComputed
(HashMap<String, StructureMatrix<Double>> parametersValuesVecComputed) @NotNull String
toString()
-
Constructor Details
-
AlgebraicTree
Constructs a new instance of theAlgebraicTree
class with the specified formula.- Parameters:
formula
- the formula used to create the algebraic tree
-
AlgebraicTree
Constructs a new instance of the AlgebraicTree class with the specified formula and parameter values.- Parameters:
formula
- the formula used to create the algebraic treeparametersValues
- a map of parameter values
-
-
Method Details
-
removeSpaces
public void removeSpaces()Removes all spaces, newlines, carriage returns, and tabs from the formula string. If the formula is null, it sets it to an empty string. -
setParameter
Sets the parameter value for a given parameter name.- Parameters:
s
- the parameter named
- the parameter value
-
construct
Constructs and returns an AlgebraicTree object.- Returns:
- the constructed AlgebraicTree object
- Throws:
AlgebraicFormulaSyntaxException
- if there is a syntax error in the algebraic formula
-
add
Adds a subformula to the given source tree node.- Parameters:
src
- the source tree node to add the subformula tosubformula
- the subformula to be added- Returns:
- true if the subformula was successfully added, false otherwise
- Throws:
AlgebraicFormulaSyntaxException
- if there is a syntax error in the subformula
-
addPower
- Throws:
AlgebraicFormulaSyntaxException
-
addFactors
- Throws:
AlgebraicFormulaSyntaxException
-
addTerms
- Throws:
AlgebraicFormulaSyntaxException
-
addVector2
- Throws:
AlgebraicFormulaSyntaxException
-
addFunction
- Throws:
AlgebraicFormulaSyntaxException
-
addMethodCall
- Throws:
AlgebraicFormulaSyntaxException
-
addFunctionDefinition
public boolean addFunctionDefinition(TreeNode t, String values) throws AlgebraicFormulaSyntaxException - Throws:
AlgebraicFormulaSyntaxException
-
addFunctionBody
-
addBracedExpression
public boolean addBracedExpression(TreeNode src, String values) throws AlgebraicFormulaSyntaxException - Throws:
AlgebraicFormulaSyntaxException
-
eval
-
toString
-
setParametersValues
-
setParametersValuesVec
-
getParametersValues
-
getParametersValuesVec
-
setParametersValuesVecComputed
public void setParametersValuesVecComputed(HashMap<String, StructureMatrix<Double>> parametersValuesVecComputed) -
getParametersValuesVecComputed
-
getFormula
-