public class Symbol extends ExprImpl implements ISymbol, java.io.Serializable
ISymbol.RuleType| Modifier and Type | Field and Description |
|---|---|
protected static org.matheclipse.core.expression.Symbol.DummyEvaluator |
DUMMY_EVALUATOR |
CONSOLE_OUTPUT, CONSTANT, DELAYED_RULE_EVALUATION, FLAT, FLATORDERLESS, HOLDALL, HOLDFIRST, HOLDREST, LISTABLE, NHOLDALL, NHOLDFIRST, NHOLDREST, NOATTRIBUTE, NUMERICFUNCTION, ONEIDENTITY, ORDERLESS, PACKAGE_LOADEDASTID, BLANKID, COMPLEXID, DOUBLECOMPLEXID, DOUBLEID, FRACTIONID, INTEGERID, METHODSYMBOLID, PATTERNID, STRINGID, SYMBOLID| Constructor and Description |
|---|
Symbol(java.lang.String symbolName) |
Symbol(java.lang.String symbolName,
IEvaluator evaluator) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
accept(IVisitor<T> visitor)
Accept a visitor with return type T
|
boolean |
accept(IVisitorBoolean visitor)
Accept a visitor with return type
boolean |
int |
accept(IVisitorInt visitor)
Accept a visitor with return type
int |
long |
accept(IVisitorLong visitor)
Accept a visitor with return type
long |
IExpr |
apply(IExpr... expressions) |
void |
clear(EvalEngine engine)
Clear the associated rules for this symbol
|
void |
clearAll(EvalEngine engine)
Clear all associated rules and attributes for this symbol
|
int |
compareTo(IExpr expr)
Compares this expression with the specified expression for order.
|
boolean |
containsRules()
Check if ths symbol contains a "DownRule" or "UpRule"
|
void |
createRulesData(int[] sizes)
Create internal rules data structure with precalculated sizes
index 0 - number of equal rules in
RULES
|
java.util.List<IAST> |
definition()
Return a list of the rules associated to this symbol
|
java.lang.String |
definitionToString()
Return the rules associated to this symbol in
String
representation |
boolean |
equals(java.lang.Object obj)
Test if this is equal to b.
|
org.apache.commons.math4.complex.Complex |
evalComplex()
Evaluate the expression to a
INumber value. |
double |
evalDouble()
Evaluate the expression to a Java
double value. |
IExpr |
evalDownRule(IEvaluationEngine ee,
IExpr expression)
Evaluate the given expression for the "down value" rules
associated with this symbol
|
INumber |
evalNumber()
Evaluate the expression to a
INumber value. |
ISignedNumber |
evalSignedNumber()
Evaluate the expression to a
ISignedNumber value. |
IExpr |
evaluate(EvalEngine engine)
Evaluate an expression
|
IExpr |
evaluateHead(IAST ast,
EvalEngine engine) |
IExpr |
evalUpRule(IEvaluationEngine ee,
IExpr expression)
Evaluate the given expression for the "up value" rules
associated with this symbol
|
java.lang.String |
fullFormString()
Return the
FullForm() of this expression |
IExpr |
get()
Get the topmost value from the local variable stack
|
IExpr |
getAssignedValue()
Get the value which is assigned to the symbol or
null, if no
value is assigned. |
int |
getAttributes()
Get the Attributes of this symbol (i.e.
|
IExpr |
getDefaultValue()
Get the general default value for this symbol (i.e.
|
IExpr |
getDefaultValue(int pos)
Get the default value at the arguments position for this symbol
(i.e.
|
IEvaluator |
getEvaluator()
Get the current evaluator for this symbol
|
RulesData |
getRulesData()
Get the rules for initializing the pattern matching rules of this symbol.
|
java.lang.String |
getSymbolName()
Get the pure symbol name string
|
boolean |
hasAssignedSymbolValue()
Is a (local or global) value assigned for this symbol?
|
int |
hashCode()
Hashcode of this Element.
|
boolean |
hasLocalVariableStack()
Is a local variable stack created for this symbol ?
|
ISymbol |
head()
If this object is an instance of
IAST get the first element
(offset 0) of the IAST list (i.e. get(0) ). |
int |
hierarchy()
A unique integer ID for the implementation of this expression
|
java.lang.String |
internalFormString(boolean symbolsAsFactoryMethod,
int depth)
Return the internal Java form of this expression.
|
java.lang.String |
internalJavaString(boolean symbolsAsFactoryMethod,
int depth,
boolean useOperators)
Return the internal Java form of this expression.
|
java.lang.String |
internalScalaString(boolean symbolsAsFactoryMethod,
int depth)
Return the internal Scala form of this expression.
|
boolean |
isAtom()
Test if this expression is an atomic expression (i.e. no AST expression)
|
boolean |
isConstant()
Test if this expression is a symbol with attribute
Constant. |
boolean |
isE()
Test if this expression equals
E (base of the natural
logarithm; approximately equal to 2.71828...) in symbolic or numeric
mode. |
boolean |
isFalse()
Test if this expression equals the symbol "False"
|
boolean |
isIndeterminate()
Test if this expression is representing
Indeterminate |
boolean |
isNegative()
Test if this object is a negative signed number.
|
boolean |
isPi()
Test if this expression equals
Pi (the ratio of a circle's
circumference to its diameter, approx. 3.141592...) in symbolic or
numeric mode. |
boolean |
isPolynomial(IAST variables)
Test if this expression is a polynomial for the given list of
variables. |
boolean |
isPolynomial(ISymbol variable)
Test if this expression is a polynomial for the given
variable. |
boolean |
isPolynomialOfMaxDegree(ISymbol variable,
long maxDegree)
Test if this expression is a polynomial of
maxDegree (i.e. |
boolean |
isPositive()
Test if this object is a positive signed number.
|
boolean |
isString(java.lang.String str)
Tests if this symbols name equals the given string
|
boolean |
isSymbolName(java.lang.String name)
Returns
true, if this symbol has the given name. |
boolean |
isTrue()
Test if this expression equals the symbol
True. |
boolean |
isValue()
Returns
true, if this symbol or ast expression is bound to a
value (i.e. the evaluation returns an assigned value). |
boolean |
isVariable()
Test if this expression is a symbol which doesn't has attribute
Constant. |
IExpr |
mapConstantDouble(INumericFunction<IExpr> function)
If this symbol has attribute
ISymbol.CONSTANT and the
symbol's evaluator is of instance INumericConstant, then
apply the constants double value to the given function and return the
result, otherwise return F.NIL. |
IExpr |
negate()
Negate this.
|
void |
popLocalVariable()
Delete the topmost placeholder from the local variable stack
|
void |
pushLocalVariable()
Create a new variable placeholder on the symbols variable stack
|
void |
pushLocalVariable(IExpr expression)
Create a new variable placeholder on the symbols variable stack and set
the local value
|
IPatternMatcher |
putDownRule(ISymbol.RuleType symbol,
boolean equalRule,
IExpr leftHandSide,
IExpr rightHandSide,
boolean packageMode)
Associate a new "down value" rule with default priority to this
symbol.
|
IPatternMatcher |
putDownRule(ISymbol.RuleType setSymbol,
boolean equalRule,
IExpr leftHandSide,
IExpr rightHandSide,
int priority,
boolean packageMode)
Associate a new rule with the given priority to this symbol.
|
PatternMatcher |
putDownRule(PatternMatcherAndInvoker pmEvaluator)
Associate a new rule, which invokes a method, to this symbol.
|
IPatternMatcher |
putUpRule(ISymbol.RuleType symbol,
boolean equalRule,
IAST leftHandSide,
IExpr rightHandSide)
Associate a new "up value" rule with default priority to this
symbol.
|
IPatternMatcher |
putUpRule(ISymbol.RuleType setSymbol,
boolean equalRule,
IAST leftHandSide,
IExpr rightHandSide,
int priority)
Associate a new "up value" rule with the given priority to this
symbol.
|
java.lang.Object |
readResolve() |
void |
readRules(java.io.ObjectInputStream stream)
Deserialize the rules associated to this object
|
IExpr[] |
reassignSymbolValue(java.util.function.Function<IExpr,IExpr> function,
ISymbol functionSymbol)
Apply the function to the currently assigned value of the symbol and
reassign the result value to the symbol.
|
void |
removeRule(ISymbol.RuleType setSymbol,
boolean equalRule,
IExpr leftHandSide,
boolean packageMode) |
void |
set(IExpr value)
Set the value of the local variable on top of the local variable stack
|
void |
setAttributes(int attributes)
Set the Attributes of this symbol (i.e.
|
void |
setDefaultValue(IExpr expr)
Set the general default value for this symbol (i.e.
|
void |
setDefaultValue(int pos,
IExpr expr)
Set the default value at the arguments position for this symbol
(i.e.
|
void |
setEvaluator(IEvaluator evaluator)
Set the current evaluator which is associated to this symbol
|
java.lang.String |
toString() |
IExpr |
variables2Slots(java.util.Map<IExpr,IExpr> map,
java.util.Collection<IExpr> variableCollector)
Convert the variables (i.e. expressions of type
ISymbol
which aren't constants) in this expression into Slot[] s. |
boolean |
writeRules(java.io.ObjectOutputStream stream)
Serialize the rule definitions associated to this symbol
|
$div, $minus, $plus, $times, $up, abs, and, apply, asType, conjugate, copy, dec, divide, egcd, factory, gcd, getAt, inc, inverse, leafCount, leaves, minus, mod, multiply, negative, opposite, optional, or, plus, power, power, remainder, replaceAll, replaceAll, replacePart, replaceRepeated, replaceRepeated, replaceRepeated, replaceSlots, signum, subtract, sum, times, topHead, toScript, toScriptFactoryclone, finalize, getClass, notify, notifyAll, wait, wait, wait$div, $minus, $plus, $times, $up, and, apply, asType, dec, divide, getAt, getField, ifPresent, inc, inverse, isAllExpanded, isAnd, isArcCos, isArcCosh, isArcSin, isArcSinh, isArcTan, isArcTanh, isAST, isAST, isAST, isAST, isAST, isAST, isAST, isASTSizeGE, isBlank, isComplex, isComplexInfinity, isComplexNumeric, isCondition, isCos, isCosh, isDerivative, isDirectedInfinity, isExpanded, isFlatAST, isFraction, isFree, isFree, isFree, isFreeAST, isFreeAST, isFreeOfPatterns, isFunction, isGEOrdered, isGTOrdered, isInfinity, isInteger, isIntegerResult, isLEOrdered, isList, isListOfLists, isLog, isLTOrdered, isMatrix, isMember, isMember, isMinusOne, isModule, isNegativeInfinity, isNegativeResult, isNonNegativeResult, isNot, isNumber, isNumEqualInteger, isNumEqualRational, isNumeric, isNumericFunction, isNumericMode, isNumIntValue, isOne, isONE, isOr, isOrderlessAST, isPattern, isPatternDefault, isPatternExpr, isPatternSequence, isPlus, isPlusTimesPower, isPositiveResult, isPower, isPresent, isRational, isRationalResult, isRationalValue, isRealResult, isRuleAST, isSame, isSame, isSequence, isSignedNumber, isSin, isSinh, isSlot, isSlotSequence, isSpan, isSymbol, isTan, isTanh, isTimes, isUnit, isVector, isZero, isZERO, leafCount, leaves, minus, mod, multiply, multiply, negative, ofNullable, opposite, optional, or, orElse, orElseGet, orElseThrow, plus, power, power, reciprocal, replaceAll, replaceAll, replacePart, replaceRepeated, replaceRepeated, replaceSlots, signum, subtract, sum, times, timesDistributed, topHeadprotected static final org.matheclipse.core.expression.Symbol.DummyEvaluator DUMMY_EVALUATOR
public Symbol(java.lang.String symbolName)
public Symbol(java.lang.String symbolName,
IEvaluator evaluator)
public RulesData getRulesData()
getRulesData in interface ISymbolnull if no rule is definedpublic IExpr[] reassignSymbolValue(java.util.function.Function<IExpr,IExpr> function, ISymbol functionSymbol)
reassignSymbolValue in interface ISymbolfunction - the function which should be appliedfunctionSymbol - if this method throws a WrongArgumentType exception the symbol
will be displayed in the exceptions messagenull if the
reassignment isn't possible.WrongArgumentTypepublic boolean hasAssignedSymbolValue()
hasAssignedSymbolValue in interface ISymboltrue if this symbol has an assigned value.public IExpr getAssignedValue()
null, if no
value is assigned.getAssignedValue in interface ISymbolnull, if no value is assigned.public final void pushLocalVariable()
pushLocalVariable in interface ISymbolpublic final void pushLocalVariable(IExpr expression)
pushLocalVariable in interface ISymbolpublic final void popLocalVariable()
popLocalVariable in interface ISymbolpublic final void clear(EvalEngine engine)
public final void clearAll(EvalEngine engine)
public boolean equals(java.lang.Object obj)
equals in interface edu.jas.structure.Element<IExpr>equals in class java.lang.Objectpublic final boolean isSymbolName(java.lang.String name)
ISymboltrue, if this symbol has the given name. The
comparison of the symbols name with the given name is done according to
the Config.PARSER_USE_LOWERCASE_SYMBOLS setting.isSymbolName in interface ISymbolpublic IExpr evaluate(EvalEngine engine)
public IExpr evaluateHead(IAST ast, EvalEngine engine)
evaluateHead in interface IExprpublic final IExpr evalDownRule(IEvaluationEngine ee, IExpr expression)
evalDownRule in interface ISymbolF.NIL if no evaluation was possiblepublic final double evalDouble()
double value. If the
conversion to a double value is not possible, the method throws a
WrongArgumentType exception.evalDouble in interface IExprevalDouble in class ExprImpldouble value.public final org.apache.commons.math4.complex.Complex evalComplex()
INumber value.evalComplex in interface IExprevalComplex in class ExprImplnull if the conversion is not possible.public final INumber evalNumber()
INumber value.evalNumber in interface IExprevalNumber in class ExprImplnull if the conversion is not possible.public final ISignedNumber evalSignedNumber()
ISignedNumber value.evalSignedNumber in interface IExprevalSignedNumber in class ExprImplnull if the conversion is not possible.public final IExpr evalUpRule(IEvaluationEngine ee, IExpr expression)
evalUpRule in interface ISymbolF.NIL if no evaluation was possiblepublic final int getAttributes()
getAttributes in interface ISymbolISymbol.FLATpublic IEvaluator getEvaluator()
getEvaluator in interface ISymbolnull if no evaluator is associatedpublic final boolean hasLocalVariableStack()
hasLocalVariableStack in interface ISymboltrue if this symbol has a local variable stackpublic final IExpr get()
public final void set(IExpr value)
public int hashCode()
hashCode in interface edu.jas.structure.Element<IExpr>hashCode in class java.lang.Objectpublic int hierarchy()
public final boolean isString(java.lang.String str)
public final IPatternMatcher putDownRule(ISymbol.RuleType symbol, boolean equalRule, IExpr leftHandSide, IExpr rightHandSide, boolean packageMode)
putDownRule in interface ISymbolsymbol - which of the symbols
Set, SetDelayed, UpSet, UpSetDelayed was used for
defining this ruleequalRule - true if the leftHandSide could be matched with
equalitypackageMode - true if we are on "package mode"PatternMap.DEFAULT_RULE_PRIORITYpublic final IPatternMatcher putDownRule(ISymbol.RuleType setSymbol, boolean equalRule, IExpr leftHandSide, IExpr rightHandSide, int priority, boolean packageMode)
putDownRule in interface ISymbolsetSymbol - which of the symbols
Set, SetDelayed, UpSet, UpSetDelayed was used for
defining this ruleequalRule - true if the leftHandSide could be matched with
equalitypriority - the priority of the rulepackageMode - true if we are on "package mode"PatternMap.DEFAULT_RULE_PRIORITYpublic final void removeRule(ISymbol.RuleType setSymbol, boolean equalRule, IExpr leftHandSide, boolean packageMode)
removeRule in interface ISymbolpublic final PatternMatcher putDownRule(PatternMatcherAndInvoker pmEvaluator)
putDownRule in interface ISymbolpublic final IPatternMatcher putUpRule(ISymbol.RuleType symbol, boolean equalRule, IAST leftHandSide, IExpr rightHandSide)
putUpRule in interface ISymbolsymbol - which of the symbols
Set, SetDelayed, UpSet, UpSetDelayed was used for
defining this ruleequalRule - true if the leftHandSide could be matched with
equalityPatternMap.DEFAULT_RULE_PRIORITYpublic final IPatternMatcher putUpRule(ISymbol.RuleType setSymbol, boolean equalRule, IAST leftHandSide, IExpr rightHandSide, int priority)
putUpRule in interface ISymbolsetSymbol - which of the symbols
Set, SetDelayed, UpSet, UpSetDelayed was used for
defining this ruleequalRule - true if the leftHandSide could be matched with
equalitypriority - the priority of the rulePatternMap.DEFAULT_RULE_PRIORITYpublic final void setAttributes(int attributes)
setAttributes in interface ISymbolattributes - the Attributes of this symbolpublic final void setEvaluator(IEvaluator evaluator)
setEvaluator in interface ISymbolpublic int compareTo(IExpr expr)
public final boolean isAtom()
public final boolean isConstant()
Constant.
Therefore numbers return false for this method!isConstant in interface IExpr#isRealFunction(),
IExpr.isNumericFunction()public final boolean isE()
E (base of the natural
logarithm; approximately equal to 2.71828...) in symbolic or numeric
mode.
public boolean isTrue()
True.public final boolean isValue()
true, if this symbol or ast expression is bound to a
value (i.e. the evaluation returns an assigned value).public boolean isVariable()
Constant.isVariable in interface IExprIExpr.isConstant(),
IExpr.isSymbol()public boolean isFalse()
public boolean isIndeterminate()
IndeterminateisIndeterminate in interface IExprpublic boolean isNegative()
IAST
object the method checks, if it is a numeric constant. If the
IAST object evaluates to a negative numeric expression this
method returns true.isNegative in interface IExprtrue, if this < 0; false
in all other case.public final boolean isPi()
Pi (the ratio of a circle's
circumference to its diameter, approx. 3.141592...) in symbolic or
numeric mode.
public boolean isPolynomial(ISymbol variable)
Test if this expression is a polynomial for the given
variable.
null, this method
returns true for a Symbol expression.isPolynomial in interface IExprpublic boolean isPolynomial(IAST variables)
Test if this expression is a polynomial for the given list of
variables.
true for a Symbol expression.isPolynomial in interface IExprvariables - a list of variables or an empty listtrue if this expression is a polynomial;
falseotherwisepublic boolean isPolynomialOfMaxDegree(ISymbol variable, long maxDegree)
maxDegree (i.e.
the maximum exponent <= maxDegree) for the given variable.isPolynomialOfMaxDegree in interface IExprmaxDegree - the maximum degree of the polynomial; maxDegree must be
greater 0public boolean isPositive()
IAST
object the method checks, if it is a numeric constant. If the
IAST object evaluates to a positive numeric expression this
method returns true.isPositive in interface IExprtrue, if this > 0; false
in all other case.public ISymbol head()
IAST get the first element
(offset 0) of the IAST list (i.e. get(0) ).public final java.lang.String getSymbolName()
getSymbolName in interface ISymbolpublic IExpr variables2Slots(java.util.Map<IExpr,IExpr> map, java.util.Collection<IExpr> variableCollector)
ISymbol
which aren't constants) in this expression into Slot[] s.variables2Slots in interface IExprvariables2Slots in class ExprImplmap - for every given symbol argument return the associated unique
slot from this mapvariableCollector - collects the variables which are used in the replacement
processF.NIL if no variable symbol was found.public java.lang.String internalFormString(boolean symbolsAsFactoryMethod,
int depth)
internalFormString in interface IExprinternalFormString in class ExprImplsymbolsAsFactoryMethod - if true use the F.symbol() method,
otherwise print the symbol name.depth - the recursion depth of this call. 0 indicates
"recurse without a limit".public java.lang.String internalScalaString(boolean symbolsAsFactoryMethod,
int depth)
internalScalaString in interface IExprinternalScalaString in class ExprImplsymbolsAsFactoryMethod - if true use the F.symbol() method,
otherwise print the symbol name.depth - the recursion depth of this call. 0 indicates
"recurse without a limit".public java.lang.String internalJavaString(boolean symbolsAsFactoryMethod,
int depth,
boolean useOperators)
internalJavaString in interface IExprinternalJavaString in class ExprImplsymbolsAsFactoryMethod - if true use the F.symbol() method,
otherwise print the symbol name.depth - the recursion depth of this call. 0 indicates
"recurse without a limit".useOperators - use operators instead of function names for representation of
Plus, Times, Power,...public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String fullFormString()
FullForm() of this expressionfullFormString in interface IExprfullFormString in class ExprImplpublic java.util.List<IAST> definition()
definition in interface ISymbolpublic IExpr getDefaultValue()
1
is the default value for Times, 0 is the
default value for Plus). The general default value is used
in pattern-matching for expressions like a_. * b_. + c_getDefaultValue in interface ISymbolnull if undefined.public IExpr getDefaultValue(int pos)
1 is the default value for Power at
position 2). The default value is used in
pattern-matching for expressions like a ^ b_.getDefaultValue in interface ISymbolpos - the position for the default valuenull if undefined.public void setDefaultValue(IExpr expr)
1
is the default value for Times, 0 is the
default value for Plus). The general default value is used
in pattern-matching for expressions like a_. * b_. + c_setDefaultValue in interface ISymbolexpr - the general default valueISymbol.getDefaultValue()public void setDefaultValue(int pos,
IExpr expr)
1 is the default value for Power at
position 2). The default value is used in
pattern-matching for expressions like a ^ b_.setDefaultValue in interface ISymbolpos - the position for the default valueexpr - the default value for the given positionISymbol.getDefaultValue(int)public java.lang.String definitionToString()
throws java.io.IOException
String
representationdefinitionToString in interface ISymbolString representation of the symbol definitionjava.io.IOExceptionpublic java.lang.Object readResolve()
throws java.io.ObjectStreamException
java.io.ObjectStreamExceptionpublic void readRules(java.io.ObjectInputStream stream)
throws java.io.IOException,
java.lang.ClassNotFoundException
public boolean writeRules(java.io.ObjectOutputStream stream)
throws java.io.IOException
writeRules in interface ISymbolfalse if the symbol contains no rule definion.java.io.IOExceptionpublic boolean containsRules()
containsRules in interface ISymboltrue if this symbol contains a "DownRule" or
"UpRule"public final void createRulesData(int[] sizes)
RULEScreateRulesData in interface ISymbolpublic <T> T accept(IVisitor<T> visitor)
public boolean accept(IVisitorBoolean visitor)
booleanpublic int accept(IVisitorInt visitor)
intpublic long accept(IVisitorLong visitor)
longpublic IExpr mapConstantDouble(INumericFunction<IExpr> function)
ISymbol.CONSTANT and the
symbol's evaluator is of instance INumericConstant, then
apply the constants double value to the given function and return the
result, otherwise return F.NIL.mapConstantDouble in interface ISymbolfunction - applys the function to a double value, resulting
in an object of type IExpr.F.NIL.Abs,
Ceiling,
Floor