public interface ISymbol extends IExpr
Modifier and Type | Interface and Description |
---|---|
static class |
ISymbol.RuleType |
Modifier and Type | Field and Description |
---|---|
static int |
CONSOLE_OUTPUT
ISymbol attribute to indicate that a symbols evaluation should be printed
to Console with System.out.println();
|
static int |
CONSTANT
ISymbol attribute to indicate that a symbol has a constant value
|
static int |
DELAYED_RULE_EVALUATION
ISymbol attribute to indicate that a symbols evaluation should be printed
to Console with System.out.println();
|
static int |
FLAT
ISymbol attribute for an associative function transformation.
|
static int |
FLATORDERLESS
ISymbol attribute combination (ISymbol.FLAT and ISymbol.ORDERLESS)
|
static int |
HOLDALL
ISymbol attribute for a function, where no argument should be evaluated
|
static int |
HOLDFIRST
ISymbol attribute for a function, where the first argument should not be
evaluated
|
static int |
HOLDREST
ISymbol attribute for a function, where only the first argument should be
evaluated
|
static int |
LISTABLE
ISymbol attribute for a function with lists as arguments
|
static int |
NHOLDALL
ISymbol attribute for a function, which should not be evaluated
numerically
|
static int |
NHOLDFIRST
ISymbol attribute for a function, where the first argument should not be
evaluated numerically
|
static int |
NHOLDREST
ISymbol attribute for a function, where the rest of the arguments should
not be evaluated numerically.
|
static int |
NOATTRIBUTE
ISymbol attribute which means that no attribute is set.
|
static int |
NUMERICFUNCTION
ISymbol attribute for a numeric function
|
static int |
ONEIDENTITY
ISymbol attribute for a function transformation: f(x) ==> x
|
static int |
ORDERLESS
ISymbol attribute for a commutative function transformation.
|
static int |
PACKAGE_LOADED
ISymbol flag for a symbol which has already loaded it's package
definition
|
ASTID, BLANKID, COMPLEXID, DOUBLECOMPLEXID, DOUBLEID, FRACTIONID, INTEGERID, METHODSYMBOLID, PATTERNID, STRINGID, SYMBOLID
Modifier and Type | Method and Description |
---|---|
void |
clear(EvalEngine engine)
Clear the associated rules for this symbol
|
void |
clearAll(EvalEngine engine)
Clear all associated rules and attributes for this symbol
|
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 |
IExpr |
evalDownRule(IEvaluationEngine engine,
IExpr expression)
Evaluate the given expression for the "down value" rules
associated with this symbol
|
IExpr |
evalUpRule(IEvaluationEngine engine,
IExpr expression)
Evaluate the given expression for the "up value" rules
associated with this symbol
|
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 position)
Get the default value at the arguments position for this symbol
(i.e.
|
IEvaluator |
getEvaluator()
Get the current evaluator for this symbol
|
RulesData |
getRulesData() |
java.lang.String |
getSymbolName()
Get the pure symbol name string
|
boolean |
hasAssignedSymbolValue()
Is a (local or global) value assigned for this symbol?
|
boolean |
hasLocalVariableStack()
Is a local variable stack created for this symbol ?
|
boolean |
isString(java.lang.String symbolName)
Tests if this symbols name equals the given string
|
boolean |
isSymbolName(java.lang.String name)
Returns
true , if this symbol has the given name. |
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 . |
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 localValue)
Create a new variable placeholder on the symbols variable stack and set
the local value
|
IPatternMatcher |
putDownRule(ISymbol.RuleType setSymbol,
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.
|
IPatternMatcher |
putDownRule(PatternMatcherAndInvoker pmEvaluator)
Associate a new rule, which invokes a method, to this symbol.
|
IPatternMatcher |
putUpRule(ISymbol.RuleType setSymbol,
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.
|
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 position,
IExpr expr)
Set the default value at the arguments position for this symbol
(i.e.
|
void |
setEvaluator(IEvaluator module)
Set the current evaluator which is associated to this symbol
|
boolean |
writeRules(java.io.ObjectOutputStream stream)
Serialize the rule definitions associated to this symbol
|
$div, $minus, $plus, $times, $up, accept, accept, accept, accept, and, apply, apply, asType, compareTo, dec, divide, evalComplex, evalDouble, evalNumber, evalSignedNumber, evaluate, evaluateHead, fullFormString, getAt, getField, head, hierarchy, ifPresent, inc, internalFormString, internalJavaString, internalScalaString, inverse, isAllExpanded, isAnd, isArcCos, isArcCosh, isArcSin, isArcSinh, isArcTan, isArcTanh, isAST, isAST, isAST, isAST, isAST, isAST, isAST, isASTSizeGE, isAtom, isBlank, isComplex, isComplexInfinity, isComplexNumeric, isCondition, isConstant, isCos, isCosh, isDerivative, isDirectedInfinity, isE, isExpanded, isFalse, isFlatAST, isFraction, isFree, isFree, isFree, isFreeAST, isFreeAST, isFreeOfPatterns, isFunction, isGEOrdered, isGTOrdered, isIndeterminate, isInfinity, isInteger, isIntegerResult, isLEOrdered, isList, isListOfLists, isLog, isLTOrdered, isMatrix, isMember, isMember, isMinusOne, isModule, isNegative, isNegativeInfinity, isNegativeResult, isNonNegativeResult, isNot, isNumber, isNumEqualInteger, isNumEqualRational, isNumeric, isNumericFunction, isNumericMode, isNumIntValue, isOne, isONE, isOr, isOrderlessAST, isPattern, isPatternDefault, isPatternExpr, isPatternSequence, isPi, isPlus, isPlusTimesPower, isPolynomial, isPolynomial, isPolynomialOfMaxDegree, isPositive, isPositiveResult, isPower, isPresent, isRational, isRationalResult, isRationalValue, isRealResult, isRuleAST, isSame, isSame, isSequence, isSignedNumber, isSin, isSinh, isSlot, isSlotSequence, isSpan, isSymbol, isTan, isTanh, isTimes, isTrue, isUnit, isValue, isVariable, 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, topHead, variables2Slots
static final int CONSOLE_OUTPUT
static final int CONSTANT
static final int FLAT
static final int HOLDFIRST
static final int HOLDREST
static final int HOLDALL
static final int LISTABLE
static final int NHOLDFIRST
static final int NHOLDREST
static final int NHOLDALL
static final int NOATTRIBUTE
static final int NUMERICFUNCTION
static final int PACKAGE_LOADED
static final int ONEIDENTITY
static final int ORDERLESS
static final int FLATORDERLESS
static final int DELAYED_RULE_EVALUATION
IEvaluator getEvaluator()
null
if no evaluator is associatedRulesData getRulesData()
null
if no rules are definedjava.lang.String getSymbolName()
void setEvaluator(IEvaluator module)
boolean isString(java.lang.String symbolName)
symbolName
- boolean isSymbolName(java.lang.String name)
true
, 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.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
.int getAttributes()
FLAT
void setAttributes(int attributes)
attributes
- the Attributes of this symbolvoid pushLocalVariable()
void pushLocalVariable(IExpr localValue)
void popLocalVariable()
boolean hasAssignedSymbolValue()
true
if this symbol has an assigned value.boolean hasLocalVariableStack()
true
if this symbol has a local variable stackIExpr get()
null
if no local variable is definedvoid set(IExpr value)
IPatternMatcher putDownRule(ISymbol.RuleType setSymbol, boolean equalRule, IExpr leftHandSide, IExpr rightHandSide, boolean packageMode)
setSymbol
- which of the symbols
Set, SetDelayed, UpSet, UpSetDelayed
was used for
defining this ruleequalRule
- true
if the leftHandSide could be matched with
equalityleftHandSide
- rightHandSide
- packageMode
- true
if we are on "package mode"PatternMap.DEFAULT_RULE_PRIORITY
IPatternMatcher putDownRule(ISymbol.RuleType setSymbol, boolean equalRule, IExpr leftHandSide, IExpr rightHandSide, int priority, boolean packageMode)
setSymbol
- which of the symbols
Set, SetDelayed, UpSet, UpSetDelayed
was used for
defining this ruleequalRule
- true
if the leftHandSide could be matched with
equalityleftHandSide
- rightHandSide
- priority
- the priority of the rulepackageMode
- true
if we are on "package mode"PatternMap.DEFAULT_RULE_PRIORITY
IPatternMatcher putDownRule(PatternMatcherAndInvoker pmEvaluator)
IPatternMatcher putUpRule(ISymbol.RuleType setSymbol, boolean equalRule, IAST leftHandSide, IExpr rightHandSide)
setSymbol
- which of the symbols
Set, SetDelayed, UpSet, UpSetDelayed
was used for
defining this ruleequalRule
- true
if the leftHandSide could be matched with
equalityleftHandSide
- rightHandSide
- PatternMap.DEFAULT_RULE_PRIORITY
IPatternMatcher putUpRule(ISymbol.RuleType setSymbol, boolean equalRule, IAST leftHandSide, IExpr rightHandSide, int priority)
setSymbol
- which of the symbols
Set, SetDelayed, UpSet, UpSetDelayed
was used for
defining this ruleequalRule
- true
if the leftHandSide could be matched with
equalityleftHandSide
- rightHandSide
- priority
- the priority of the rulePatternMap.DEFAULT_RULE_PRIORITY
void removeRule(ISymbol.RuleType setSymbol, boolean equalRule, IExpr leftHandSide, boolean packageMode)
IExpr evalDownRule(IEvaluationEngine engine, IExpr expression)
engine
- expression
- F.NIL
if no evaluation was possibleIExpr evalUpRule(IEvaluationEngine engine, IExpr expression)
engine
- expression
- F.NIL
if no evaluation was possibleIExpr 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_
null
if undefined.IExpr getDefaultValue(int position)
1
is the default value for Power
at
position
2
). The default value is used in
pattern-matching for expressions like a ^ b_.
position
- the position for the default valuenull
if undefined.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_
expr
- the general default valuegetDefaultValue()
void setDefaultValue(int position, 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_.
position
- the position for the default valueexpr
- the default value for the given positiongetDefaultValue(int)
IExpr getAssignedValue()
null
, if no
value is assigned.null
, if no value is assigned.IExpr[] reassignSymbolValue(java.util.function.Function<IExpr,IExpr> function, ISymbol functionSymbol)
function
- 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.WrongArgumentType
void clear(EvalEngine engine)
void clearAll(EvalEngine engine)
boolean containsRules()
true
if this symbol contains a "DownRule" or
"UpRule"void createRulesData(int[] sizes)
RULES
sizes
- java.util.List<IAST> definition()
java.lang.String definitionToString() throws java.io.IOException
String
representationString
representation of the symbol definitionjava.io.IOException
void readRules(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
stream
- java.io.IOException
java.lang.ClassNotFoundException
boolean writeRules(java.io.ObjectOutputStream stream) throws java.io.IOException
stream
- false
if the symbol contains no rule definion.java.io.IOException