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 headerSinand one node for the argumentx. Internally an AST is represented as ajava.util.Listwhich contains- the operator of a function (i.e. the "header"-symbol: Sin, Cos, Inverse, Plus,
Times,...) at index
0and - the
narguments 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>rrbTreeThe 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 voidappend(int location, IExpr expr)Inserts the specified object into thisListat the specified location.booleanappend(IExpr expr)Adds the specified expression at the end ofthis.booleanappendAll(int location, Collection<? extends IExpr> collection)Inserts the objects in the specified collection at the specified location in this AST.booleanappendAll(Collection<? extends IExpr> collection)Adds the objects in the specified collection to the end of thisList.booleanappendAll(List<? extends IExpr> list, int startPosition, int endPosition)Appends all elements from offsetstartPositiontoendPositionin the specified list to the end of this AST.booleanappendAll(Map<? extends IExpr,? extends IExpr> map)Adds the mappings in the specified map asRule(...)to the end of thisList.booleanappendAll(IAST ast, int startPosition, int endPosition)Appends all elements from offsetstartPositiontoendPositionin the specified AST to the end of this AST.booleanappendAll(IExpr[] args, int startPosition, int endPosition)Appends all elements from offsetstartPositiontoendPositionin the specified list to the end of this AST.IASTAppendableappendArgs(int start, int end, IntFunction<IExpr> function)Appends all elements generated by the givenIntFunction.apply(int)method from indexstartinclusive toendexclusive.booleanappendArgs(IAST ast)Appends all of the arguments (starting from offset1) in the specifiedastto the end ofthisAST.booleanappendArgs(IAST ast, int untilPosition)Appends all of the arguments (starting from offset1) in the specified AST up to positionuntilPositionexclusive.IASTappendOneIdentity(IAST value)Append ansubASTwith attributeOneIdentityfor example Plus[] or Times[].IExprarg1()Get the first argument (i.e.IExprarg2()Get the second argument (i.e.IExprarg3()Get the third argument (i.e.IExprarg4()Get the fourth argument (i.e.IExprarg5()Get the fifth argument (i.e.intargSize()Returns the number of arguments in thisIAST.Set<IExpr>asSet()Collect all arguments of this AST in a new set.voidclear()Removes all elements from thisIAST, leaving it empty (optional).IASTclone()Returns a newHMArrayListwith the same elements, the same size and the same capacity as thisHMArrayList.ASTRRBTreecopy()Returns a shallow copy of thisIASTinstance (the elements themselves are not copied).IASTAppendablecopyAppendable()Returns a shallow copy of thisIASTinstance (the elements themselves are not copied).IASTAppendablecopyAppendable(int additionalCapacity)Returns a shallow copy of thisIASTinstance (the elements themselves are not copied).voidensureCapacity(int size)booleanequals(Object obj)booleanexists(Predicate<? super IExpr> predicate, int startOffset)Check all elements by applying thepredicateto each argument in thisASTand returntrueif one of the arguments starting from indexstartOffsetsatisfy the predicate.booleanexists(ObjIntPredicate<? super IExpr> predicate, int startOffset)Check all elements by applying thepredicateto each argument in thisASTand returntrueif one of the arguments starting from indexstartOffsetsatisfy the predicate.booleanforAll(Predicate<? super IExpr> predicate, int startOffset)Check all elements by applying thepredicateto each argument in thisASTand returntrueif all of the arguments starting from indexstartOffsetsatisfy the predicate.booleanforAll(ObjIntPredicate<? super IExpr> predicate, int startOffset)Check all elements by applying thepredicateto each argument in thisASTand returntrueif all of the arguments starting from indexstartOffsetsatisfy the predicate.voidforEach(int start, int end, Consumer<? super IExpr> action)Consume allvalue-elementsgenerated by the given function from indexstartinclusive toendexclusive.voidforEach(int start, int end, ObjIntConsumer<? super IExpr> action)Consume allvalue-elementsgenerated by the given function from indexstartinclusive toendexclusive.IExprget(int location)Returns the element at the specified location in thisIAST.IASTgetItems(int[] items, int length)Returnslengthnumber of elements specified in theitemsposition array in thisIAST.inthashCode()FNV-1 hash code of thisIAST.IExprhead()If this object is an instance ofIASTget the first element (offset 0) of theIASTlist (i.e.booleanisAST0()Test if this expression is anIASTfunction, which contains a header element (i.e.booleanisAST1()Test if this expression is anIASTfunction, which contains a header element (i.e.booleanisAST2()Test if this expression is anIASTfunction, which contains a header element (i.e.booleanisAST3()Test if this expression is anIASTfunction, which contains a header element (i.e.booleanisList()Test if this expression is a list (i.e.booleanisSameHead(ISymbol head)Check if the object at index 0 (i.e.booleanisSameHead(ISymbol head, int length)Check if the object at index 0 (i.e.booleanisSameHead(ISymbol head, int minLength, int maxLength)Check if the object at index 0 (i.e.booleanisSameHeadSizeGE(ISymbol head, int length)Check if the object at index 0 (i.e.static ASTRRBTreenewInstance(int initialCapacity, IExpr head)voidreadExternal(ObjectInput objectInput)IExprremove(int location)Removes the object at the specified location from thisIAST.voidremoveRange(int start, int end)Removes the objects in the specified range from the start to the end, but not including the end index.IExprset(int location, IExpr object)Replaces the element at the specified location in thisArrayListwith the specified object.IASTMutablesetAtCopy(int i, IExpr expr)Create a shallow copy of thisIASTinstance (the elements themselves are not copied) and set theexprat the givenposition.intsize()Returns the number of elements in thisArrayList.voidsortInplace(Comparator<IExpr> comparator)Sortthisin place using functioncomparator#compare(a, b).IExpr[]toArray()Returns an array containing all elements contained in thisList.voidwriteExternal(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 allastelements 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 theASTfunction (i.e. get(1) ).
Example: for the AST representing the expressionSin(x),arg1()returnsx.- Specified by:
arg1in 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 theASTfunction (i.e. get(2) ).
Example: for the AST representing the expressionx^y(i.e.Power(x, y)),arg2()returnsy.- Specified by:
arg2in 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 theASTfunction (i.e. get(3) ).
Example: for the AST representing the expressionf(a, b, c),arg3()returnsc.- Specified by:
arg3in 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 theASTfunction (i.e. get(4) ).
Example: for the AST representing the expressionf(a, b ,c, d),arg4()returnsd.- Specified by:
arg4in 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 theASTfunction (i.e. get(5) ).
Example: for the AST representing the expressionf(a, b ,c, d, e),arg5()returnse.- Specified by:
arg5in 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:
argSizein interfaceIAST- Specified by:
argSizein interfaceIExpr- Returns:
- the number of arguments in this
IAST. - See Also:
IExpr.size()
-
asSet
public Set<IExpr> asSet()
Description copied from interface:IASTCollect all arguments of this AST in a new set.- Specified by:
asSetin interfaceIAST- Overrides:
asSetin classAbstractAST- Returns:
nullif a set couldn't be created
-
clone
public IAST clone()
Returns a newHMArrayListwith the same elements, the same size and the same capacity as thisHMArrayList.
-
copy
public ASTRRBTree copy()
Returns a shallow copy of this
IASTinstance (the elements themselves are not copied). In contrast to theIAST.copyAppendable()method, this method returns exactly the same type forAST0, AST1, AST2, AST3and tries to transformASTobjects toAST0, AST1, AST2, AST3if 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:IASTReturns a shallow copy of this
IASTinstance (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 newASTobject, so that additional arguments could be appended at the end.This also allows to set the header object to an arbitrary expression.
- Specified by:
copyAppendablein interfaceIAST- Returns:
- a copy of this
IASTinstance.
-
copyAppendable
public IASTAppendable copyAppendable(int additionalCapacity)
Description copied from interface:IASTReturns a shallow copy of this
IASTinstance (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 newASTobject, so that additional arguments could be appended at the end.This also allows to set the header object to an arbitrary expression.
- Specified by:
copyAppendablein interfaceIAST- Returns:
- a copy of this
IASTinstance.
-
equals
public boolean equals(Object obj)
- Specified by:
equalsin interfaceedu.jas.structure.Element<IExpr>- Overrides:
equalsin classAbstractAST
-
exists
public boolean exists(ObjIntPredicate<? super IExpr> predicate, int startOffset)
Check all elements by applying thepredicateto each argument in thisASTand returntrueif one of the arguments starting from indexstartOffsetsatisfy the predicate.- Specified by:
existsin interfaceIAST- Overrides:
existsin classAbstractAST- Parameters:
predicate- the predicate which filters each argument in thisASTstartOffset- start offset from which the element have to be tested- Returns:
- the
trueif the predicate is true the first time orfalseotherwise
-
exists
public boolean exists(Predicate<? super IExpr> predicate, int startOffset)
Check all elements by applying thepredicateto each argument in thisASTand returntrueif one of the arguments starting from indexstartOffsetsatisfy the predicate.- Specified by:
existsin interfaceIAST- Overrides:
existsin classAbstractAST- Parameters:
predicate- the predicate which filters each argument in thisASTstartOffset- start offset from which the element have to be tested- Returns:
- the
trueif the predicate is true the first time orfalseotherwise
-
forAll
public boolean forAll(ObjIntPredicate<? super IExpr> predicate, int startOffset)
Check all elements by applying thepredicateto each argument in thisASTand returntrueif all of the arguments starting from indexstartOffsetsatisfy the predicate.Note: If this is an
IAssociationthe rule at the position will be returned.- Specified by:
forAllin interfaceIAST- Overrides:
forAllin classAbstractAST- Parameters:
predicate- the predicate which filters each argument in thisASTstartOffset- start offset from which the element have to be tested- Returns:
trueif the predicate is true for all elements orfalseotherwise
-
forAll
public boolean forAll(Predicate<? super IExpr> predicate, int startOffset)
Check all elements by applying thepredicateto each argument in thisASTand returntrueif all of the arguments starting from indexstartOffsetsatisfy the predicate.Note: If this is an
IAssociationthe rule at the position will be returned.- Specified by:
forAllin interfaceIAST- Overrides:
forAllin classAbstractAST- Parameters:
predicate- the predicate which filters each argument in thisASTstartOffset- start offset from which the element have to be tested- Returns:
trueif the predicate is true for all elements orfalseotherwise
-
forEach
public void forEach(int start, int end, ObjIntConsumer<? super IExpr> action)Description copied from interface:IASTConsume allvalue-elementsgenerated by the given function from indexstartinclusive toendexclusive.
-
forEach
public void forEach(int start, int end, Consumer<? super IExpr> action)Description copied from interface:IASTConsume allvalue-elementsgenerated by the given function from indexstartinclusive toendexclusive.
-
get
public IExpr get(int location)
Description copied from interface:IASTReturns the element at the specified location in thisIAST. If this is anIAssociationreturn the value of the rule at the specified location.- Specified by:
getin interfaceIAST- Specified by:
getin interfaceITensorAccess- Specified by:
getin 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:IASTReturnslengthnumber of elements specified in theitemsposition array in thisIAST.
-
hashCode
public int hashCode()
Description copied from class:AbstractASTFNV-1 hash code of thisIAST.- Specified by:
hashCodein interfaceedu.jas.structure.Element<IExpr>- Overrides:
hashCodein classAbstractAST
-
head
public IExpr head()
Description copied from interface:IExprIf this object is an instance ofIASTget the first element (offset 0) of theIASTlist (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 anIASTfunction, which contains a header element (i.e. the function name) at index position0and no argument elements.
Therefore this expression is no atomic expression.- Specified by:
isAST0in interfaceIExpr- Overrides:
isAST0in classAbstractAST- Returns:
- See Also:
IExpr.isAtom()
-
isAST1
public boolean isAST1()
Test if this expression is anIASTfunction, which contains a header element (i.e. the function name) at index position0and one argument element at the index position1.
Therefore this expression is no atomic expression.- Specified by:
isAST1in interfaceIExpr- Overrides:
isAST1in classAbstractAST- Returns:
- See Also:
IExpr.isAtom()
-
isAST2
public boolean isAST2()
Test if this expression is anIASTfunction, which contains a header element (i.e. the function name) at index position0and two argument elements at the index positions1, 2.
Therefore this expression is no atomic expression.- Specified by:
isAST2in interfaceIExpr- Overrides:
isAST2in classAbstractAST- Returns:
- See Also:
IExpr.isAtom()
-
isAST3
public boolean isAST3()
Test if this expression is anIASTfunction, which contains a header element (i.e. the function name) at index position0and three argument elements at the index positions1, 2, 3.
Therefore this expression is no atomic expression.- Specified by:
isAST3in interfaceIExpr- Overrides:
isAST3in 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:
isListin interfaceIExpr- Overrides:
isListin 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:
isSameHeadin 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 asheadand if the size of the list equalslength.- Overrides:
isSameHeadin 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 asheadand if the size of the list is betweenminLengthandmaxLength.- Overrides:
isSameHeadin classAbstractAST- Parameters:
head- object to compare with element at location0minLength- 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 asheadand if the size of the list is greater or equallength.- Specified by:
isSameHeadSizeGEin interfaceIAST- Specified by:
isSameHeadSizeGEin interfaceIExpr- Parameters:
head- object to compare with element at location0- Returns:
-
readExternal
public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
set
public IExpr set(int location, IExpr object)
Replaces the element at the specified location in thisArrayListwith the specified object. Internally thehashValuewill be reset to0.- Specified by:
setin 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:IASTCreate a shallow copy of thisIASTinstance (the elements themselves are not copied) and set theexprat 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:IASTMutableSortthisin 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:
sortInplacein interfaceIASTMutable- Overrides:
sortInplacein classAbstractAST- Parameters:
comparator- the comparator used for sorting inplace.
-
size
public final int size()
Returns the number of elements in thisArrayList.- Specified by:
sizein interfaceIAST- Specified by:
sizein interfaceIExpr- Returns:
- the number of elements in this
ArrayList. - See Also:
IAST.argSize()
-
writeExternal
public void writeExternal(ObjectOutput objectOutput) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
toArray
public IExpr[] toArray()
Description copied from interface:IASTReturns an array containing all elements contained in thisList.
-
append
public boolean append(IExpr expr)
Description copied from interface:IASTAppendableAdds the specified expression at the end ofthis.- Specified by:
appendin interfaceIASTAppendable- Parameters:
expr- the object to add.- Returns:
- always true.
-
append
public void append(int location, IExpr expr)Description copied from interface:IASTAppendableInserts the specified object into thisListat 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:
appendin 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:IASTAppendableAdds 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:
appendAllin interfaceIASTAppendable- Parameters:
collection- the collection of objects.- Returns:
trueif thisListis modified,falseotherwise (i.e. if the passed collection was empty).
-
appendAll
public boolean appendAll(Map<? extends IExpr,? extends IExpr> map)
Description copied from interface:IASTAppendableAdds 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:
appendAllin interfaceIASTAppendable- Returns:
-
appendAll
public boolean appendAll(IAST ast, int startPosition, int endPosition)
Description copied from interface:IASTAppendableAppends all elements from offsetstartPositiontoendPositionin the specified AST to the end of this AST.- Specified by:
appendAllin 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:IASTAppendableInserts 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:
appendAllin interfaceIASTAppendable- Parameters:
location- the index at which to insert.collection- the collection of objects.- Returns:
trueif thisArrayListis modified,falseotherwise.
-
appendAll
public boolean appendAll(List<? extends IExpr> list, int startPosition, int endPosition)
Description copied from interface:IASTAppendableAppends all elements from offsetstartPositiontoendPositionin the specified list to the end of this AST.- Specified by:
appendAllin 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:IASTAppendableAppends all elements from offsetstartPositiontoendPositionin the specified list to the end of this AST.- Specified by:
appendAllin 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:IASTAppendableAppends all of the arguments (starting from offset1) in the specifiedastto the end ofthisAST.- Specified by:
appendArgsin 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:IASTAppendableAppends all of the arguments (starting from offset1) in the specified AST up to positionuntilPositionexclusive.- Specified by:
appendArgsin interfaceIASTAppendable- Parameters:
ast- AST containing elements to be added to this ASTuntilPosition- append all argumments of ast up to positionuntilPositionexclusive.- 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:IASTAppendableAppends all elements generated by the givenIntFunction.apply(int)method from indexstartinclusive toendexclusive. If the result of theIntFunction.apply(int)method is equalF.NILthen stop appending further entries.- Specified by:
appendArgsin 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.NILthen stop appending further entries- Returns:
- this
-
appendOneIdentity
public IAST appendOneIdentity(IAST value)
Description copied from interface:IASTAppendableAppend ansubASTwith attributeOneIdentityfor example Plus[] or Times[].- Specified by:
appendOneIdentityin interfaceIASTAppendable- Parameters:
value- an ast with attributeOneIdentity.- Returns:
thisast after adding the subAST
-
clear
public void clear()
Description copied from interface:IASTAppendableRemoves all elements from thisIAST, leaving it empty (optional).- Specified by:
clearin interfaceIASTAppendable
-
remove
public IExpr remove(int location)
Description copied from interface:IASTAppendableRemoves the object at the specified location from thisIAST.- Specified by:
removein 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:IASTAppendableRemoves the objects in the specified range from the start to the end, but not including the end index.- Specified by:
removeRangein 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 thisIASTis not supported.
-
-