Class ASTRRBTree
- java.lang.Object
-
- org.matheclipse.core.expression.AbstractAST
-
- org.matheclipse.core.expression.ASTRRBTree
-
- All Implemented Interfaces:
edu.jas.structure.AbelianGroupElem<IExpr>
,edu.jas.structure.Element<IExpr>
,edu.jas.structure.GcdRingElem<IExpr>
,edu.jas.structure.MonoidElem<IExpr>
,edu.jas.structure.RingElem<IExpr>
,Externalizable
,Serializable
,Cloneable
,Comparable<IExpr>
,Iterable<IExpr>
,RandomAccess
,org.hipparchus.CalculusFieldElement<IExpr>
,org.hipparchus.FieldElement<IExpr>
,IAST
,IASTAppendable
,IASTMutable
,IExpr
,ITensorAccess
- Direct Known Subclasses:
ASTAssociation
public class ASTRRBTree extends AbstractAST implements IASTAppendable, Externalizable, RandomAccess
Immutable (A)bstract (S)yntax (T)ree of a given function implemented as an RRB Tree. The implmentation is based on the paper, "RRB-Trees: Efficient Immutable Vectors" by Phil Bagwell and Tiark Rompf, with the following differences:
- the Relaxed nodes can be sized between n/3 and 2n/3 (Bagwell/Rompf specify n and n-1)
- the Join operation sticks the shorter tree unaltered into the larger tree (except for verysmall trees which just get concatenated).
In Symja, an abstract syntax tree (AST), is a tree representation of the abstract syntactic structure of the Symja source code. Each node of the tree denotes a construct occurring in the source code. The syntax is 'abstract' in the sense that it does not represent every detail that appears in the real syntax. For instance, grouping parentheses are implicit in the tree structure, and a syntactic construct such as a
Sin[x]
expression will be denoted by an AST with 2 nodes. One node for the headerSin
and one node for the argumentx
. Internally an AST is represented as ajava.util.List
which contains- the operator of a function (i.e. the "header"-symbol: Sin, Cos, Inverse, Plus,
Times,...) at index
0
and - the
n
arguments of a function in the index1 to n
- See Also:
AST
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.matheclipse.core.expression.AbstractAST
AbstractAST.ASTIterator, AbstractAST.NILPointer
-
Nested classes/interfaces inherited from interface org.matheclipse.core.interfaces.IAST
IAST.PROPERTY
-
Nested classes/interfaces inherited from interface org.matheclipse.core.interfaces.IASTAppendable
IASTAppendable.CollectorImpl<T,A,R>
-
Nested classes/interfaces inherited from interface org.matheclipse.core.interfaces.IExpr
IExpr.COMPARE_TERNARY
-
-
Field Summary
Fields Modifier and Type Field Description protected org.organicdesign.fp.collections.RrbTree.MutRrbt<IExpr>
rrbTree
The underlying RRB Tree-
Fields inherited from class org.matheclipse.core.expression.AbstractAST
fEvalFlags, hashValue
-
Fields inherited from interface org.matheclipse.core.interfaces.IAST
BUILT_IN_EVALED, CONTAINS_DEFAULT_PATTERN, CONTAINS_NO_DEFAULT_PATTERN_MASK, CONTAINS_NO_PATTERN, CONTAINS_NUMERIC_ARG, CONTAINS_PATTERN, CONTAINS_PATTERN_EXPR, CONTAINS_PATTERN_SEQUENCE, IS_ALL_EXPANDED, IS_DECOMPOSED_PARTIAL_FRACTION, IS_DERIVATIVE_EVALED, IS_EXPANDED, IS_FLAT_ORDERLESS_EVALED, IS_FLATTENED, IS_FLATTENED_OR_SORTED_MASK, IS_HASH_EVALED, IS_LISTABLE_THREADED, IS_MATRIX, IS_MATRIX_OR_VECTOR, IS_NOT_NUMERIC_FUNCTION, IS_NOT_NUMERIC_FUNCTION_OR_LIST, IS_NUMERIC_FUNCTION, IS_NUMERIC_FUNCTION_OR_LIST, IS_NUMERIC_MASK, IS_SORTED, IS_VECTOR, NO_FLAG, NUMERIC_ARBITRARY_EVALED, NUMERIC_DOUBLE_EVALED, OUTPUT_MULTILINE, SEQUENCE_FLATTENED, TIMES_PARSED_IMPLICIT
-
Fields inherited from interface org.matheclipse.core.interfaces.IExpr
ASTID, BDDEXPRID, BIOSEQUENCEID, BLANKID, BYTEARRAYID, COMPILEFUNCTONID, COMPLEXID, DATAID, DATASETID, DATEOBJECTEXPRID, DISPATCHID, DOUBLECOMPLEXID, DOUBLEID, FILEEXPRID, FITTEDMODELID, FRACTIONID, GEOPOSITIONID, GRAPHEXPRID, IMAGEID, INPUTSTREAMEXPRID, INTEGERID, INTERPOLATEDFUNCTONID, JAVACLASSEXPRID, JAVAOBJECTEXPRID, LINEARSOLVEUNCTONID, METHODSYMBOLID, NUMERICARRAYID, OUTPUTSTREAMEXPRID, PATTERNID, QUANTITYID, SERIESID, SPARSEARRAYID, STRINGID, SYMBOLID, TESTREPORTOBJECT, TESTRESULTOBJECT, TIMEOBJECTEXPRID
-
-
Constructor Summary
Constructors Constructor Description ASTRRBTree()
ASTRRBTree(int size, boolean test)
ASTRRBTree(IAST ast)
Copy constructor.ASTRRBTree(IExpr[] array)
ASTRRBTree(org.organicdesign.fp.collections.RrbTree.ImRrbt<IExpr> list)
ASTRRBTree(org.organicdesign.fp.collections.RrbTree.MutRrbt<IExpr> list)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(int location, IExpr expr)
Inserts the specified object into thisList
at the specified location.boolean
append(IExpr expr)
Adds the specified expression at the end ofthis
.boolean
appendAll(int location, Collection<? extends IExpr> collection)
Inserts the objects in the specified collection at the specified location in this AST.boolean
appendAll(Collection<? extends IExpr> collection)
Adds the objects in the specified collection to the end of thisList
.boolean
appendAll(List<? extends IExpr> list, int startPosition, int endPosition)
Appends all elements from offsetstartPosition
toendPosition
in the specified list to the end of this AST.boolean
appendAll(Map<? extends IExpr,? extends IExpr> map)
Adds the mappings in the specified map asRule(...)
to the end of thisList
.boolean
appendAll(IAST ast, int startPosition, int endPosition)
Appends all elements from offsetstartPosition
toendPosition
in the specified AST to the end of this AST.boolean
appendAll(IExpr[] args, int startPosition, int endPosition)
Appends all elements from offsetstartPosition
toendPosition
in the specified list to the end of this AST.IASTAppendable
appendArgs(int start, int end, IntFunction<IExpr> function)
Appends all elements generated by the givenIntFunction.apply(int)
method from indexstart
inclusive toend
exclusive.boolean
appendArgs(IAST ast)
Appends all of the arguments (starting from offset1
) in the specifiedast
to the end ofthis
AST.boolean
appendArgs(IAST ast, int untilPosition)
Appends all of the arguments (starting from offset1
) in the specified AST up to positionuntilPosition
exclusive.IAST
appendOneIdentity(IAST value)
Append ansubAST
with attributeOneIdentity
for example Plus[] or Times[].IExpr
arg1()
Get the first argument (i.e.IExpr
arg2()
Get the second argument (i.e.IExpr
arg3()
Get the third argument (i.e.IExpr
arg4()
Get the fourth argument (i.e.IExpr
arg5()
Get the fifth argument (i.e.int
argSize()
Returns the number of arguments in thisIAST
.Set<IExpr>
asSet()
Collect all arguments of this AST in a new set.void
clear()
Removes all elements from thisIAST
, leaving it empty (optional).IAST
clone()
Returns a newHMArrayList
with the same elements, the same size and the same capacity as thisHMArrayList
.ASTRRBTree
copy()
Returns a shallow copy of thisIAST
instance (the elements themselves are not copied).IASTAppendable
copyAppendable()
Returns a shallow copy of thisIAST
instance (the elements themselves are not copied).IASTAppendable
copyAppendable(int additionalCapacity)
Returns a shallow copy of thisIAST
instance (the elements themselves are not copied).void
ensureCapacity(int size)
boolean
equals(Object obj)
boolean
exists(Predicate<? super IExpr> predicate, int startOffset)
Check all elements by applying thepredicate
to each argument in thisAST
and returntrue
if one of the arguments starting from indexstartOffset
satisfy the predicate.boolean
exists(ObjIntPredicate<? super IExpr> predicate, int startOffset)
Check all elements by applying thepredicate
to each argument in thisAST
and returntrue
if one of the arguments starting from indexstartOffset
satisfy the predicate.boolean
forAll(Predicate<? super IExpr> predicate, int startOffset)
Check all elements by applying thepredicate
to each argument in thisAST
and returntrue
if all of the arguments starting from indexstartOffset
satisfy the predicate.boolean
forAll(ObjIntPredicate<? super IExpr> predicate, int startOffset)
Check all elements by applying thepredicate
to each argument in thisAST
and returntrue
if all of the arguments starting from indexstartOffset
satisfy the predicate.void
forEach(int start, int end, Consumer<? super IExpr> action)
Consume allvalue-elements
generated by the given function from indexstart
inclusive toend
exclusive.void
forEach(int start, int end, ObjIntConsumer<? super IExpr> action)
Consume allvalue-elements
generated by the given function from indexstart
inclusive toend
exclusive.IExpr
get(int location)
Returns the element at the specified location in thisIAST
.IAST
getItems(int[] items, int length)
Returnslength
number of elements specified in theitems
position array in thisIAST
.int
hashCode()
FNV-1 hash code of thisIAST
.IExpr
head()
If this object is an instance ofIAST
get the first element (offset 0) of theIAST
list (i.e.boolean
isAST0()
Test if this expression is anIAST
function, which contains a header element (i.e.boolean
isAST1()
Test if this expression is anIAST
function, which contains a header element (i.e.boolean
isAST2()
Test if this expression is anIAST
function, which contains a header element (i.e.boolean
isAST3()
Test if this expression is anIAST
function, which contains a header element (i.e.boolean
isList()
Test if this expression is a list (i.e.boolean
isSameHead(ISymbol head)
Check if the object at index 0 (i.e.boolean
isSameHead(ISymbol head, int length)
Check if the object at index 0 (i.e.boolean
isSameHead(ISymbol head, int minLength, int maxLength)
Check if the object at index 0 (i.e.boolean
isSameHeadSizeGE(ISymbol head, int length)
Check if the object at index 0 (i.e.static ASTRRBTree
newInstance(int initialCapacity, IExpr head)
void
readExternal(ObjectInput objectInput)
IExpr
remove(int location)
Removes the object at the specified location from thisIAST
.void
removeRange(int start, int end)
Removes the objects in the specified range from the start to the end, but not including the end index.IExpr
set(int location, IExpr object)
Replaces the element at the specified location in thisArrayList
with the specified object.IASTMutable
setAtCopy(int i, IExpr expr)
Create a shallow copy of thisIAST
instance (the elements themselves are not copied) and set theexpr
at the givenposition
.int
size()
Returns the number of elements in thisArrayList
.void
sortInplace(Comparator<IExpr> comparator)
Sortthis
in place using functioncomparator#compare(a, b)
.IExpr[]
toArray()
Returns an array containing all elements contained in thisList
.void
writeExternal(ObjectOutput objectOutput)
-
Methods inherited from class org.matheclipse.core.expression.AbstractAST
accept, accept, accept, accept, addEvalFlags, appendAtClone, appendClone, apply, apply, apply, asNumerDenom, asPowersDict, asType, clearHashCache, compareAdjacent, compareTo, contains, copyAlloc, copyFrom, copyFrom, copyHead, copyHead, copyUntil, copyUntil, count, depth, determinePrecision, equalsArgs, equalsAt, equalsFromPosition, equalTernary, evalEvaluate, evalNumber, evalReal, evaluate, extractConditionalExpression, filter, filter, filter, filter, filter, filterFunction, filterNIL, findFirst, foldLeft, foldRight, forAllLeaves, forAllLeaves, forEach, forEach, forEachRule, forEachRule, fullFormString, fullFormString, gcd, get, getArg, getAST, getAt, getEvalFlags, getHashCache, getIndex, getInt, getList, getNumber, getOptionalValue, getPart, getPart, getProperty, getUnevaluated, has, hasTrigonometricFunction, hierarchy, indexOf, indexOf, internalFormString, internalJavaString, internalScalaString, intSlot, isAbs, isAllExpanded, isAlternatives, isAnd, isArcCos, isArcCosh, isArcSin, isArcSinh, isArcTan, isArcTanh, isAST, isAST, isAST, isAST, isAST, isAST, isAST, isASTSizeGE, isAtom, isBooleanFormula, isBooleanFunction, isBooleanResult, isComparatorFunction, isComplexInfinity, isCondition, isConditionalExpression, isConjugate, isContinuousDistribution, isCos, isCosh, isDefer, isDerivative, isDerivativeAST1, isDirectedInfinity, isDirectedInfinity, isDiscreteDistribution, isDistribution, isEdge, isEmpty, isEmptyIntervalData, isEmptyList, isEqual, isEvalFlagOff, isEvalFlagOn, isExcept, isExpanded, isFlatAST, isFree, isFree, isFreeAST, isFreeAST, isFreeAt, isFreeOfPatterns, isFunction, isFunctionID, isGEOrdered, isGTOrdered, isHoldAllCompleteAST, isHoldPatternOrLiteral, isHyperbolicFunction, isInexactVector, isInfinity, isIntegerResult, isInterval, isInterval1, isIntervalData, isList, isList, isListableAST, isListOfEdges, isListOfLists, isListOfMatrices, isListOfPoints, isListOfRules, isListOfRulesOrAssociation, isListOfStrings, isLog, isMatrix, isMatrixIgnore, isMember, isModule, isModuleOrWithCondition, isNegative, isNegativeInfinity, isNegativeResult, isNonEmptyList, isNonNegativeResult, isNot, isNotEmpty, isNumericArgument, isNumericAST, isNumericFunction, isNumericFunction, isNumericFunction, isNumericFunction, isNumericMode, isOneIdentityAST1, isOptional, isOr, isOrderlessAST, isPatternDefault, isPatternExpr, isPatternMatchingFunction, isPatternTest, isPiecewise, isPlus, isPlus2, isPlus3, isPlusTimesPower, isPolynomial, isPolynomial, isPolynomialOfMaxDegree, isPolynomialOfMaxDegree, isPolynomialStruct, isPositive, isPositiveResult, isPossibleZero, isPower, isPureFunction, isRationalResult, isRealMatrix, isRealResult, isRealVector, isRule, isRuleAST, isRuleDelayed, isSame, isSame, isSequence, isSin, isSinh, isSlot, isSlotSequence, isSpan, isSubscript, isTan, isTanh, isTimes, isTimes2, isTimes3, isTrigFunction, isUnevaluated, isUnit, isValue, isVariable, isVector, isWith, iterator, last, lastIndexOf, leafCount, leafCountSimplify, linear, linearPower, lower, makeAST, makeList, map, map, map, map, map, map, mapLeaf, mapLeft, mapMatrixColumns, mapReverse, mapRight, mapThread, mapThread, mapThread, mapThreadEvaled, mapThreadEvaled, negative, normal, oneIdentity, opposite, optional, orElse, partition, partitionPlus, partitionTimes, patternHashCode, prependClone, putProperty, remove, removeAtClone, removeAtCopy, removeIf, removePositionsAtCopy, removePositionsAtCopy, reverse, rewrite, rotateLeft, rotateRight, select, select, setAtClone, setEvalFlags, setPart, signum, splice, stream, stream, timesDistributed, toBooleanMatrix, toBooleanVector, toBooleValueVector, toByteMatrix, toComplexMatrix, toComplexVector, toDoubleMatrix, toDoubleMatrixIgnore, toDoubleVector, toDoubleVectorIgnore, toIntMatrix, toIntVector, topHead, toRealMatrixIgnore, toString, upper, variables2Slots
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.hipparchus.CalculusFieldElement
getExponent, isFinite, isInfinite, isNaN, norm, round
-
Methods inherited from interface org.matheclipse.core.interfaces.IAST
acceptChecked, addEvalFlags, appendAtClone, appendClone, apply, apply, apply, clearHashCache, compareAdjacent, contains, containsAll, copyAST, copyFrom, copyFrom, copyHead, copyHead, copyTo, copyTo, copyUntil, copyUntil, count, count, equalsAt, exists, exists, existsLeft, extract, extractConditionalExpression, filter, filter, filter, filter, filter, filterNIL, findFirst, findFirstEquals, first, foldLeft, foldRight, forAll, forAll, forAllLeaves, forAllLeaves, forEach, forEach, forEach, forEach, forEach, forEach, forEachRule, forEachRule, functionEvaled, get, getAST, getEvalFlags, getHashCache, getInt, getList, getNumber, getPart, getPart, getRule, getRule, getRule, getUnevaluated, getValue, hasNumericArgument, hasOptionalArgument, hasTrigonometricFunction, isASTOrAssociation, isEmpty, isEvalFlagOff, isEvalFlagOn, isFreeAt, isNotDefined, isNumberOrInfinity, isPatternMatchingFunction, isRealsIntervalData, isTimes, iterator, joinToString, joinToString, lastIndexOf, map, map, map, map, map, map, mapAt, mapLeaf, mapLeaf, mapLeft, mapMatrixColumns, mapReverse, mapRight, mapThread, mapThread, mapThread, mapThreadEvaled, mapThreadEvaled, most, oneIdentity, oneIdentity0, oneIdentity1, orElse, patternHashCode, prependClone, remove, removeAtClone, removeAtCopy, removeFromEnd, removeFromStart, removeIf, removePositionsAtCopy, removePositionsAtCopy, rest, reverse, rotateLeft, rotateRight, second, select, select, setAtClone, setEvalFlags, slice, splice, splice, stream, stream, stream0, toArray, topHead
-
Methods inherited from interface org.matheclipse.core.interfaces.IASTAppendable
append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, appendArgs, appendIfPresent, appendIfPresent, appendRule, ifAppendable, pop, prependRule, remove
-
Methods inherited from interface org.matheclipse.core.interfaces.IASTMutable
setApply, setArgs, setArgs, setIf, setIfPresent, setPart, setValue, sortInplace
-
Methods inherited from interface org.matheclipse.core.interfaces.IExpr
$div, $minus, $plus, $times, $up, abs, accept, accept, accept, accept, acos, acosh, add, add, and, apply, apply, asBaseExp, asCoeffAdd, asCoeffAdd, asCoeffAdd, asCoeffExponent, asCoeffmul, asCoeffmul, asCoeffmul, asCoeffmul, asCoeffMul, asCoeffMul, asin, asinh, asLeadingTerm, asLeadingTerm, asLeadingTerm, asLeadingTerm, asNumerDenom, asPowersDict, asType, atan, atan2, atanh, base, cancel, cbrt, ceil, compareTo, compareToNumerical, complexArg, conjugate, constantArray, copySign, copySign, copySign, cos, cosh, dec, depth, determinePrecision, divide, divide, egcd, equalsArgs, equalsArgs, equalTernary, equalTo, erf, erfc, eval, eval, evalAsLeadingTerm, evalBinary64, evalComplex, evalDouble, evalf, evalf, evalfc, evalfc, evalNIL, evalNumber, evalReal, evaluate, evaluateHead, evaluateOrElse, exp, expm1, exponent, factory, floor, fresnelC, fresnelS, fullFormString, gaussianIntegers, gcd, getArg, getAt, getField, getOptionalValue, getPi, getReal, greater, greaterEqual, greaterEqualThan, greaterEqualThan, greaterThan, greaterThan, has, has, has, has, hasComplexNumber, hasFree, headID, hierarchy, hypergeometric0F1, hypergeometric1F1, hypergeometric2F1, hypot, ifPresent, im, inc, indexOf, indexOf, indexOf, internalFormString, internalJavaString, internalScalaString, intSlot, inverse, isAbs, isAllExpanded, isAlternatives, isAnd, isArcCos, isArcCosh, isArcSin, isArcSinh, isArcTan, isArcTanh, isAssociation, isAST, isAST, isAST, isAST, isAST, isAST, isAST, isASTSizeGE, isAtom, isBlank, isBooleanFormula, isBooleanFormulaSymbol, isBooleanFunction, isBooleanResult, isBuiltInSymbol, isBuiltInSymbolID, isComparatorFunction, isComparatorFunctionSymbol, isComplex, isComplexInfinity, isComplexNumeric, isCondition, isConditionalExpression, isConjugate, isConstantAttribute, isContinuousDistribution, isCoreFunctionSymbol, isCos, isCosh, isDataset, isDefer, isDerivative, isDerivativeAST1, isDirectedInfinity, isDirectedInfinity, isDiscreteDistribution, isDistribution, isE, isEdge, isEmptyIntervalData, isEmptyList, isEqual, isEvenResult, isExactNumber, isExcept, isExp, isExpanded, isFactorSqrtExpr, isFalse, isFlatAST, isFraction, isFree, isFree, isFree, isFree, isFreeAST, isFreeAST, isFreeOfPatterns, isFunction, isFunctionID, isGEOrdered, isGTOrdered, isHoldAllCompleteAST, isHoldOrHoldFormOrDefer, isHoldPatternOrLiteral, isHyperbolicFunction, isImaginaryUnit, isIndeterminate, isInexactNumber, isInexactVector, isInfinity, isInteger, isIntegerResult, isInterval, isInterval1, isIntervalData, isInvalid, isLEOrdered, isList, isList, isList1, isList2, isList3, isList4, isListableAST, isListOfEdges, isListOfLists, isListOfMatrices, isListOfPoints, isListOfRules, isListOfRules, isListOfRulesOrAssociation, isListOfStrings, isListOrAssociation, isLog, isLTOrdered, isMachineNumber, isMathematicalIntegerNegative, isMathematicalIntegerNonNegative, isMatrix, isMatrix, isMatrixIgnore, isMember, isMember, isMinusOne, isModule, isModuleOrWithCondition, isNegative, isNegativeImaginaryUnit, isNegativeInfinity, isNegativeResult, isNegativeSigned, isNIL, isNonEmptyList, isNonNegativeResult, isNonZeroComplexResult, isNonZeroRealResult, isNot, isNotEmpty, isNumber, isNumEqualInteger, isNumEqualRational, isNumeric, isNumericArgument, isNumericArgument, isNumericArray, isNumericAST, isNumericFunction, isNumericFunction, isNumericFunction, isNumericFunction, isNumericFunction, isNumericMode, isNumIntValue, isOne, isONE, isOneIdentityAST1, isOptional, isOptionsPattern, isOr, isOrderlessAST, isPattern, isPatternDefault, isPatternExpr, isPatternOptional, isPatternSequence, isPatternTest, isPi, isPiecewise, isPlus, isPlus2, isPlus3, isPlusTimesPower, isPolynomial, isPolynomial, isPolynomialOfMaxDegree, isPolynomialStruct, isPositive, isPositiveResult, isPossibleZero, isPower, isPowerReciprocal, isPredicateFunctionSymbol, isPresent, isPureFunction, isQuantity, isRational, isRationalResult, isRationalValue, isReal, isRealConstant, isRealMatrix, isRealNumber, isRealResult, isRealVector, isReNegativeResult, isRepeated, isRePositiveResult, isRGBColor, isRule, isRuleAST, isRuleDelayed, isSame, isSame, isSequence, isSin, isSinh, isSlot, isSlotSequence, isSpan, isSparseArray, isSqrt, isSqrtExpr, isString, isString, isStringIgnoreCase, isSubscript, isSymbol, isSymbolOrPattern, isTan, isTanh, isTimes2, isTimes3, isTrigFunction, isTrue, isUndefined, isUnequalResult, isUnevaluated, isUnit, isValue, isVariable, isVariable, isVector, isWith, isZero, isZERO, isZeroResult, last, leadTerm, leadTerm, leafCount, leafCountSimplify, less, lessEqual, lessEqualThan, lessEqualThan, lessThan, lessThan, linear, linearCombination, linearCombination, linearCombination, linearCombination, linearCombination, linearCombination, linearCombination, linearCombination, linearPower, log, log10, log1p, lower, makeAST, makeList, mapExpr, minus, mod, multiply, multiply, multiply, multiplyDistributed, negate, negative, newInstance, normal, one, opposite, optional, or, orElse, orElseGet, orElseThrow, partition, partitionPlus, partitionTimes, plus, pow, pow, pow, power, power, re, reciprocal, remainder, remainder, replaceAll, replaceAll, replaceAll, replacePart, replaceRepeated, replaceRepeated, replaceRepeated, rewrite, rint, rootN, roundExpr, scalb, sign, signum, sin, sinCos, sinh, sinhCosh, sqr, sqrt, subs, subtract, subtract, sum, tan, tanh, times, timesDistributed, toBooleanMatrix, toBooleanVector, toBooleValueVector, toByteMatrix, toComplexMatrix, toComplexVector, toDegrees, toDoubleDefault, toDoubleDefault, toDoubleMatrix, toDoubleMatrixIgnore, toDoubleVector, toDoubleVectorIgnore, together, toIntDefault, toIntDefault, toIntMatrix, toIntVector, toLongDefault, toLongDefault, toMMA, toNumber, toNumber, toRadians, toRealMatrix, toRealMatrixIgnore, toRealVector, toScript, toScriptFactory, toWolframString, trigsimp, ulp, unequalTo, unitStep, upper, variables2Slots, zero
-
Methods inherited from interface org.matheclipse.core.interfaces.ITensorAccess
getIndex
-
Methods inherited from interface java.lang.Iterable
spliterator
-
-
-
-
Field Detail
-
rrbTree
protected org.organicdesign.fp.collections.RrbTree.MutRrbt<IExpr> rrbTree
The underlying RRB Tree
-
-
Constructor Detail
-
ASTRRBTree
public ASTRRBTree()
-
ASTRRBTree
public ASTRRBTree(int size, boolean test)
-
ASTRRBTree
public ASTRRBTree(IAST ast)
Copy constructor. Do a shallow copy of allast
elements to a newASTRRBTree
.- Parameters:
ast
-
-
ASTRRBTree
public ASTRRBTree(org.organicdesign.fp.collections.RrbTree.MutRrbt<IExpr> list)
-
ASTRRBTree
public ASTRRBTree(org.organicdesign.fp.collections.RrbTree.ImRrbt<IExpr> list)
-
ASTRRBTree
public ASTRRBTree(IExpr[] array)
-
-
Method Detail
-
ensureCapacity
public void ensureCapacity(int size)
-
newInstance
public static ASTRRBTree newInstance(int initialCapacity, IExpr head)
-
arg1
public IExpr arg1()
Get the first argument (i.e. the second element of the underlying list structure) of theAST
function (i.e. get(1) ).
Example: for the AST representing the expressionSin(x)
,arg1()
returnsx
.- Specified by:
arg1
in interfaceIAST
- Returns:
- the first argument of the function represented by this
AST
. - See Also:
IExpr.head()
-
arg2
public IExpr arg2()
Get the second argument (i.e. the third element of the underlying list structure) of theAST
function (i.e. get(2) ).
Example: for the AST representing the expressionx^y
(i.e.Power(x, y)
),arg2()
returnsy
.- Specified by:
arg2
in interfaceIAST
- Returns:
- the second argument of the function represented by this
AST
. - See Also:
IExpr.head()
-
arg3
public IExpr arg3()
Get the third argument (i.e. the fourth element of the underlying list structure) of theAST
function (i.e. get(3) ).
Example: for the AST representing the expressionf(a, b, c)
,arg3()
returnsc
.- Specified by:
arg3
in interfaceIAST
- Returns:
- the third argument of the function represented by this
AST
. - See Also:
IExpr.head()
-
arg4
public IExpr arg4()
Get the fourth argument (i.e. the fifth element of the underlying list structure) of theAST
function (i.e. get(4) ).
Example: for the AST representing the expressionf(a, b ,c, d)
,arg4()
returnsd
.- Specified by:
arg4
in interfaceIAST
- Returns:
- the fourth argument of the function represented by this
AST
. - See Also:
IExpr.head()
-
arg5
public IExpr arg5()
Get the fifth argument (i.e. the sixth element of the underlying list structure) of theAST
function (i.e. get(5) ).
Example: for the AST representing the expressionf(a, b ,c, d, e)
,arg5()
returnse
.- Specified by:
arg5
in interfaceIAST
- Returns:
- the fifth argument of the function represented by this
AST
. - See Also:
IExpr.head()
-
argSize
public int argSize()
Returns the number of arguments in thisIAST
. The number of arguments equalssize() - 1
(i.e. the number of elements minus 1). If this is an atom return size-1
.- Specified by:
argSize
in interfaceIAST
- Specified by:
argSize
in interfaceIExpr
- Returns:
- the number of arguments in this
IAST
. - See Also:
IExpr.size()
-
asSet
public Set<IExpr> asSet()
Description copied from interface:IAST
Collect all arguments of this AST in a new set.- Specified by:
asSet
in interfaceIAST
- Overrides:
asSet
in classAbstractAST
- Returns:
null
if a set couldn't be created
-
clone
public IAST clone()
Returns a newHMArrayList
with the same elements, the same size and the same capacity as thisHMArrayList
.
-
copy
public ASTRRBTree copy()
Returns a shallow copy of this
IAST
instance (the elements themselves are not copied). In contrast to theIAST.copyAppendable()
method, this method returns exactly the same type forAST0, AST1, AST2, AST3
and tries to transformAST
objects toAST0, AST1, AST2, AST3
if possible.Because it's not allowed to set the header object (offset 0) to an arbitrary expression after a
copy()
, this method should only be used if the arguments (offset 1..argSize) should be set to new expressions.
-
copyAppendable
public IASTAppendable copyAppendable()
Description copied from interface:IAST
Returns a shallow copy of this
IAST
instance (the elements themselves are not copied). In contrast to theIAST.copy()
method, this method doesn't return exactly the same type for a givenAST0, AST1, AST2, AST3...
object but transforms it into a newAST
object, so that additional arguments could be appended at the end.This also allows to set the header object to an arbitrary expression.
- Specified by:
copyAppendable
in interfaceIAST
- Returns:
- a copy of this
IAST
instance.
-
copyAppendable
public IASTAppendable copyAppendable(int additionalCapacity)
Description copied from interface:IAST
Returns a shallow copy of this
IAST
instance (the elements themselves are not copied). In contrast to theIAST.copy()
method, this method doesn't return exactly the same type for a givenAST0, AST1, AST2, AST3...
object but transforms it into a newAST
object, so that additional arguments could be appended at the end.This also allows to set the header object to an arbitrary expression.
- Specified by:
copyAppendable
in interfaceIAST
- Returns:
- a copy of this
IAST
instance.
-
equals
public boolean equals(Object obj)
- Specified by:
equals
in interfaceedu.jas.structure.Element<IExpr>
- Overrides:
equals
in classAbstractAST
-
exists
public boolean exists(ObjIntPredicate<? super IExpr> predicate, int startOffset)
Check all elements by applying thepredicate
to each argument in thisAST
and returntrue
if one of the arguments starting from indexstartOffset
satisfy the predicate.- Specified by:
exists
in interfaceIAST
- Overrides:
exists
in classAbstractAST
- Parameters:
predicate
- the predicate which filters each argument in thisAST
startOffset
- start offset from which the element have to be tested- Returns:
- the
true
if the predicate is true the first time orfalse
otherwise
-
exists
public boolean exists(Predicate<? super IExpr> predicate, int startOffset)
Check all elements by applying thepredicate
to each argument in thisAST
and returntrue
if one of the arguments starting from indexstartOffset
satisfy the predicate.- Specified by:
exists
in interfaceIAST
- Overrides:
exists
in classAbstractAST
- Parameters:
predicate
- the predicate which filters each argument in thisAST
startOffset
- start offset from which the element have to be tested- Returns:
- the
true
if the predicate is true the first time orfalse
otherwise
-
forAll
public boolean forAll(ObjIntPredicate<? super IExpr> predicate, int startOffset)
Check all elements by applying thepredicate
to each argument in thisAST
and returntrue
if all of the arguments starting from indexstartOffset
satisfy the predicate.Note: If this is an
IAssociation
the rule at the position will be returned.- Specified by:
forAll
in interfaceIAST
- Overrides:
forAll
in classAbstractAST
- Parameters:
predicate
- the predicate which filters each argument in thisAST
startOffset
- start offset from which the element have to be tested- Returns:
true
if the predicate is true for all elements orfalse
otherwise
-
forAll
public boolean forAll(Predicate<? super IExpr> predicate, int startOffset)
Check all elements by applying thepredicate
to each argument in thisAST
and returntrue
if all of the arguments starting from indexstartOffset
satisfy the predicate.Note: If this is an
IAssociation
the rule at the position will be returned.- Specified by:
forAll
in interfaceIAST
- Overrides:
forAll
in classAbstractAST
- Parameters:
predicate
- the predicate which filters each argument in thisAST
startOffset
- start offset from which the element have to be tested- Returns:
true
if the predicate is true for all elements orfalse
otherwise
-
forEach
public void forEach(int start, int end, ObjIntConsumer<? super IExpr> action)
Description copied from interface:IAST
Consume allvalue-elements
generated by the given function from indexstart
inclusive toend
exclusive.
-
forEach
public void forEach(int start, int end, Consumer<? super IExpr> action)
Description copied from interface:IAST
Consume allvalue-elements
generated by the given function from indexstart
inclusive toend
exclusive.
-
get
public IExpr get(int location)
Description copied from interface:IAST
Returns the element at the specified location in thisIAST
. If this is anIAssociation
return the value of the rule at the specified location.- Specified by:
get
in interfaceIAST
- Specified by:
get
in interfaceITensorAccess
- Specified by:
get
in classAbstractAST
- Parameters:
location
- the index of the element to return.- Returns:
- the element at the specified location.
-
getItems
public IAST getItems(int[] items, int length)
Description copied from interface:IAST
Returnslength
number of elements specified in theitems
position array in thisIAST
.
-
hashCode
public int hashCode()
Description copied from class:AbstractAST
FNV-1 hash code of thisIAST
.- Specified by:
hashCode
in interfaceedu.jas.structure.Element<IExpr>
- Overrides:
hashCode
in classAbstractAST
-
head
public IExpr head()
Description copied from interface:IExpr
If this object is an instance ofIAST
get the first element (offset 0) of theIAST
list (i.e.#get(0)
). Otherwise return the specific header, i.e. forinteger number type => S.Integer, fraction number type => S.Rational, complex number type => S.Complex, ...
-
isAST0
public boolean isAST0()
Test if this expression is anIAST
function, which contains a header element (i.e. the function name) at index position0
and no argument elements.
Therefore this expression is no atomic expression.- Specified by:
isAST0
in interfaceIExpr
- Overrides:
isAST0
in classAbstractAST
- Returns:
- See Also:
IExpr.isAtom()
-
isAST1
public boolean isAST1()
Test if this expression is anIAST
function, which contains a header element (i.e. the function name) at index position0
and one argument element at the index position1
.
Therefore this expression is no atomic expression.- Specified by:
isAST1
in interfaceIExpr
- Overrides:
isAST1
in classAbstractAST
- Returns:
- See Also:
IExpr.isAtom()
-
isAST2
public boolean isAST2()
Test if this expression is anIAST
function, which contains a header element (i.e. the function name) at index position0
and two argument elements at the index positions1, 2
.
Therefore this expression is no atomic expression.- Specified by:
isAST2
in interfaceIExpr
- Overrides:
isAST2
in classAbstractAST
- Returns:
- See Also:
IExpr.isAtom()
-
isAST3
public boolean isAST3()
Test if this expression is anIAST
function, which contains a header element (i.e. the function name) at index position0
and three argument elements at the index positions1, 2, 3
.
Therefore this expression is no atomic expression.- Specified by:
isAST3
in interfaceIExpr
- Overrides:
isAST3
in classAbstractAST
- Returns:
- See Also:
IExpr.isAtom()
-
isList
public boolean isList()
Test if this expression is a list (i.e. an AST with head List)- Specified by:
isList
in interfaceIExpr
- Overrides:
isList
in classAbstractAST
- Returns:
-
isSameHead
public boolean isSameHead(ISymbol head)
Check if the object at index 0 (i.e. the head of the list) is the same object ashead
- Overrides:
isSameHead
in classAbstractAST
- Parameters:
head
- object to compare with element at location0
- Returns:
-
isSameHead
public boolean isSameHead(ISymbol head, int length)
Check if the object at index 0 (i.e. the head of the list) is the same object ashead
and if the size of the list equalslength
.- Overrides:
isSameHead
in classAbstractAST
- Parameters:
head
- object to compare with element at location0
- Returns:
-
isSameHead
public boolean isSameHead(ISymbol head, int minLength, int maxLength)
Check if the object at index 0 (i.e. the head of the list) is the same object ashead
and if the size of the list is betweenminLength
andmaxLength
.- Overrides:
isSameHead
in classAbstractAST
- Parameters:
head
- object to compare with element at location0
minLength
- minimum length of list elements.maxLength
- maximum length of list elements.- Returns:
-
isSameHeadSizeGE
public boolean isSameHeadSizeGE(ISymbol head, int length)
Check if the object at index 0 (i.e. the head of the list) is the same object ashead
and if the size of the list is greater or equallength
.- Specified by:
isSameHeadSizeGE
in interfaceIAST
- Specified by:
isSameHeadSizeGE
in interfaceIExpr
- Parameters:
head
- object to compare with element at location0
- Returns:
-
readExternal
public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
set
public IExpr set(int location, IExpr object)
Replaces the element at the specified location in thisArrayList
with the specified object. Internally thehashValue
will be reset to0
.- Specified by:
set
in interfaceIASTMutable
- Parameters:
location
- the index at which to put the specified object.object
- the object to add.- Returns:
- the previous element at the index.
- Throws:
IndexOutOfBoundsException
- whenlocation < 0 || >= size()
-
setAtCopy
public IASTMutable setAtCopy(int i, IExpr expr)
Description copied from interface:IAST
Create a shallow copy of thisIAST
instance (the elements themselves are not copied) and set theexpr
at the givenposition
. In contrast to thesetAtClone()
method, this method returns exactly the same type forAST0, AST1, AST2, AST3
.
-
sortInplace
public void sortInplace(Comparator<IExpr> comparator)
Description copied from interface:IASTMutable
Sortthis
in place using functioncomparator#compare(a, b)
. Example: suppose the Symbol f has the attribute ISymbol.ORDERLESSf(z,d,a,b) ==> f(a,b,d,z)
Warning only call this method in certain steps of the evaluation chain (for example for evaluating attribute
ISymbol.ORDERLESS
)- Specified by:
sortInplace
in interfaceIASTMutable
- Overrides:
sortInplace
in classAbstractAST
- Parameters:
comparator
- the comparator used for sorting inplace.
-
size
public final int size()
Returns the number of elements in thisArrayList
.- Specified by:
size
in interfaceIAST
- Specified by:
size
in interfaceIExpr
- Returns:
- the number of elements in this
ArrayList
. - See Also:
IAST.argSize()
-
writeExternal
public void writeExternal(ObjectOutput objectOutput) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
toArray
public IExpr[] toArray()
Description copied from interface:IAST
Returns an array containing all elements contained in thisList
.
-
append
public boolean append(IExpr expr)
Description copied from interface:IASTAppendable
Adds the specified expression at the end ofthis
.- Specified by:
append
in interfaceIASTAppendable
- Parameters:
expr
- the object to add.- Returns:
- always true.
-
append
public void append(int location, IExpr expr)
Description copied from interface:IASTAppendable
Inserts the specified object into thisList
at the specified location. The object is inserted before the current element at the specified location. If the location is equal to the size of thisList
, the object is added at the end. If the location is smaller than the size of thisList
, then all elements beyond the specified location are moved by one position towards the end of theList
.- Specified by:
append
in interfaceIASTAppendable
- Parameters:
location
- the index at which to insert.expr
- the object to add.
-
appendAll
public boolean appendAll(Collection<? extends IExpr> collection)
Description copied from interface:IASTAppendable
Adds the objects in the specified collection to the end of thisList
. The objects are added in the order in which they are returned from the collection's iterator.- Specified by:
appendAll
in interfaceIASTAppendable
- Parameters:
collection
- the collection of objects.- Returns:
true
if thisList
is modified,false
otherwise (i.e. if the passed collection was empty).
-
appendAll
public boolean appendAll(Map<? extends IExpr,? extends IExpr> map)
Description copied from interface:IASTAppendable
Adds the mappings in the specified map asRule(...)
to the end of thisList
. The objects are added in the order in which they are returned from the map's iterator.- Specified by:
appendAll
in interfaceIASTAppendable
- Returns:
-
appendAll
public boolean appendAll(IAST ast, int startPosition, int endPosition)
Description copied from interface:IASTAppendable
Appends all elements from offsetstartPosition
toendPosition
in the specified AST to the end of this AST.- Specified by:
appendAll
in interfaceIASTAppendable
- Parameters:
ast
- AST containing elements to be added to this ASTstartPosition
- the start position, inclusive.endPosition
- the ending position, exclusive.- Returns:
- true if this AST changed as a result of the call
-
appendAll
public boolean appendAll(int location, Collection<? extends IExpr> collection)
Description copied from interface:IASTAppendable
Inserts the objects in the specified collection at the specified location in this AST. The objects are added in the order they are returned from the collection's iterator.- Specified by:
appendAll
in interfaceIASTAppendable
- Parameters:
location
- the index at which to insert.collection
- the collection of objects.- Returns:
true
if thisArrayList
is modified,false
otherwise.
-
appendAll
public boolean appendAll(List<? extends IExpr> list, int startPosition, int endPosition)
Description copied from interface:IASTAppendable
Appends all elements from offsetstartPosition
toendPosition
in the specified list to the end of this AST.- Specified by:
appendAll
in interfaceIASTAppendable
- Parameters:
list
- list containing elements to be added to this ASTstartPosition
- the start position, inclusive.endPosition
- the ending position, exclusive.- Returns:
- true if this AST changed as a result of the call
-
appendAll
public boolean appendAll(IExpr[] args, int startPosition, int endPosition)
Description copied from interface:IASTAppendable
Appends all elements from offsetstartPosition
toendPosition
in the specified list to the end of this AST.- Specified by:
appendAll
in interfaceIASTAppendable
- Parameters:
args
- array containing elements to be added to this ASTstartPosition
- the start position, inclusive.endPosition
- the ending position, exclusive.- Returns:
- true if this AST changed as a result of the call
-
appendArgs
public boolean appendArgs(IAST ast)
Description copied from interface:IASTAppendable
Appends all of the arguments (starting from offset1
) in the specifiedast
to the end ofthis
AST.- Specified by:
appendArgs
in interfaceIASTAppendable
- Parameters:
ast
- AST containing elements to be added to this AST- Returns:
- true if this AST changed as a result of the call
-
appendArgs
public boolean appendArgs(IAST ast, int untilPosition)
Description copied from interface:IASTAppendable
Appends all of the arguments (starting from offset1
) in the specified AST up to positionuntilPosition
exclusive.- Specified by:
appendArgs
in interfaceIASTAppendable
- Parameters:
ast
- AST containing elements to be added to this ASTuntilPosition
- append all argumments of ast up to positionuntilPosition
exclusive.- Returns:
- true if this AST changed as a result of the call
-
appendArgs
public IASTAppendable appendArgs(int start, int end, IntFunction<IExpr> function)
Description copied from interface:IASTAppendable
Appends all elements generated by the givenIntFunction.apply(int)
method from indexstart
inclusive toend
exclusive. If the result of theIntFunction.apply(int)
method is equalF.NIL
then stop appending further entries.- Specified by:
appendArgs
in interfaceIASTAppendable
- Parameters:
start
- start index (inclusive)end
- end index (exclusive)function
- function thoseIntFunction.apply(int)
method will be called with each number in the range. If theIntFunction.apply(int)
method returnsF.NIL
then stop appending further entries- Returns:
- this
-
appendOneIdentity
public IAST appendOneIdentity(IAST value)
Description copied from interface:IASTAppendable
Append ansubAST
with attributeOneIdentity
for example Plus[] or Times[].- Specified by:
appendOneIdentity
in interfaceIASTAppendable
- Parameters:
value
- an ast with attributeOneIdentity
.- Returns:
this
ast after adding the subAST
-
clear
public void clear()
Description copied from interface:IASTAppendable
Removes all elements from thisIAST
, leaving it empty (optional).- Specified by:
clear
in interfaceIASTAppendable
-
remove
public IExpr remove(int location)
Description copied from interface:IASTAppendable
Removes the object at the specified location from thisIAST
.- Specified by:
remove
in interfaceIASTAppendable
- Parameters:
location
- the index of the object to remove.- Returns:
- the removed object.
-
removeRange
public void removeRange(int start, int end)
Description copied from interface:IASTAppendable
Removes the objects in the specified range from the start to the end, but not including the end index.- Specified by:
removeRange
in interfaceIASTAppendable
- Parameters:
start
- the index at which to start removing.end
- the index one after the end of the range to remove. * @throws UnsupportedOperationException if removing from thisIAST
is not supported.
-
-