public class XJep extends Jep
Modifier and Type | Field and Description |
---|---|
protected ExpressionCleaner |
cleaner |
protected CommandVisitor |
commandv |
protected DeepCopyVisitor |
copier |
protected EquationExtractor |
extractor |
protected PolynomialCreator |
polyv |
protected RewriteVisitor |
rewritev |
protected SubstitutionVisitor |
subv |
protected TreeUtils |
tu
A few utility functions.
|
additionalComponents, allowAssignment, allowUndeclared, evaluator, funTab, implicitMul, lastRootNode, nodeFac, numFac, opTab, parser, pv, varFac, varTab
Constructor and Description |
---|
XJep()
Create a new XJep with all the function of Jep plus simplification and other features.
|
XJep(ComponentSet components)
Create a new XJep instance using specified components set and default components if necessary.
|
XJep(JepComponent... components)
Create a new XJep instance using specified components and default components if necessary.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addRewriteRule(RewriteRuleI rule) |
java.lang.Object |
calcVarValue(java.lang.String name,
boolean force)
Calculates the value for the variables equation and returns that value.
|
Node |
clean(Node node)
Returns a cleaned up version of an expression tree.
|
Node |
deepCopy(Node node)
Returns a deep copy of an expression tree.
|
boolean |
equals(Node lhs,
Node rhs)
Compare two expressions symbolically.
|
Node |
expand(Node node)
Expand brackets in an expression
|
CommandVisitor |
getCommandVisitor() |
DeepCopyVisitor |
getCopier() |
ExpressionCleaner |
getExpressionCleaner() |
EquationExtractor |
getExtractor() |
PolynomialCreator |
getPolynomialCreator() |
RewriteVisitor |
getRewriteVisitor() |
SubstitutionVisitor |
getSubstitutionVisitor() |
TreeUtils |
getTreeUtils()
Returns the TreeUtilitities, used for examining properties of nodes.
|
java.util.Set<Variable> |
getVarsInEquation(Node n)
Finds all the variables in an equation.
|
java.util.Set<Variable> |
getVarsInEquation(Node n,
java.util.Set<Variable> vars)
Finds all the variables in an equation.
|
Node |
preprocess(Node node)
Pre-processes an equation to allow the diff and eval operators to be used.
|
java.util.Set<XVariable> |
recursiveGetVarsInEquation(Node n,
java.util.Set<XVariable> vars)
Finds all the variables in an equation and if any of those
variables are defined by equations find the variables
in those equations as well.
|
Node |
replaceRHSVariablesByEquations(Node node)
Replace variables on the right had side of an assignment by their equations
|
Node |
replaceVariableByExpressions(Node node)
Replace all symbolic variable by their equations
|
Node |
rewrite(Node node,
boolean clean) |
protected void |
setXComponentInternal(JepComponent comp) |
Node |
simplify(Node node)
Returns a simplification of an expression tree.
|
Node |
substitute(Node orig,
Node sub)
Substitute all occurrences of the variable on the left hand side of sub with the expression tree on the right hand side.
|
Node |
substitute(Node orig,
Node[] subs)
Substitute all occurrences of the variable on the left hand side of sub with the expression tree on the right hand side.
|
Node |
substitute(Node orig,
java.lang.String[] names,
Node[] replacements)
Substitute all occurrences of a set of named variable with a set of expression tree.
|
Node |
substitute(Node orig,
java.lang.String[] names,
java.lang.Object[] values)
Substitute all occurrences of the variable with their values.
|
Node |
substitute(Node orig,
java.lang.String name,
Node replacement)
Substitute all occurrences of a named variable with an expression.
|
Node |
substitute(Node orig,
java.lang.String name,
java.lang.Object value)
Substitute all occurrences of a named variable with a constant value.
|
Node |
substituteConstantVariables(Node orig)
Replace all constant variables like
pi by their values. |
addConstant, addDefaultComponents, addFunction, addStandardConstants, addVariable, addVariable, addVariable, addVariable, continueParsing, evaluate, evaluate, evaluateD, getAdditionalComponent, getAdditionalComponents, getAllowAssignment, getAllowUndeclared, getDefaultValue, getEvaluator, getFunctionTable, getImplicitMul, getLastRootNode, getNodeFactory, getNumberFactory, getOperatorTable, getParser, getPrintVisitor, getVariable, getVariableFactory, getVariableTable, getVariableValue, initMultiParse, initMultiParse, parse, parse, print, print, print, println, println, println, reinitializeComponents, rootNodeToString, setAllowAssignment, setAllowUndeclared, setComponent, setComponentInternal, setComponents, setComponentsInternal, setDefaultValue, setImplicitMul, setVariable, toString, tryAddConstant
protected TreeUtils tu
protected DeepCopyVisitor copier
protected SubstitutionVisitor subv
protected ExpressionCleaner cleaner
protected CommandVisitor commandv
protected PolynomialCreator polyv
protected RewriteVisitor rewritev
protected EquationExtractor extractor
public XJep()
public XJep(JepComponent... components)
components
- public XJep(ComponentSet components)
components
- protected void setXComponentInternal(JepComponent comp)
public Node preprocess(Node node) throws ParseException
CommandVisitor
ParseException
public Node deepCopy(Node node) throws ParseException
ParseException
DeepCopyVisitor
public Node clean(Node node) throws ParseException
ParseException
ExpressionCleaner
public Node simplify(Node node) throws ParseException
ParseException
PolynomialCreator.simplify(Node)
public Node expand(Node node) throws ParseException
node
- expression to expandParseException
PolynomialCreator.expand(Node)
public boolean equals(Node lhs, Node rhs) throws ParseException
lhs
- rhs
- ParseException
PolynomialCreator.equals(Node, Node)
public Node substitute(Node orig, java.lang.String name, java.lang.Object value) throws ParseException
orig
- expression to substitute intoname
- name of variable to substitutevalue
- its replacement valueParseException
public Node substitute(Node orig, java.lang.String name, Node replacement) throws ParseException
orig
- expression to substitute intoname
- name of variable to substitutereplacement
- expression toParseException
public Node substitute(Node orig, Node sub) throws ParseException
orig
- expression to substitute intosub
- expression of the form x=....ParseException
public Node substitute(Node orig, java.lang.String[] names, java.lang.Object[] values) throws ParseException
ParseException
public Node substitute(Node orig, Node[] subs) throws ParseException
ParseException
public Node substitute(Node orig, java.lang.String[] names, Node[] replacements) throws ParseException
ParseException
public Node substituteConstantVariables(Node orig) throws ParseException
pi
by their values.orig
- the inputParseException
public Node replaceRHSVariablesByEquations(Node node) throws JepException
node
- an equation of the form g:=f^2-1
JepException
public Node replaceVariableByExpressions(Node node) throws JepException
node
- root of expressionJepException
public java.lang.Object calcVarValue(java.lang.String name, boolean force) throws EvaluationException
name
- name of variableforce
- whether to force re-evaluation if the variable has a valid valueEvaluationException
public java.util.Set<Variable> getVarsInEquation(Node n)
n
- the top node of the expressionpublic java.util.Set<Variable> getVarsInEquation(Node n, java.util.Set<Variable> vars)
n
- the top node of the expressionvars
- the list of variables (new variables will be added on end)public java.util.Set<XVariable> recursiveGetVarsInEquation(Node n, java.util.Set<XVariable> vars) throws ParseException
For example if the equation is a+b
and
a=c+d
, b=c+e
then the
result will be the sequence (c,d,a,e,b)
For this method to work the equations must be preprocessed using
preprocess(com.singularsys.jep.parser.Node)
.
n
- top nodevars
- list of variables, new variables will be added on the end.ParseException
- if equation is recursive i.e. x=y; y=x+1;
public Node rewrite(Node node, boolean clean) throws ParseException
ParseException
public boolean addRewriteRule(RewriteRuleI rule)
public TreeUtils getTreeUtils()
public DeepCopyVisitor getCopier()
public SubstitutionVisitor getSubstitutionVisitor()
public ExpressionCleaner getExpressionCleaner()
public CommandVisitor getCommandVisitor()
public PolynomialCreator getPolynomialCreator()
public RewriteVisitor getRewriteVisitor()
public EquationExtractor getExtractor()
Copyright © 2018 Singular Systems http://www.singularsys.com/jep