org.matheclipse.core.interfaces
Interface ISymbol
-
- All Superinterfaces:
- AbelianGroupElem<IExpr>, java.lang.Comparable<IExpr>, Element<IExpr>, IExpr, MonoidElem<IExpr>, RingElem<IExpr>, java.io.Serializable
- All Known Implementing Classes:
- MethodSymbol, Symbol
public interface ISymbol extends IExpr
An expression representing a symbol (i.e. variable- constant- or function-name)
-
-
Field Summary
Fields Modifier and Type Field and Description static intCONSOLE_OUTPUTISymbol attribute to indicate that a symbols evaluation should be printed to Console with System.out.println();static intCONSTANTISymbol attribute to indicate that a symbol has a constant valuestatic intDEFAULT_RULE_PRIORITYThe default priority when associating a new rule to a symbol.static intFLATISymbol attribute for an associative function transformation.static intFLATORDERLESSISymbol attribute combination (ISymbol.FLAT and ISymbol.ORDERLESS)static intHOLDALLISymbol attribute for a function, where no argument should be evaluatedstatic intHOLDFIRSTISymbol attribute for a function, where the first argument should not be evaluatedstatic intHOLDRESTISymbol attribute for a function, where only the first argument should be evaluatedstatic intLISTABLEISymbol attribute for a function with lists as argumentsstatic intNHOLDALLISymbol attribute for a function, which should not be evaluated numericallystatic intNHOLDFIRSTISymbol attribute for a function, where the first argument should not be evaluated numericallystatic intNHOLDRESTISymbol attribute for a function, where the rest of the arguments should not be evaluated numerically.static intNOATTRIBUTEISymbol attribute which means that no attribute is set.static intNUMERICFUNCTIONISymbol attribute for a numeric functionstatic intONEIDENTITYISymbol attribute for a function transformation: f(x) ==> xstatic intORDERLESSISymbol attribute for a commutative function transformation.static intPACKAGE_LOADEDISymbol flag for a symbol which has already loaded it's package definition-
Fields inherited from interface org.matheclipse.core.interfaces.IExpr
ASTID, COMPLEXID, DOUBLECOMPLEXID, DOUBLEID, FRACTIONID, INTEGERID, METHODSYMBOLID, PATTERNID, STRINGID, SYMBOLID
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description voidclear(EvalEngine engine)Clear the associated rules for this symbolvoidclearAll(EvalEngine engine)Clear all associated rules and attributes for this symboljava.util.List<IAST>definition()Return a list of the rules associated to this symboljava.lang.StringdefinitionToString()Return the rules associated to this symbol in String representationIExprevalDownRule(IEvaluationEngine engine, IExpr expression)Evaluate the given expression for the "down value" rules associated with this symbolIExprevalUpRule(IEvaluationEngine engine, IExpr expression)Evaluate the given expression for the "up value" rules associated with this symbolIExprget()Get the topmost value from the local variable stackIExprgetAssignedValue()Get the value which is assigned to the symbol ornull, if no value is assigned.intgetAttributes()Get the Attributes of this symbol (i.e.IExprgetDefaultValue()Get the general default value for this symbol (i.e.IExprgetDefaultValue(int position)Get the default value at the arguments position for this symbol (i.e.IEvaluatorgetEvaluator()Get the current evaluator for this symbolbooleanhasLocalVariableStack()Is a local variable stack created for this symbol ?booleanisString(java.lang.String symbolName)Tests if this symbols name equals the given stringbooleanisSymbolName(java.lang.String name)Returnstrue, if this symbol has the given name.IExprmapConstantDouble(INumericFunction<IExpr> function)If this symbol has attributeISymbol.CONSTANTand the symbol's evaluator is of instanceINumericConstant, then apply the constants double value to the given function and return the result, otherwise returnnull.voidpopLocalVariable()Delete the topmost placeholder from the local variable stackvoidpushLocalVariable()Create a new variable placeholder on the symbols variable stackvoidpushLocalVariable(IExpr localValue)Create a new variable placeholder on the symbols variable stack and set the local valueIPatternMatcherputDownRule(ISymbol symbol, boolean equalRule, IExpr leftHandSide, IExpr rightHandSide, boolean packageMode)Associate a new "down value" rule with default priority to this symbol.IPatternMatcherputDownRule(ISymbol symbol, boolean equalRule, IExpr leftHandSide, IExpr rightHandSide, int priority, boolean packageMode)Associate a new rule with the given priority to this symbol.
Rules with lower numbers have higher priorities.PatternMatcherputDownRule(PatternMatcherAndInvoker pmEvaluator)Associate a new rule, which invokes a method, to this symbol.IPatternMatcherputUpRule(ISymbol symbol, boolean equalRule, IAST leftHandSide, IExpr rightHandSide)Associate a new "up value" rule with default priority to this symbol.IPatternMatcherputUpRule(ISymbol setSymbol, boolean equalRule, IAST leftHandSide, IExpr rightHandSide, int priority)Associate a new "up value" rule with the given priority to this symbol.
Rules with lower numbers have higher priorities.voidreadSymbol(java.io.ObjectInputStream stream)Deserialize the rules associated to this objectIExpr[]reassignSymbolValue(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.voidset(IExpr value)Set the value of the local variable on top of the local variable stackvoidsetAttributes(int attributes)Set the Attributes of this symbol (i.e.voidsetDefaultValue(IExpr expr)Set the general default value for this symbol (i.e.voidsetDefaultValue(int position, IExpr expr)Set the default value at the arguments position for this symbol (i.e.voidsetEvaluator(IEvaluator module)Set the current evaluator which is associated to this symbolvoidwriteSymbol(java.io.ObjectOutputStream stream)Serialize the rules associated to this object-
Methods inherited from interface org.matheclipse.core.interfaces.IExpr
accept, accept, accept, and, apply, apply, asType, compareTo, evaluate, fullFormString, getAt, head, hierarchy, internalFormString, inverse, isAnd, isArcCos, isArcCosh, isArcSin, isArcSinh, isArcTan, isArcTanh, isAST, isAST, isAST, isAST, isAST, isAST, isASTSizeGE, isAtom, isComplex, isComplexInfinity, isComplexNumeric, isCondition, isConstant, isCos, isCosh, isDirectedInfinity, isFalse, isFlatAST, isFraction, isFree, isFree, isFunction, isGEOrdered, isGTOrdered, isInfinity, isInteger, isLEOrdered, isList, isListOfLists, isLog, isLTOrdered, isMatrix, isMember, isMember, isMinusOne, isModule, isNegative, isNegativeInfinity, isNot, isNumber, isNumEqualInteger, isNumeric, isNumericFunction, isNumIntValue, isOne, isOr, isOrderlessAST, isPattern, isPatternExpr, isPatternSequence, isPlus, isPositive, isPower, isRational, isRealFunction, isRuleAST, isSame, isSame, isSequence, isSignedNumber, isSin, isSinh, isSlot, isSlotSequence, isSymbol, isTan, isTanh, isTimes, isTrue, isValue, isVector, isZero, leaves, minus, mod, multiply, negative, or, plus, power, power, replaceAll, replaceAll, replacePart, replaceRepeated, replaceRepeated, replaceSlots, signum, times, topHead, variables2Slots
-
Methods inherited from interface edu.jas.structure.AbelianGroupElem
abs, isZERO, negate, subtract, sum
-
Methods inherited from interface edu.jas.structure.MonoidElem
divide, isONE, isUnit, remainder
-
-
-
-
Field Detail
-
CONSOLE_OUTPUT
static final int CONSOLE_OUTPUT
ISymbol attribute to indicate that a symbols evaluation should be printed to Console with System.out.println();- See Also:
- Constant Field Values
-
CONSTANT
static final int CONSTANT
ISymbol attribute to indicate that a symbol has a constant value- See Also:
- Constant Field Values
-
FLAT
static final int FLAT
ISymbol attribute for an associative function transformation. The evaluation of the function will flatten the arguments list- See Also:
- Constant Field Values
-
HOLDFIRST
static final int HOLDFIRST
ISymbol attribute for a function, where the first argument should not be evaluated- See Also:
- Constant Field Values
-
HOLDREST
static final int HOLDREST
ISymbol attribute for a function, where only the first argument should be evaluated- See Also:
- Constant Field Values
-
HOLDALL
static final int HOLDALL
ISymbol attribute for a function, where no argument should be evaluated- See Also:
- Constant Field Values
-
LISTABLE
static final int LISTABLE
ISymbol attribute for a function with lists as arguments- See Also:
- Constant Field Values
-
NHOLDFIRST
static final int NHOLDFIRST
ISymbol attribute for a function, where the first argument should not be evaluated numerically- See Also:
- Constant Field Values
-
NHOLDREST
static final int NHOLDREST
ISymbol attribute for a function, where the rest of the arguments should not be evaluated numerically.- See Also:
- Constant Field Values
-
NHOLDALL
static final int NHOLDALL
ISymbol attribute for a function, which should not be evaluated numerically- See Also:
- Constant Field Values
-
NOATTRIBUTE
static final int NOATTRIBUTE
ISymbol attribute which means that no attribute is set.- See Also:
- Constant Field Values
-
NUMERICFUNCTION
static final int NUMERICFUNCTION
ISymbol attribute for a numeric function- See Also:
- Constant Field Values
-
PACKAGE_LOADED
static final int PACKAGE_LOADED
ISymbol flag for a symbol which has already loaded it's package definition- See Also:
- Constant Field Values
-
ONEIDENTITY
static final int ONEIDENTITY
ISymbol attribute for a function transformation: f(x) ==> x- See Also:
- Constant Field Values
-
ORDERLESS
static final int ORDERLESS
ISymbol attribute for a commutative function transformation. The evaluation of the function will sort the arguments.- See Also:
- Constant Field Values
-
FLATORDERLESS
static final int FLATORDERLESS
ISymbol attribute combination (ISymbol.FLAT and ISymbol.ORDERLESS)- See Also:
- Constant Field Values
-
DEFAULT_RULE_PRIORITY
static final int DEFAULT_RULE_PRIORITY
The default priority when associating a new rule to a symbol. Lower numbers have higher priorities- See Also:
- Constant Field Values
-
-
Method Detail
-
getEvaluator
IEvaluator getEvaluator()
Get the current evaluator for this symbol- Returns:
- the evaluator which is associated to this symbol or
nullif no evaluator is associated
-
setEvaluator
void setEvaluator(IEvaluator module)
Set the current evaluator which is associated to this symbol
-
isString
boolean isString(java.lang.String symbolName)
Tests if this symbols name equals the given string- Parameters:
symbolName-- Returns:
-
isSymbolName
boolean isSymbolName(java.lang.String name)
Returnstrue, if this symbol has the given name. The comparison of the symbols name with the given name is done according to theConfig.PARSER_USE_LOWERCASE_SYMBOLSsetting.
-
mapConstantDouble
IExpr mapConstantDouble(INumericFunction<IExpr> function)
If this symbol has attributeISymbol.CONSTANTand the symbol's evaluator is of instanceINumericConstant, then apply the constants double value to the given function and return the result, otherwise returnnull.
-
getAttributes
int getAttributes()
Get the Attributes of this symbol (i.e. LISTABLE, FLAT, ORDERLESS,...)- Returns:
- See Also:
FLAT
-
setAttributes
void setAttributes(int attributes)
Set the Attributes of this symbol (i.e. LISTABLE, FLAT, ORDERLESS,...)- Parameters:
attributes- the Attributes of this symbol
-
pushLocalVariable
void pushLocalVariable()
Create a new variable placeholder on the symbols variable stack
-
pushLocalVariable
void pushLocalVariable(IExpr localValue)
Create a new variable placeholder on the symbols variable stack and set the local value
-
popLocalVariable
void popLocalVariable()
Delete the topmost placeholder from the local variable stack
-
hasLocalVariableStack
boolean hasLocalVariableStack()
Is a local variable stack created for this symbol ?- Returns:
trueif this symbol has a local variable stack
-
get
IExpr get()
Get the topmost value from the local variable stack- Returns:
nullif no local variable is defined
-
set
void set(IExpr value)
Set the value of the local variable on top of the local variable stack
-
putDownRule
IPatternMatcher putDownRule(ISymbol symbol, boolean equalRule, IExpr leftHandSide, IExpr rightHandSide, boolean packageMode)
Associate a new "down value" rule with default priority to this symbol.- Parameters:
equalRule-trueif the leftHandSide could be matched with equalityleftHandSide-rightHandSide-packageMode- TODO- Returns:
- See Also:
DEFAULT_RULE_PRIORITY
-
putDownRule
IPatternMatcher putDownRule(ISymbol symbol, boolean equalRule, IExpr leftHandSide, IExpr rightHandSide, int priority, boolean packageMode)
Associate a new rule with the given priority to this symbol.
Rules with lower numbers have higher priorities.- Parameters:
equalRule-trueif the leftHandSide could be matched with equalityleftHandSide-rightHandSide-priority- the priority of the rulepackageMode- TODOcondition- additional condition for rules containing patternsmoduleInitializer- if the right-hand-side is a module, this is the initializer part- Returns:
- See Also:
DEFAULT_RULE_PRIORITY
-
putDownRule
PatternMatcher putDownRule(PatternMatcherAndInvoker pmEvaluator)
Associate a new rule, which invokes a method, to this symbol.
-
putUpRule
IPatternMatcher putUpRule(ISymbol symbol, boolean equalRule, IAST leftHandSide, IExpr rightHandSide)
Associate a new "up value" rule with default priority to this symbol.- Parameters:
equalRule-trueif the leftHandSide could be matched with equalityleftHandSide-rightHandSide-- Returns:
- See Also:
DEFAULT_RULE_PRIORITY
-
putUpRule
IPatternMatcher putUpRule(ISymbol setSymbol, boolean equalRule, IAST leftHandSide, IExpr rightHandSide, int priority)
Associate a new "up value" rule with the given priority to this symbol.
Rules with lower numbers have higher priorities.- Parameters:
equalRule-trueif the leftHandSide could be matched with equalityleftHandSide-rightHandSide-condition- additional condition for rules containing patternsmoduleInitializer- if the right-hand-side is a module, this is the initializer partpriority- the priority of the rule- Returns:
- See Also:
DEFAULT_RULE_PRIORITY
-
evalDownRule
IExpr evalDownRule(IEvaluationEngine engine, IExpr expression)
Evaluate the given expression for the "down value" rules associated with this symbol- Parameters:
engine-expression-- Returns:
-
evalUpRule
IExpr evalUpRule(IEvaluationEngine engine, IExpr expression)
Evaluate the given expression for the "up value" rules associated with this symbol- Parameters:
engine-expression-- Returns:
-
getDefaultValue
IExpr getDefaultValue()
Get the general default value for this symbol (i.e.1is the default value forTimes,0is the default value forPlus). The general default value is used in pattern-matching for expressions likea_. * b_. + c_- Returns:
- the default value or
nullif undefined.
-
getDefaultValue
IExpr getDefaultValue(int position)
Get the default value at the arguments position for this symbol (i.e.1is the default value forPoweratposition2). The default value is used in pattern-matching for expressions likea ^ b_.- Parameters:
position- the position for the default value- Returns:
- the default value or
nullif undefined.
-
setDefaultValue
void setDefaultValue(IExpr expr)
Set the general default value for this symbol (i.e.1is the default value forTimes,0is the default value forPlus). The general default value is used in pattern-matching for expressions likea_. * b_. + c_- Parameters:
expr- the general default value- See Also:
getDefaultValue()
-
setDefaultValue
void setDefaultValue(int position, IExpr expr)Set the default value at the arguments position for this symbol (i.e.1is the default value forPoweratposition2). The default value is used in pattern-matching for expressions likea ^ b_.- Parameters:
position- the position for the default valueexpr- the default value for the given position- See Also:
getDefaultValue(int)
-
getAssignedValue
IExpr getAssignedValue()
Get the value which is assigned to the symbol ornull, if no value is assigned.- Returns:
null, if no value is assigned.
-
reassignSymbolValue
IExpr[] reassignSymbolValue(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.- Parameters:
function- the function which should be appliedfunctionSymbol- TODO- Returns:
- an array with the currently assigned value of the symbol and the new calculated value of the symbol or
nullif the reassignment isn't possible.
-
clear
void clear(EvalEngine engine)
Clear the associated rules for this symbol
-
clearAll
void clearAll(EvalEngine engine)
Clear all associated rules and attributes for this symbol
-
definition
java.util.List<IAST> definition()
Return a list of the rules associated to this symbol- Returns:
-
definitionToString
java.lang.String definitionToString() throws java.io.IOExceptionReturn the rules associated to this symbol in String representation- Returns:
- Throws:
java.io.IOException
-
readSymbol
void readSymbol(java.io.ObjectInputStream stream) throws java.io.IOExceptionDeserialize the rules associated to this object- Parameters:
stream-- Throws:
java.io.IOException
-
writeSymbol
void writeSymbol(java.io.ObjectOutputStream stream) throws java.io.IOExceptionSerialize the rules associated to this object- Parameters:
stream-- Throws:
java.io.IOException
-
-
DMelt 3.0 © DataMelt by jWork.ORG