Class AbstractAST

    • Field Detail

      • fEvalFlags

        protected int fEvalFlags
        Flags for controlling evaluation and left-hand-side pattern-matching expressions
      • hashValue

        protected transient int hashValue
    • Constructor Detail

      • AbstractAST

        public AbstractAST()
    • Method Detail

      • accept

        public IExpr accept​(IVisitor visitor)
        Accept a visitor with return type T
        Specified by:
        accept in interface IExpr
        Returns:
        F.NIL if no evaluation was necessary
      • accept

        public final boolean accept​(IVisitorBoolean visitor)
        Accept a visitor with return type boolean. The visitor should return true if one of it's members fulfills the specific condition of the visitor.
        Specified by:
        accept in interface IExpr
        Returns:
      • accept

        public final int accept​(IVisitorInt visitor)
        Accept a visitor with return type int
        Specified by:
        accept in interface IExpr
        Returns:
      • accept

        public long accept​(IVisitorLong visitor)
        Accept a visitor with return type long
        Specified by:
        accept in interface IExpr
        Returns:
      • addEvalFlags

        public final IAST addEvalFlags​(int i)
        Add an evaluation flag to the existing ones.
        Specified by:
        addEvalFlags in interface IAST
        Specified by:
        addEvalFlags in interface IExpr
        Returns:
      • appendAtClone

        public IASTAppendable appendAtClone​(int position,
                                            IExpr expr)
        Create a shallow copy of this IAST instance (the elements themselves are not copied) and add the expr at the given position.
        Specified by:
        appendAtClone in interface IAST
        Returns:
        a clone with added expr element at the given position.
      • appendClone

        public IASTAppendable appendClone​(IExpr expr)
        Append an expression to this list.
        Specified by:
        appendClone in interface IAST
        Parameters:
        expr - the expression which should be appended
        Returns:
        this after appending the given expression.
      • apply

        public IASTAppendable apply​(IExpr head)
        Description copied from interface: IAST
        Apply the given head to this expression (i.e. create a list copy and replace the old head with the given one). F.List(a,b,c).apply(F.Max) gives Max(a,b,c)
        Specified by:
        apply in interface IAST
        Returns:
      • apply

        public final IAST apply​(IExpr head,
                                int start)
        Description copied from interface: IAST
        Apply the given head to this expression (i.e. create a sublist clone starting from index start and replacing the old head with the given one)
        Specified by:
        apply in interface IAST
        start - the start index
        Returns:
      • apply

        public IAST apply​(IExpr head,
                          int start,
                          int end)
        Description copied from interface: IAST
        Apply the given head to this expression (i.e. create a sublist clone from index start to end, and replacing the old head with the given one)
        Specified by:
        apply in interface IAST
        start - the start index
        end - the end index
        Returns:
        a clone with element set to head at the given 0.
      • asNumerDenom

        public Pair asNumerDenom()
        Description copied from interface: IExpr
        Expression a/b -> [a, b]
        Specified by:
        asNumerDenom in interface IExpr
        Returns:
      • asSet

        public Set<IExpr> asSet()
        Description copied from interface: IAST
        Collect all arguments of this AST in a new set.
        Specified by:
        asSet in interface IAST
        Returns:
        null if a set couldn't be created
      • clearHashCache

        public void clearHashCache()
        Description copied from interface: IAST
        Set the cached hash value to zero.
        Specified by:
        clearHashCache in interface IAST
      • compareAdjacent

        public boolean compareAdjacent​(BiPredicate<IExpr,​IExpr> predicate)
        Compare all adjacent elements from lowest to highest index and return true, if the binary predicate gives true in each step. If the size is < 2 the method returns false;
        Specified by:
        compareAdjacent in interface IAST
        Parameters:
        predicate - the binary predicate
        Returns:
        false if the first comparison fails
      • compareTo

        public int compareTo​(IExpr rhsExpr)
        Compares this expression with the specified expression for canonical order. Returns a negative integer, zero, or a positive integer as this expression is canonical less than, equal to, or greater than the specified expression.
        Specified by:
        compareTo in interface Comparable<IExpr>
        Specified by:
        compareTo in interface edu.jas.structure.Element<IExpr>
        Specified by:
        compareTo in interface IExpr
        See Also:
        S.Order, S.NumericalOrder
      • contains

        public boolean contains​(Object object)
        Tests whether this List contains the specified object.
        Specified by:
        contains in interface IAST
        Parameters:
        object - the object to search for.
        Returns:
        true if object is an element of this List, false otherwise
      • copyAlloc

        public IAST copyAlloc​(int capacity)
      • copyFrom

        public IASTAppendable copyFrom​(int index)

        Create a copy of this AST, which contains the same head and all elements from the given position (inclusive).

        Specified by:
        copyFrom in interface IAST
        Returns:
      • copyFrom

        public IASTAppendable copyFrom​(int startPosition,
                                       int endPosition)

        Create a copy of this AST, which contains the same head and all elements from the given position (inclusive).

        Specified by:
        copyFrom in interface IAST
        Parameters:
        startPosition - the position to start copying the elements (inclusive)
        endPosition - the position to end copying the elements (exclusive)
        Returns:
      • copyHead

        public IASTAppendable copyHead()

        Create a copy of this AST, which only contains the head element of the list (i.e. the element with index 0). For ASTAssociations create a copy of the full form AST, which only contains the head S.Association (i.e. the element with index 0). In further evaluation steps this full form can be converted back into a real ASTAssociation.

        This also allows to set the header object to an arbitrary expression.

        Specified by:
        copyHead in interface IAST
        Returns:
      • copyHead

        public IASTAppendable copyHead​(int intialCapacity)

        Create a copy of this AST, which only contains the head element of the list (i.e. the element with index 0) and allocate the intialCapacity size of entries for the arguments.

        This also allows to set the header object to an arbitrary expression.

        Specified by:
        copyHead in interface IAST
        Parameters:
        intialCapacity - the initial number of arguments
        Returns:
      • copyUntil

        public IASTAppendable copyUntil​(int index)
        Create a copy of this AST, which contains the same head and all elements up to the given position (exclusive).
        Specified by:
        copyUntil in interface IAST
        Returns:
      • copyUntil

        public IASTAppendable copyUntil​(int intialCapacity,
                                        int index)
        Create a copy of this AST, which contains the same head and all elements up to the given position (exclusive).
        Specified by:
        copyUntil in interface IAST
        Parameters:
        intialCapacity - the initial capacity of elements
        Returns:
      • count

        public int count​(Predicate<? super IExpr> predicate,
                         int fromIndex)
        Description copied from interface: IAST
        Test each argument with the Predicate and sum up how often it returns true.
        Specified by:
        count in interface IAST
        Returns:
      • depth

        public int depth​(boolean heads)
        Calculates the depth of an expression. Atomic expressions (no sublists) have depth 1 Example: the nested list [x,[y]] has depth 3
        Specified by:
        depth in interface IExpr
        Parameters:
        heads - if true, include the depth of heads
      • determinePrecision

        public long determinePrecision()
        Determine precision of this expression. Return -1 for symbolic evaluation.
        Specified by:
        determinePrecision in interface IExpr
        Returns:
        the precision of this expression. -1 for symbolic evaluation.
      • equals

        public boolean equals​(Object obj)
        Specified by:
        equals in interface edu.jas.structure.Element<IExpr>
        Overrides:
        equals in class Object
      • equalsArgs

        public boolean equalsArgs​(IExpr that,
                                  int startPosition,
                                  int endPosition)
        Check if this expression and that expression are both IASTs with the same number of arguments, where all arguments are equals each other.
        Specified by:
        equalsArgs in interface IExpr
        startPosition - (inclusive)
        endPosition - (exclusive)
        Returns:
      • equalsAt

        public final boolean equalsAt​(int position,
                                      IExpr expr)
        Calls get(position).equals(expr).
        Specified by:
        equalsAt in interface IAST
        Specified by:
        equalsAt in interface IExpr
        Parameters:
        position - the position which should be tested for equality
        expr - the expr which should be tested for equality
        Returns:
      • equalsFromPosition

        public final boolean equalsFromPosition​(int from0,
                                                IAST f1,
                                                int from1)
      • evalNumber

        public final INumber evalNumber()
        Evaluate the expression to a INumber value.
        Specified by:
        evalNumber in interface IExpr
        Returns:
        null if the conversion is not possible.
      • evalReal

        public final IReal evalReal()
        Evaluate the expression to a IReal value.
        Specified by:
        evalReal in interface IExpr
        Returns:
        null if the conversion is not possible.
      • evalEvaluate

        public IExpr evalEvaluate​(EvalEngine engine)
        Evaluate arguments with the head F.Evaluate, i.e. f(a, ... , Evaluate(x), ...)
        Parameters:
        engine - the evaluation engine
        Returns:
      • evaluate

        public IExpr evaluate​(EvalEngine engine)
        Evaluate an expression
        Specified by:
        evaluate in interface IExpr
        Parameters:
        engine - the evaluation engine
        Returns:
        the evaluated Object or F.NIL if the evaluation is not possible (i.e. the evaluation doesn't change the object).
      • exists

        public boolean exists​(ObjIntPredicate<? super IExpr> predicate,
                              int startOffset)
        Check all elements by applying the predicate to each argument in this AST and return true if one of the arguments starting from index startOffset satisfy the predicate.
        Specified by:
        exists in interface IAST
        Parameters:
        predicate - the predicate which filters each argument in this AST
        startOffset - start offset from which the element have to be tested
        Returns:
        the true if the predicate is true the first time or false otherwise
      • exists

        public boolean exists​(Predicate<? super IExpr> predicate,
                              int startOffset)
        Check all elements by applying the predicate to each argument in this AST and return true if one of the arguments starting from index startOffset satisfy the predicate.
        Specified by:
        exists in interface IAST
        Parameters:
        predicate - the predicate which filters each argument in this AST
        startOffset - start offset from which the element have to be tested
        Returns:
        the true if the predicate is true the first time or false otherwise
      • filterNIL

        public final IASTAppendable[] filterNIL​(Function<IExpr,​IExpr> function)
        Select all elements by applying the function to each argument in this AST and append the result elements for which the function returns non F.NIL elements to the 0th element of the result array, or otherwise append it to the 1st element of the result array.
        Specified by:
        filterNIL in interface IAST
        Parameters:
        function - the function which filters each argument in this AST by returning a result != F.NIL .
        Returns:
        the resulting ASTs in the 0-th and 1-st element of the array
        See Also:
        F.NIL
      • filter

        public IAST filter​(IASTAppendable filterAST,
                           IASTAppendable restAST,
                           Predicate<? super IExpr> predicate)
        Select all elements by applying the predicate to each argument in this AST and append the elements which satisfy the predicate to the filterAST , or otherwise append it to the restAST.
        Specified by:
        filter in interface IAST
        Parameters:
        filterAST - the elements where the predicate#apply() method returns true
        restAST - the elements which don't match the predicate
        predicate - the predicate which filters each argument in this AST
        Returns:
        the filterAST
      • filter

        public final IAST filter​(IASTAppendable filterAST,
                                 IExpr unaryHead)
        Select all elements by applying the Predicates.isTrue(expr) predicate to each argument in this AST and append the elements which satisfy the Predicates.isTrue(expr) predicate to the filterAST.
        Specified by:
        filter in interface IAST
        Parameters:
        filterAST - the elements where the predicate#apply() method returns true
        unaryHead - create a Predicates.isTrue(unaryHead) predicate which filters each element in this AST.
        Returns:
        the filterAST
      • filter

        public IAST filter​(IASTAppendable filterAST,
                           Predicate<? super IExpr> predicate)
        Select all elements by applying the predicate to each argument in this AST and append the arguments which satisfy the predicate to the filterAST.
        Specified by:
        filter in interface IAST
        Parameters:
        filterAST - the elements where the predicate#apply() method returns true
        predicate - the predicate which filters each argument in this AST
        Returns:
        the filterAST
      • filter

        public IAST filter​(IASTAppendable filterAST,
                           Predicate<? super IExpr> predicate,
                           int maxMatches)
        Select all elements by applying the predicate to each argument in this AST and append up to maxMatches arguments which satisfy the predicate to the filterAST.
        Specified by:
        filter in interface IAST
        Parameters:
        filterAST - the elements where the predicate#apply() method returns true
        predicate - the predicate which filters each argument in this AST
        maxMatches - the maximum number of matches
        Returns:
        the filterAST
      • select

        public IAST select​(Predicate<? super IExpr> predicate)
        Description copied from interface: IAST
        Select all elements by applying the predicate to each argument in this AST and append the arguments which satisfy the predicate.
        Specified by:
        select in interface IAST
        Parameters:
        predicate - the predicate which filters each argument in this AST
        Returns:
        the selected ast
      • select

        public IAST select​(Predicate<? super IExpr> predicate,
                           int maxMatches)
        Description copied from interface: IAST
        Select all elements by applying the predicate to each argument in this AST and append up to maxMatches arguments which satisfy the predicate.
        Specified by:
        select in interface IAST
        Parameters:
        predicate - the predicate which filters each argument in this AST
        maxMatches - the maximum number of matches
        Returns:
        the selected ast
      • filter

        public IASTAppendable[] filter​(Predicate<? super IExpr> predicate)
        Select all elements by applying the predicate to each argument in this AST and append the arguments which satisfy the predicate to the 0th element of the result array, or otherwise append it to the 1st element of the result array.
        Specified by:
        filter in interface IAST
        Parameters:
        predicate - the predicate which filters each element in the range
        Returns:
        the resulting ASTs in the 0-th and 1-st element of the array
      • removeIf

        public IAST removeIf​(Predicate<? super IExpr> predicate)
        Removes all the elements from this list which satisfies the given predicate and return the result as a new List
        Specified by:
        removeIf in interface IAST
        Parameters:
        predicate - the predicate which filters each element in the range
        Returns:
        the resulting ASTs in the 0-th and 1-st element of the array
      • filterFunction

        protected IAST filterFunction​(IASTAppendable filterAST,
                                      IASTAppendable restAST,
                                      Function<IExpr,​IExpr> function)
        Select all elements by applying the function to each argument in this AST and append the result elements for which the function returns non F.NIL elements to the filterAST, or otherwise append the argument to the restAST.
        Parameters:
        filterAST - the non F.NIL elements which were returned by the function#apply() method
        restAST - the arguments in this AST for which the function#apply() method returned F.NIL
        function - the function which filters each argument by returning a value which unequals F.NIL
        Returns:
        the given filterAST
      • foldLeft

        public IExpr foldLeft​(BiFunction<IExpr,​IExpr,​? extends IExpr> function,
                              IExpr startValue,
                              int start)
        Apply the functor to the elements of the range from left to right and return the final result. Results do accumulate from one invocation to the next: each time this method is called, the accumulation starts over with value from the previous function call.
        Specified by:
        foldLeft in interface IAST
        Parameters:
        function - a binary function that accumulate the elements
        Returns:
        the accumulated elements or F.NIL if the function returns F.NIL
      • foldRight

        public IExpr foldRight​(BiFunction<IExpr,​IExpr,​? extends IExpr> function,
                               IExpr startValue,
                               int start)
        Apply the functor to the elements of the range from right to left and return the final result. Results do accumulate from one invocation to the next: each time this method is called, the accumulation starts over with value from the previous function call.
        Specified by:
        foldRight in interface IAST
        Parameters:
        function - a binary function that accumulate the elements
        Returns:
        the accumulated elements or F.NIL if the function returns F.NIL
      • forAll

        public boolean forAll​(ObjIntPredicate<? super IExpr> predicate,
                              int startOffset)
        Check all elements by applying the predicate to each argument in this AST and return true if all of the arguments starting from index startOffset satisfy the predicate.

        Note: If this is an IAssociation the rule at the position will be returned.

        Specified by:
        forAll in interface IAST
        Parameters:
        predicate - the predicate which filters each argument in this AST
        startOffset - start offset from which the element have to be tested
        Returns:
        true if the predicate is true for all elements or false otherwise
      • forAll

        public boolean forAll​(Predicate<? super IExpr> predicate,
                              int startOffset)
        Check all elements by applying the predicate to each argument in this AST and return true if all of the arguments starting from index startOffset satisfy the predicate.

        Note: If this is an IAssociation the rule at the position will be returned.

        Specified by:
        forAll in interface IAST
        Parameters:
        predicate - the predicate which filters each argument in this AST
        startOffset - start offset from which the element have to be tested
        Returns:
        true if the predicate is true for all elements or false otherwise
      • forAllLeaves

        public boolean forAllLeaves​(Predicate<? super IExpr> predicate,
                                    int startOffset)
        Check all atomic (non IAST objects) leaf elements by applying the predicate to each leaf argument in this AST and sub-ASTs and return true if all of the leaf elements starting from index startOffset satisfy the predicate.
        Specified by:
        forAllLeaves in interface IAST
        Parameters:
        predicate - the predicate which filters each argument in this AST
        startOffset - start offset from which the leaf elements have to be tested
        Returns:
        the true if the predicate is true for all elements or false otherwise
      • forAllLeaves

        public boolean forAllLeaves​(IExpr head,
                                    Predicate<? super IExpr> predicate,
                                    int startOffset)
        Description copied from interface: IAST
        Check all IAST recursively, which don't have head as head element and apply the predicate to each leaf argument in this IAST and sub-ASTs and return true if all of the leaf elements starting from index startOffset satisfy the predicate.
        Specified by:
        forAllLeaves in interface IAST
        predicate - the predicate which filters each argument in this AST
        startOffset - start offset from which the leaf elements have to be tested
        Returns:
      • forEach

        public void forEach​(Consumer<? super IExpr> action)
        Iterate over all value-elements from index 1 to size()-1 and call the method Consumer.accept() for these elements. Note: the 0-th element (i.e. the head of the AST) will not be selected.
        Specified by:
        forEach in interface IAST
        Specified by:
        forEach in interface Iterable<IExpr>
      • forEachRule

        public void forEachRule​(Consumer<? super IExpr> action)
        Iterate over all elements from index 1 to size()-1 and call the method Consumer.accept() for these elements. Note: the 0-th element (i.e. the head of the AST) will not be selected. If the element is an Association the complete rule will be selected as element.
        Specified by:
        forEachRule in interface IAST
      • forEach

        public void forEach​(Consumer<? super IExpr> action,
                            int startOffset)
        Iterate over all value-elements from index startOffset to size()-1 and call the method Consumer.accept() for these elements. Note: the 0-th element (i.e. the head of the AST) will not be selected.
        Specified by:
        forEach in interface IAST
        startOffset - the start offset from which the action.accept() method should be executed
      • forEachRule

        public void forEachRule​(Consumer<? super IExpr> action,
                                int startOffset)
        Iterate over all elements from index startOffset to size()-1 and call the method Consumer.accept() for these elements. Note: the 0-th element (i.e. the head of the AST) will not be selected. If the element is an Association the complete rule will be selected as element.
        Specified by:
        forEachRule in interface IAST
        startOffset - the start offset from which the action.accept() method should be executed
      • fullFormString

        public String fullFormString()
        Return the FullForm() of this expression
        Specified by:
        fullFormString in interface IExpr
        Returns:
      • fullFormString

        protected String fullFormString​(IExpr head)
      • gcd

        public final IExpr gcd​(IExpr that)
        Specified by:
        gcd in interface IExpr
        Specified by:
        gcd in interface edu.jas.structure.RingElem<IExpr>
      • get

        public abstract IExpr get​(int location)
        Description copied from interface: IAST
        Returns the element at the specified location in this IAST. If this is an IAssociation return the value of the rule at the specified location.
        Specified by:
        get in interface IAST
        Specified by:
        get in interface ITensorAccess
        Parameters:
        location - the index of the element to return.
        Returns:
        the element at the specified location.
      • get

        public IExpr get​(IInteger location)
        Description copied from interface: IAST
        Returns the element at the specified location in this IAST.
        Specified by:
        get in interface IAST
        Parameters:
        location - the index of the element to return.
        Returns:
        the element at the specified location.
      • getAST

        public final IAST getAST​(int index)
        Casts an IExpr at position index to an IAST.
        Specified by:
        getAST in interface IAST
        Parameters:
        index -
        Returns:
        Throws:
        IllegalArgumentException - if the cast is not possible
      • getAt

        public final IExpr getAt​(int index)
        Description copied from interface: IExpr
        Get the element at the specified index if this object is of type IAST .
        Specified by:
        getAt in interface IExpr
        Returns:
      • getEvalFlags

        public final int getEvalFlags()
        Get the evaluation flags for this list.
        Specified by:
        getEvalFlags in interface IAST
        Returns:
      • getHashCache

        public int getHashCache()
        Description copied from interface: IAST
        Get the cached hash value.
        Specified by:
        getHashCache in interface IAST
        Returns:
      • getInt

        public final IInteger getInt​(int index)
        Casts an IExpr at position index to an IInteger.
        Specified by:
        getInt in interface IAST
        Parameters:
        index -
        Returns:
        Throws:
        IllegalArgumentException - if the cast is not possible
      • getList

        public final IAST getList​(int index)
        Casts an IExpr which is a list at position index to an IAST .
        Specified by:
        getList in interface IAST
        Parameters:
        index -
        Returns:
        Throws:
        IllegalArgumentException
      • getNumber

        public final INumber getNumber​(int index)
        Casts an IExpr at position index to an INumber.
        Specified by:
        getNumber in interface IAST
        Parameters:
        index -
        Returns:
        Throws:
        IllegalArgumentException - if the cast is not possible
      • getPart

        public IExpr getPart​(int... positions)
        Description copied from interface: IAST
        Returns the element at the specified positions in the nested ASTs.
        Specified by:
        getPart in interface IAST
        Parameters:
        positions - index of the element to return
        Returns:
        the element at the specified positions in this nested AST or F.NIL
      • getIndex

        public IExpr getIndex​(int... positions)
        Description copied from interface: ITensorAccess
        Low level access. It is assumed that positions is a full index within the dimensions of this ISparseArray or IAST (vector/matrix/tensor) object.
        Specified by:
        getIndex in interface ITensorAccess
        Parameters:
        positions - full index within the dimensions of this object
        Returns:
        the expression at the given index or F.NIL
      • getPart

        public final IExpr getPart​(it.unimi.dsi.fastutil.ints.IntList positions)
        Description copied from interface: IAST
        Returns the element at the specified positions in the nested ASTs.
        Specified by:
        getPart in interface IAST
        Parameters:
        positions - index of the element to return
        Returns:
        the element at the specified positions in this nested AST
      • getProperty

        public Object getProperty​(IAST.PROPERTY key)
        Returns the value to which the specified property is mapped, or null if this map contains no mapping for the property.
        Parameters:
        key -
        Returns:
        See Also:
        putProperty(PROPERTY, Object)
      • has

        public final boolean has​(Predicate<IExpr> predicate,
                                 boolean heads)
        Returns true, if at least one of the elements in the subexpressions or the expression itself, satisfy the given unary predicate.
        Specified by:
        has in interface IExpr
        Parameters:
        predicate - a unary predicate
        heads - if set to false, only the arguments of an IAST should be tested and not the Head[] element.
        Returns:
      • hasTrigonometricFunction

        public final boolean hasTrigonometricFunction()
        Description copied from interface: IAST
        Returnstrue, if one of the headers of this AST contains a trigonometric function.
        Specified by:
        hasTrigonometricFunction in interface IAST
        Returns:
        true, if one of the headers of this AST contains a trigonometric function.
      • hierarchy

        public int hierarchy()
        A unique integer ID for the implementation of this expression
        Specified by:
        hierarchy in interface IExpr
        Returns:
        a unique integer id for the implementation of this expression
      • indexOf

        public int indexOf​(IExpr expr)
        If this is of type IAST, find the first argument position, which equals expr . The search starts at index 1. Otherwise return -1.

        Note: If this is an IAssociation the position of the rule will be searched.

        Specified by:
        indexOf in interface IExpr
        Returns:
        -1 if no position was found
      • indexOf

        public int indexOf​(Predicate<? super IExpr> predicate,
                           int fromIndex)
        If this is of type IAST, find the first argument position, which fulfills the predicate. The search starts at index fromIndex. Otherwise return -1 .
        Specified by:
        indexOf in interface IExpr
        Returns:
        the index of the first occurrence of the specified predicate, starting at the specified index, or -1 if no position was found
      • findFirst

        public IExpr findFirst​(Function<IExpr,​IExpr> function)
        Find the first argument position, where the the function doesn't return F.NIL. The search starts at index 1.

        Note: If this is an IAssociation the rule at the position will be returned.

        Specified by:
        findFirst in interface IAST
        Returns:
        F.NIL if no position was found
      • internalFormString

        public final CharSequence internalFormString​(boolean symbolsAsFactoryMethod,
                                                     int depth)
        Return the internal Java form of this expression.
        Specified by:
        internalFormString in interface IExpr
        Parameters:
        symbolsAsFactoryMethod - if true use the F.symbol() method, otherwise print the symbol name.
        depth - the recursion depth of this call. 0 indicates "recurse without a limit".
        Returns:
        the internal Java form of this expression
      • internalJavaString

        public CharSequence internalJavaString​(SourceCodeProperties properties,
                                               int depth,
                                               Function<ISymbol,​? extends CharSequence> variables)
        Return the internal Java form of this expression.
        Specified by:
        internalJavaString in interface IExpr
        Parameters:
        properties - the settings to use for code generation.
        depth - the recursion depth of this call. 0 indicates "recurse without a limit".
        variables - TODO
        Returns:
        the internal Java form of this expression
      • internalScalaString

        public final CharSequence internalScalaString​(boolean symbolsAsFactoryMethod,
                                                      int depth)
        Return the internal Scala form of this expression.
        Specified by:
        internalScalaString in interface IExpr
        Parameters:
        symbolsAsFactoryMethod - if true use the F.symbol() method, otherwise print the symbol name.
        depth - the recursion depth of this call. 0 indicates "recurse without a limit".
        Returns:
        the internal Scala form of this expression
      • isAbs

        public boolean isAbs()
        Test if this expression is the function Abs[<arg>]
        Specified by:
        isAbs in interface IExpr
        Returns:
      • isAllExpanded

        public boolean isAllExpanded()
        Test if this expression and all subexpressions are already expanded i.e. all Plus, Times, Power (sub-)expressions are expanded.
        Specified by:
        isAllExpanded in interface IExpr
        Returns:
      • isAlternatives

        public final boolean isAlternatives()
        Test if this expression is the Alternatives function Alternatives[<pattern1>, <pattern2>, ...]
        Specified by:
        isAlternatives in interface IExpr
        Returns:
      • isAnd

        public final boolean isAnd()
        Test if this expression is the function And[<arg>,...] and has at least 2 arguments.
        Specified by:
        isAnd in interface IExpr
        Returns:
      • isArcCos

        public final boolean isArcCos()
        Test if this expression is the function ArcCos[<arg>]
        Specified by:
        isArcCos in interface IExpr
        Returns:
      • isArcCosh

        public final boolean isArcCosh()
        Test if this expression is the function ArcCosh[<arg>]
        Specified by:
        isArcCosh in interface IExpr
        Returns:
      • isArcSin

        public final boolean isArcSin()
        Test if this expression is the function ArcSin[<arg>]
        Specified by:
        isArcSin in interface IExpr
        Returns:
      • isArcSinh

        public final boolean isArcSinh()
        Test if this expression is the function ArcSinh[<arg>]
        Specified by:
        isArcSinh in interface IExpr
        Returns:
      • isArcTan

        public final boolean isArcTan()
        Test if this expression is the function ArcTan[<arg>]
        Specified by:
        isArcTan in interface IExpr
        Returns:
      • isArcTanh

        public final boolean isArcTanh()
        Test if this expression is the function ArcTanh[<arg>]
        Specified by:
        isArcTanh in interface IExpr
        Returns:
      • isAST

        public boolean isAST()
        Test if this expression is an AST function, which contains a header element (i.e. the function name) at index position 0 and some optional argument elements at the index positions 1..n. Therefore this expression is no atomic expression.
        Specified by:
        isAST in interface IExpr
        Returns:
        See Also:
        IExpr.isAtom()
      • isAST

        public boolean isAST​(IExpr header)
        Test if this expression is an AST function, which contains the given header element at index position 0 and some optional argument elements at the index positions 1..(size()-1). Therefore this expression is not an atomic expression.
        Specified by:
        isAST in interface IExpr
        Parameters:
        header - the header element at position 0, which should be tested
        Returns:
        See Also:
        IExpr.isAtom()
      • isAST

        public boolean isAST​(IExpr header,
                             int length)
        Test if this expression is an IAST function, which contains the given header element at index position 0 and optional argument elements at the index positions 1..(length-1). If this test gives true this expression is not an atomic expression.
        Specified by:
        isAST in interface IExpr
        Parameters:
        header - the header element at position 0, which should be tested
        length - the size the AST expression must have (inclusive head element)
        Returns:
        See Also:
        IExpr.isAtom()
      • isAST

        public boolean isAST​(IExpr header,
                             int length,
                             IExpr... args)
        Test if this expression is an IAST function, which contains the given header element at index position 0 and optional argument elements at the index positions 1..(length-1). If this test gives true this expression is not an atomic expression.
        Specified by:
        isAST in interface IExpr
        Parameters:
        header - the header element at position 0, which should be tested
        length - the size the AST expression must have
        args - the arguments of this AST which should be tested, if they are equal, a null value argument skips the equals check.
        Returns:
        See Also:
        IExpr.isAtom()
      • isAST

        public boolean isAST​(IExpr head,
                             int minLength,
                             int maxLength)
        Test if this expression is an IAST function, which contains the given header element at index position 0 and optional argument elements at the index positions 1..(length-1). If this test gives true this expression is not an atomic expression.
        Specified by:
        isAST in interface IExpr
        Parameters:
        head - the header element at position 0, which should be tested
        minLength - the minimum size the AST expression must have
        maxLength - the maximum size the AST expression must have
        Returns:
        See Also:
        IExpr.isAtom()
      • isAST

        public boolean isAST​(String symbol)
        Test if this expression is an IAST function, where the string representation of the header element at index position 0 equals the given symbol and some optional argument elements at the index positions 1..(size()-1). If this test gives true this expression is not an atomic expression.

        Example: isAST("Sin") gives true for Sin(Pi/2).

        Note: this is a performance critical method, only use it in special cases like for example UI handling etc.

        Specified by:
        isAST in interface IExpr
        Parameters:
        symbol - string representation of the header element at index position 0
        Returns:
        See Also:
        IExpr.isAtom()
      • isAST

        public boolean isAST​(String symbol,
                             int length)
        Test if this expression is an IAST function, where the string representation of the header element at index position 0 equals the given symbol and some optional argument elements at the index positions 1..(length-1).
        Therefore this expression is no atomic expression.
        Example: isAST("Sin", 2) gives true for Sin(0).
        Specified by:
        isAST in interface IExpr
        Parameters:
        symbol - string representation of the header element at index position 0
        length - the size the AST expression must have
        Returns:
        See Also:
        IExpr.isAtom()
      • isAST0

        public boolean isAST0()
        Test if this expression is an IAST function, which contains a header element (i.e. the function name) at index position 0 and no argument elements.
        Therefore this expression is no atomic expression.
        Specified by:
        isAST0 in interface IExpr
        Returns:
        See Also:
        IExpr.isAtom()
      • isAST1

        public boolean isAST1()
        Test if this expression is an IAST function, which contains a header element (i.e. the function name) at index position 0 and one argument element at the index position 1.
        Therefore this expression is no atomic expression.
        Specified by:
        isAST1 in interface IExpr
        Returns:
        See Also:
        IExpr.isAtom()
      • isAST2

        public boolean isAST2()
        Test if this expression is an IAST function, which contains a header element (i.e. the function name) at index position 0 and two argument elements at the index positions 1, 2.
        Therefore this expression is no atomic expression.
        Specified by:
        isAST2 in interface IExpr
        Returns:
        See Also:
        IExpr.isAtom()
      • isAST3

        public boolean isAST3()
        Test if this expression is an IAST function, which contains a header element (i.e. the function name) at index position 0 and three argument elements at the index positions 1, 2, 3.
        Therefore this expression is no atomic expression.
        Specified by:
        isAST3 in interface IExpr
        Returns:
        See Also:
        IExpr.isAtom()
      • isASTSizeGE

        public boolean isASTSizeGE​(IExpr header,
                                   int length)
        Test if this expression is an IAST function, which contains the given header element at index position 0 and optional argument elements at the index positions 1..n. n must be greater equal than the given length.
        Therefore this expression is no atomic expression.
        Specified by:
        isASTSizeGE in interface IExpr
        Parameters:
        header - the header element at position 0, which should be tested
        length - the size the AST expression must have
        Returns:
        See Also:
        IExpr.isAtom()
      • isAtom

        public boolean isAtom()
        Description copied from interface: IExpr
        Test if this expression is an atomic expression (i.e. no AST expression)
        Specified by:
        isAtom in interface IExpr
        Returns:
      • isComplexInfinity

        public final boolean isComplexInfinity()
        Test if this expression is representing ComplexInfinity (i.e. DirectedInfinity[])
        Specified by:
        isComplexInfinity in interface IExpr
        Returns:
      • isCondition

        public boolean isCondition()
        Test if this expression is the Condition function Condition[<arg1>, <arg2>]
        Specified by:
        isCondition in interface IExpr
        Returns:
      • isConditionalExpression

        public boolean isConditionalExpression()
        Test if this expression is the ConditionalExpression function ConditionalExpression[<arg1>, <arg2>]
        Specified by:
        isConditionalExpression in interface IExpr
        Returns:
      • isConjugate

        public final boolean isConjugate()
        Test if this expression is the function Conjugate[<arg>]
        Specified by:
        isConjugate in interface IExpr
        Returns:
      • isCos

        public final boolean isCos()
        Test if this expression is the function Cos[<arg>]
        Specified by:
        isCos in interface IExpr
      • isCosh

        public final boolean isCosh()
        Test if this expression is the function Cosh[<arg>]
        Specified by:
        isCosh in interface IExpr
        Returns:
      • isDefer

        public final boolean isDefer()
        Test if this expression is the function Defer[<arg>]
        Specified by:
        isDefer in interface IExpr
        Returns:
      • isDerivative

        public final IAST[] isDerivative()
        Test if this expression is a Derivative[number, ...][symbol][arg,...] or Derivative[number][symbol] expression and return the corresponding IAST structures.
        • The expression at index [0] contains the Derivative[number, ...] AST part.
        • The expression at index [1] contains the Derivative[...][symbol] AST part.
        • The expression at index [2] contains the Derivative[...][...][arg, ...] AST part, if available.

        Note: the result at index [2] maybe null , if no argument is available.

        Specified by:
        isDerivative in interface IExpr
        Returns:
        null if the expression is not a Derivative[number, ...][symbol][arg, ...] or Derivative[number, ...][symbol] expression.
      • isDerivativeAST1

        public final IAST[] isDerivativeAST1()
        Test if this expression is a Derivative[number][symbol][arg] or Derivative[number][symbol] expression with one argument and return the corresponding IAST structures.
        • The expression at index [0] contains the Derivative[number,...] AST part.
        • The expression at index [1] contains the Derivative[...][symbol] AST part.
        • The expression at index [2] contains the Derivative[...][...][arg] AST part, if available.

        Note: the result at index [2] maybe null , if no argument is available.

        Specified by:
        isDerivativeAST1 in interface IExpr
        Returns:
        null if the expression is not a Derivative[number][symbol][arg] or Derivative[number][symbol] expression.
      • isDirectedInfinity

        public final boolean isDirectedInfinity()
        Test if this expression is representing a DirectedInfinity (i.e. Infinity->DirectedInfinity[1], -Infinity->DirectedInfinity[-1], ComplexInfinity->DirectedInfinity[])
        Specified by:
        isDirectedInfinity in interface IExpr
        Returns:
      • isDirectedInfinity

        public final boolean isDirectedInfinity​(IExpr x)
        Test if this expression is representing a DirectedInfinity (i.e. Infinity->DirectedInfinity[1], -Infinity->DirectedInfinity[-1], ComplexInfinity->DirectedInfinity[])
        Specified by:
        isDirectedInfinity in interface IExpr
        Returns:
      • isContinuousDistribution

        public boolean isContinuousDistribution()
        Description copied from interface: IExpr
        Test if this expression is a continuous distribution AST (i.e. evakuator is instanceof IContinuousDistribution
        Specified by:
        isContinuousDistribution in interface IExpr
        Returns:
      • isDiscreteDistribution

        public boolean isDiscreteDistribution()
        Description copied from interface: IExpr
        Test if this expression is a discrete distribution AST (i.e. BinomialDistribution(), PoissonDistribution(),...)
        Specified by:
        isDiscreteDistribution in interface IExpr
        Returns:
      • isDistribution

        public boolean isDistribution()
        Description copied from interface: IExpr
        Test if this expression is a distribution AST (i.e. NormalDistribution(), PoissonDistribution(),...)
        Specified by:
        isDistribution in interface IExpr
        Returns:
      • isEmpty

        public final boolean isEmpty()
        Description copied from interface: IAST
        Test if this AST contains no argument
        Specified by:
        isEmpty in interface IAST
        Specified by:
        isEmpty in interface IExpr
        Returns:
      • isNotEmpty

        public final boolean isNotEmpty()
        Description copied from interface: IExpr
        Test if this expression is an IAST and contains at least 1 argument
        Specified by:
        isNotEmpty in interface IExpr
        Returns:
      • isEqual

        public final boolean isEqual()
        Test if this expression is the function Equal[<arg1>, <arg2>]
        Specified by:
        isEqual in interface IExpr
        Returns:
      • isEvalFlagOff

        public final boolean isEvalFlagOff​(int i)
        Are the given evaluation flags disabled for this list ?
        Specified by:
        isEvalFlagOff in interface IAST
        Specified by:
        isEvalFlagOff in interface IExpr
        Returns:
        See Also:
        IAST.NO_FLAG
      • isEvalFlagOn

        public final boolean isEvalFlagOn​(int i)
        Are the given evaluation flags enabled for this list ?
        Specified by:
        isEvalFlagOn in interface IAST
        Specified by:
        isEvalFlagOn in interface IExpr
        Returns:
        See Also:
        IAST.NO_FLAG
      • isExcept

        public boolean isExcept()
        Test if this expression is the Except function Except(<pattern1>) or Except(<pattern1>, <pattern2>)
        Specified by:
        isExcept in interface IExpr
        Returns:
      • isExpanded

        public boolean isExpanded()
        Test if this expression is already expanded i.e. Plus, Times, Power expression is expanded.
        Specified by:
        isExpanded in interface IExpr
        Returns:
      • isFlatAST

        public boolean isFlatAST()
        Test if this expression is an AST list, which contains a header element (i.e. a function symbol like for example Dot, Plus or Times) with attribute Flat at index position 0 and some optional argument elements at the index positions 1..(size()-1). Examples for Flat functions are Dot[], Plus[] or Times[]. Therefore this expression is no atomic expression.
        Specified by:
        isFlatAST in interface IExpr
        Returns:
        See Also:
        IExpr.isAtom()
      • isFree

        public final boolean isFree​(IPatternMatcher predicate,
                                    boolean heads)
        Returns true, if all of the elements in the subexpressions or the expression itself, did not satisfy the given unary predicate.
        Specified by:
        isFree in interface IExpr
        Parameters:
        predicate - a unary predicate
        heads - if set to false, only the arguments of an IAST should be tested and not the Head[] element.
        Returns:
      • isFree

        public final boolean isFree​(Predicate<IExpr> predicate,
                                    boolean heads)
        Returns true, if all of the elements in the subexpressions or the expression itself, did not satisfy the given unary predicate.
        Specified by:
        isFree in interface IExpr
        Parameters:
        predicate - a unary predicate
        heads - if set to false, only the arguments of an IAST should be tested and not the Head[] element.
        Returns:
      • isFreeAST

        public final boolean isFreeAST​(IExpr pattern)
        Returns true, if all of the elements in the subexpressions or the expression itself, aren't ASTs with a head which match the given pattern.
        Specified by:
        isFreeAST in interface IExpr
        Parameters:
        pattern - a pattern-matching expression
        Returns:
      • isFreeAST

        public final boolean isFreeAST​(Predicate<IExpr> predicate)
        Returns true, if all of the elements in the subexpressions or the expression itself, aren't ASTs with a head which match the given predicate.
        Specified by:
        isFreeAST in interface IExpr
        Parameters:
        predicate - a unary predicate
        Returns:
      • isFreeAt

        public final boolean isFreeAt​(int position,
                                      IExpr pattern)
        Returns true, if all of the elements in the expressions or the expression itself at the given position, did not match the pattern. Calls get(Position).isFree(pattern, true).
        Specified by:
        isFreeAt in interface IAST
        pattern - a pattern-matching expression
        Returns:
      • isFreeOfPatterns

        public final boolean isFreeOfPatterns()
        Returns true, if all of the elements in the subexpressions or the expression itself, are no pattern objects.
        Specified by:
        isFreeOfPatterns in interface IExpr
        Returns:
        true if the expression contains no IPatternObject.
      • isFunction

        public final boolean isFunction()
        Test if this expression is a Function( arg1 ) or Function( arg1, arg2 ) expression with at least 1 argument.
        Specified by:
        isFunction in interface IExpr
        Returns:
        See Also:
        IExpr.isPureFunction()
      • isGEOrdered

        public final boolean isGEOrdered​(IExpr obj)
        Compares this expression with the specified expression for order. Returns true if this expression is canonical greater than or equal to the specified expression (<= relation).
        Specified by:
        isGEOrdered in interface IExpr
        Parameters:
        obj - an expression to compare with
        Returns:
        true if this expression is canonical greater than or equal to the specified expression.
      • isGTOrdered

        public final boolean isGTOrdered​(IExpr obj)
        Compares this expression with the specified expression for order. Returns true if this expression is canonical greater than the specified expression (< relation).
        Specified by:
        isGTOrdered in interface IExpr
        Parameters:
        obj - an expression to compare with
        Returns:
        true if this expression is canonical greater than the specified expression.
      • isHoldPatternOrLiteral

        public final boolean isHoldPatternOrLiteral()
        Test if this expression is the HoldPattern function HoldPattern[<expression>] or the deprecated Literal[<expression>] form.
        Specified by:
        isHoldPatternOrLiteral in interface IExpr
        Returns:
      • isFunctionID

        public boolean isFunctionID​(int... builtinIDs)
        Test if this expression is an IAST function with one of the built-in head IDs.
        Specified by:
        isFunctionID in interface IExpr
        Returns:
        See Also:
        IExpr.isPureFunction()
      • isHoldAllCompleteAST

        public final boolean isHoldAllCompleteAST()
        Test if this expression is an AST list, which contains a header element with attribute ISymbol.HOLDALLCOMPLETE at index position 0.
        Specified by:
        isHoldAllCompleteAST in interface IExpr
        Returns:
      • isInfinity

        public final boolean isInfinity()
        Test if this expression is representing Infinity (i.e. Infinity->DirectedInfinity[1])
        Specified by:
        isInfinity in interface IExpr
        Returns:
      • isBooleanFormula

        public boolean isBooleanFormula()
        Test if this expression is a boolean formula (i.e. a symbol or a boolean function And, Equivalent, Nand, Nor, Not, Or, Xor where all arguments are also "boolean formulas")
        Specified by:
        isBooleanFormula in interface IExpr
        Returns:
        true, if the given expression is a boolean formula or a symbol.
        See Also:
        IExpr.isRealResult()
      • isBooleanResult

        public boolean isBooleanResult()
        Test if this expression is a boolean function (i.e. a symbol or a boolean function like for example And, Equivalent, Equal, Greater, GreaterEqual, Less, LessEqual, Nand, Nor, Not, Or, Xor,... where all arguments are also "boolean functions") or a symbol or some builtin predicates like for example IntegerQ, EvenQ, PrimeQ,....
        Specified by:
        isBooleanResult in interface IExpr
        Returns:
        true, if the given expression is a boolean function or a symbol.
        See Also:
        IExpr.isRealResult()
      • isBooleanFunction

        public boolean isBooleanFunction()
        Test if this expression is a boolean function with head And, Equivalent, Nand, Nor, Not, Or, Xor.
        Specified by:
        isBooleanFunction in interface IExpr
        Returns:
      • isComparatorFunction

        public boolean isComparatorFunction()
        Test if this expression is a comparator function (i.e. a function with head Equal, Equivalent, Greater, GreaterEqual, Less, LessEqual, Inequlity, SameQ, Unequal, UnsameQ and size greater 2)
        Specified by:
        isComparatorFunction in interface IExpr
        Returns:
        true, if the given expression is a comparator function.
      • isIntegerResult

        public boolean isIntegerResult()
        Test if this expression is a integer function (i.e. a number, a symbolic constant or an integer function where all arguments are also "integer functions")
        Specified by:
        isIntegerResult in interface IExpr
        Returns:
        true, if the given expression is a integer function or value.
        See Also:
        IExpr.isRealResult()
      • isInterval

        public boolean isInterval()
        Test if this expression is a closed interval expression with one or more List[min, max] arguments Interval[{min1, max1}, {min2, max2}, ...] which represent the union of the interval ranges.
        Specified by:
        isInterval in interface IExpr
        Returns:
      • isIntervalData

        public boolean isIntervalData()
        Test if this expression is a mixed opened/closed interval expression with one or more {min, Less/LessEqual, Less/LessEqual, max} list arguments which represent the union of the interval ranges. The empty IntervalData() interval returns also true.
        Specified by:
        isIntervalData in interface IExpr
        Returns:
      • isInterval1

        public boolean isInterval1()
        Test if this expression is a closed/open ended interval expression with one List[min, max] argument Interval[{min, max}]
        Specified by:
        isInterval1 in interface IExpr
        Returns:
      • isEmptyList

        public boolean isEmptyList()
        Test if this expression is an empty list (i.e. a list {})
        Specified by:
        isEmptyList in interface IExpr
        Returns:
      • isNonEmptyList

        public boolean isNonEmptyList()
        Test if this expression is a list with at least one element (i.e. a list {element, ...} )
        Specified by:
        isNonEmptyList in interface IExpr
        Returns:
      • isList

        public boolean isList()
        Test if this expression is a list (i.e. an AST with head List)
        Specified by:
        isList in interface IExpr
        Returns:
      • isList

        public boolean isList​(int[] dimensions)
        Test if this expression is a nested list with the dimensions.
        Specified by:
        isList in interface IExpr
        Parameters:
        dimensions - the dimensions of the tensor
        Returns:
      • isListOfPoints

        public boolean isListOfPoints​(int pointDimension)
        Test if this is a list of points in the given dimension. The head of the points can be S.List, S.Labeled or S.Style
        Specified by:
        isListOfPoints in interface IExpr
        Returns:
      • isListableAST

        public final boolean isListableAST()
        Description copied from interface: IExpr
        Test if this expression is an IAST list, which contains a header element (i.e. a function symbol at index position 0 and some optional argument elements at the index positions 1..n. Examples for Listable functions are Cos[], Plus[] or Times[] . Therefore this expression is no atomic expression.
        Specified by:
        isListableAST in interface IExpr
        Returns:
        See Also:
        IExpr.isAtom()
      • isList

        public boolean isList​(Predicate<IExpr> pred)
        Test if this expression is a list (i.e. an AST with head List) with all arguments fulfill the predicate.
        Specified by:
        isList in interface IExpr
        Returns:
      • isListOfMatrices

        public boolean isListOfMatrices()
        Test if this expression is a list of matrices and contains at least 1 matrix.
        Specified by:
        isListOfMatrices in interface IExpr
        Returns:
      • isListOfEdges

        public org.jgrapht.GraphType isListOfEdges()
        Test if this expression is a list of DirectedEdge or UndirectedEdge
        Specified by:
        isListOfEdges in interface IExpr
        Returns:
      • isEdge

        public boolean isEdge()
        Test if this expression is an DirectedEdge, UndirectedEdge, Rule, TwoWayRule.
        Specified by:
        isEdge in interface IExpr
        Returns:
      • isListOfRules

        public boolean isListOfRules​(boolean ignoreEmptySublists)
        Test if this expression is a list of rules (head Rule or RuleDelayed)
        Specified by:
        isListOfRules in interface IExpr
        Parameters:
        ignoreEmptySublists - if true, ignore elements which equals an empty list { }
        Returns:
        See Also:
        IExpr.isList(), IExpr.isMatrix(boolean), IExpr.isVector()
      • isListOfRulesOrAssociation

        public boolean isListOfRulesOrAssociation​(boolean ignoreEmptySublists)
        Test if this expression is a list of rules (head Rule or RuleDelayed) or an Association.
        Specified by:
        isListOfRulesOrAssociation in interface IExpr
        Parameters:
        ignoreEmptySublists - if true, ignore elements which equals an empty list { } but only in lists.
        Returns:
      • isLog

        public final boolean isLog()
        Test if this expression is the function Log[<arg>]
        Specified by:
        isLog in interface IExpr
        Returns:
      • isMatrix

        public int[] isMatrix​(boolean setMatrixFormat)
        Test if this expression is a matrix and return the dimensions as array [row-dimension, column-dimension]. This expression is only a matrix, if it is a ASTRealMatrix or a List(...) where all elements are lists with the header List and have the same size.
        Specified by:
        isMatrix in interface IExpr
        Parameters:
        setMatrixFormat - set the IAST.IS_MATRIX flag for formatting as a matrix.
        Returns:
        null if the expression is not a matrix
      • isMatrixIgnore

        public int[] isMatrixIgnore()
        Test if this expression is a matrix and return the dimensions as array [row-dimension, column-dimension]. This expression is a matrix, if it is a ASTRealMatrix or a List(...) where elements which could not be converted to a row vector are ignored.
        Specified by:
        isMatrixIgnore in interface IExpr
        Returns:
        null if the expression is not a matrix
      • isMember

        public boolean isMember​(IExpr pattern,
                                boolean heads,
                                IVisitorBoolean visitor)
        Description copied from interface: IExpr
        Returns true, if at least one of the elements in the subexpressions, match the given pattern. If visitor==null the isMember() method only operates at level 1.
        Specified by:
        isMember in interface IExpr
        Parameters:
        pattern - a pattern-matching expression
        heads - if set to false, only the arguments of an IAST should be tested and not the Head[] element.
        visitor - if null use VisitorBooleanLevelSpecification(predicate, 1, heads)
        Returns:
      • isModule

        public final boolean isModule()
        Test if this expression is the Module function Module[<arg1>, <arg2>]
        Specified by:
        isModule in interface IExpr
        Returns:
      • isNegative

        public boolean isNegative()
        Test if this object is a negative signed number. For an IAST object the method checks, if it is a numeric constant. If the IAST object evaluates to a negative numeric expression this method returns true.
        Specified by:
        isNegative in interface IExpr
        Returns:
        true, if this < 0; false in all other case.
      • isNegativeInfinity

        public boolean isNegativeInfinity()
        Test if this expression is representing -Infinity (i.e. -Infinity->DirectedInfinity[-1])
        Specified by:
        isNegativeInfinity in interface IExpr
        Returns:
      • isNegativeResult

        public boolean isNegativeResult()
        Test if this expression has a negative result (i.e. less than 0) or is assumed to be negative.
        Specified by:
        isNegativeResult in interface IExpr
        Returns:
        true, if the given expression is a negative function or value.
        See Also:
        IExpr.isRealResult()
      • isNonNegativeResult

        public boolean isNonNegativeResult()
        Test if this expression has a non-negative result (i.e. greater equal 0) or is assumed to be non-negative.
        Specified by:
        isNonNegativeResult in interface IExpr
        Returns:
        true, if the given expression is a non-negative function or value.
        See Also:
        IExpr.isRealResult()
      • isNot

        public final boolean isNot()
        Test if this expression is the function Not[<arg>].
        Specified by:
        isNot in interface IExpr
        Returns:
      • isNumericArgument

        public boolean isNumericArgument​(boolean allowList)
        Test if this expression is a numeric number (i.e. an instance of type INum or type IComplexNum), an ASTRealVector or an ASTRealMatrix.
        Specified by:
        isNumericArgument in interface IExpr
      • isNumericFunction

        public boolean isNumericFunction​(boolean allowList)
        Test if this expression is a numeric function (i.e. a number, a symbolic constant or a function (with attribute NumericFunction) where all arguments are also "numeric functions")
        Specified by:
        isNumericFunction in interface IExpr
        Parameters:
        allowList - if true a List(...) AST is seen, as if it has attribute ISymbol.NUMERICFUNCTION
        Returns:
        true, if the given expression is a numeric function or value.
        See Also:
        IExpr.isRealResult()
      • isNumericFunction

        public boolean isNumericFunction​(VariablesSet varSet)
        Test if this expression is a numeric function (i.e. a number, a symbolic constant or a function (with attribute NumericFunction) where all arguments are also "numeric functions") under the assumption, that all variables contained in varSet are also numeric.
        Specified by:
        isNumericFunction in interface IExpr
        Returns:
        true, if the given expression is a numeric function or value, assuming all variables contained in varSet are also numeric.
      • isNumericFunction

        public boolean isNumericFunction​(IExpr expr)
        Test if this expression is a numeric function (i.e. a number, a symbolic constant or a function (with attribute NumericFunction) where all arguments are also "numeric functions") under the assumption, that the variable is also numeric.
        Specified by:
        isNumericFunction in interface IExpr
        Returns:
      • isNumericFunction

        public boolean isNumericFunction​(Function<IExpr,​String> list)
        Test if this expression is a numeric function (i.e. a number, a symbolic constant or a function (with attribute NumericFunction) where all arguments are also "numeric functions") under the assumption, that all variables contained in list are also numeric.
        Specified by:
        isNumericFunction in interface IExpr
        Parameters:
        list - a list of variable symbols
        Returns:
      • isNumericMode

        public boolean isNumericMode()
        Test if this expression contains a numeric number (i.e. of type INum or IComplexNum.
        Specified by:
        isNumericMode in interface IExpr
        Returns:
        true, if the given expression contains numeric number (i.e. of type INum or IComplexNum.
        See Also:
        IExpr.isRealResult()
      • isOneIdentityAST1

        public boolean isOneIdentityAST1()
        Test if this expression is an AST list, which contains a header element (i.e. a function symbol like for example Plus or Times) with attribute OneIdentity at index position 0 and exactly one argument at the index position 1 . Examples for OneIdentity functions are Plus[] or Times[]. Therefore this expression is no atomic expression.
        Specified by:
        isOneIdentityAST1 in interface IExpr
        Returns:
        See Also:
        IExpr.isAtom()
      • isOptional

        public final boolean isOptional()
        Test if this expression is the Optional function Optional[<pattern>] or Optional[<pattern>, <value>]
        Specified by:
        isOptional in interface IExpr
        Returns:
      • isOr

        public final boolean isOr()
        Test if this expression is the function Or[<arg>,...] and has at least 2 arguments.
        Specified by:
        isOr in interface IExpr
        Returns:
      • isOrderlessAST

        public final boolean isOrderlessAST()
        Test if this expression is an AST list, which contains a header element (i.e. a function symbol like for example Plus or Times) with attribute Orderless at index position 0 and some optional argument elements at the index positions 1..n. Examples for Orderless functions are Plus[] or Times[] . Therefore this expression is no atomic expression.
        Specified by:
        isOrderlessAST in interface IExpr
        Returns:
        See Also:
        IExpr.isAtom()
      • isPatternDefault

        public boolean isPatternDefault()
        Return true, if the expression is a pattern object with an associated default value (for example 0 is the default value for the addition expression x_+y_. )
        Specified by:
        isPatternDefault in interface IExpr
        Returns:
      • isPatternExpr

        public final boolean isPatternExpr()
        Test if this expression or a subexpression is a pattern object. Used in pattern-matching; checks flags in IAST with flag IAST.CONTAINS_PATTERN_EXPR.
        Specified by:
        isPatternExpr in interface IExpr
        Returns:
      • isPatternTest

        public final boolean isPatternTest()
        Test if this expression is the PatternTest function PatternTest[<pattern>, <test>]
        Specified by:
        isPatternTest in interface IExpr
        Returns:
      • isPiecewise

        public int[] isPiecewise()
        Test if this expression is a Piecewise({{...}}},...) function and the first argument is a matrix with dimension [row-dimension, 2] and row-dimension > 0 . Return the dimensions of the matrix as array [row-dimension, column-dimension] . The first argument is only a matrix, if it is a List(...) where all elements are lists with the header List and have the same size.
        Specified by:
        isPiecewise in interface IExpr
        Returns:
        null if the expression is not a Piecewise({{...}}},...) function or if the first argument is not a matrix
      • isPlus

        public boolean isPlus()
        Test if this expression is the addition function Plus[<arg1>, <arg2>, ...] with at least 2 arguments.
        Specified by:
        isPlus in interface IExpr
        Returns:
      • isPlus2

        public boolean isPlus2()
        Test if this expression is the S.Plus function Plus[<arg1>, <arg2>] with exactly 2 arguments.
        Specified by:
        isPlus2 in interface IExpr
        Returns:
      • isPlus3

        public boolean isPlus3()
        Test if this expression is the S.Plus function Plus[<arg1>, <arg2>, <arg3>] with exactly 3 arguments.
        Specified by:
        isPlus3 in interface IExpr
        Returns:
      • isPlusTimesPower

        public boolean isPlusTimesPower()
        Test if this expression is a Plus, Power or Times function.
        Specified by:
        isPlusTimesPower in interface IExpr
        Returns:
      • isPolynomial

        public final boolean isPolynomial​(IAST variables)
        Test if this expression is a polynomial for the given list of variables. Note: if the list contains no argument, this method returns true for a Symbol expression.
        Specified by:
        isPolynomial in interface IExpr
        Parameters:
        variables - a list of variables or an empty list
        Returns:
        true if this expression is a polynomial; falseotherwise
      • isPolynomial

        public final boolean isPolynomial​(IExpr variable)
        Test if this expression is a polynomial for the given variable. Note: if the variable is set to null, this method returns true for a Symbol expression.
        Specified by:
        isPolynomial in interface IExpr
        Parameters:
        variable - the variable of the polynomial
        Returns:
      • isPolynomialStruct

        public boolean isPolynomialStruct()
        Test if this expression has a polynomial structiure, i.e. no built-in function as head
        Specified by:
        isPolynomialStruct in interface IExpr
        Returns:
        true if this expression has a polynomial structure; false otherwise
      • isPolynomialOfMaxDegree

        public final boolean isPolynomialOfMaxDegree​(IAST variables,
                                                     long maxDegree)
      • isPolynomialOfMaxDegree

        public final boolean isPolynomialOfMaxDegree​(ISymbol variable,
                                                     long maxDegree)
        Test if this expression is a polynomial of maxDegree (i.e. the maximum exponent <= maxDegree) for the given variable.
        Specified by:
        isPolynomialOfMaxDegree in interface IExpr
        Parameters:
        variable - the variable of the polynomial
        maxDegree - the maximum degree of the polynomial; maxDegree must be greater 0
        Returns:
      • isPositive

        public boolean isPositive()
        Test if this object is a positive signed number. For an IAST object the method checks, if it is a numeric constant. If the IAST object evaluates to a positive numeric expression this method returns true.
        Specified by:
        isPositive in interface IExpr
        Returns:
        true, if this > 0; false in all other case.
      • isPositiveResult

        public boolean isPositiveResult()
        Test if this expression has a positive result (i.e. greater than 0) or is assumed to be positive.
        Specified by:
        isPositiveResult in interface IExpr
        Returns:
        true, if the given expression is a positive function or value.
        See Also:
        IExpr.isRealResult()
      • isPower

        public boolean isPower()
        Test if this expression is the function Power[<arg1>, <arg2>]
        Specified by:
        isPower in interface IExpr
        Returns:
      • isPureFunction

        public final boolean isPureFunction()
        Test if this expression is a "pure" or "anonymous" Function( arg1 ) expression with exactly 1 argument.
        Specified by:
        isPureFunction in interface IExpr
        Returns:
        See Also:
        IExpr.isFunction()
      • isRationalResult

        public final boolean isRationalResult()
        Test if this expression is a symbolic rational function (i.e. a number, a symbolic constant or an rational function where all arguments are also "rational functions")
        Specified by:
        isRationalResult in interface IExpr
        Returns:
        true, if the given expression is a rational function or value.
        See Also:
        IExpr.isRealResult()
      • isRealMatrix

        public boolean isRealMatrix()
        Test if this expression is a real matrix (i.e. an instance of ASTRealMatrix or a List[List[...],...,List[...]] matrix with elements of type org.matheclipse.core.expression.Num.
        Specified by:
        isRealMatrix in interface IExpr
        Returns:
      • isRealResult

        public boolean isRealResult()
        Test if this expression is a real function (i.e. a number, a symbolic constant or an integer function where all arguments are also "reals functions")
        Specified by:
        isRealResult in interface IExpr
        Returns:
        true, if the given expression is a real function or value.
        See Also:
        IExpr.isIntegerResult()
      • isRealVector

        public boolean isRealVector()
        Test if this expression is a real vector (i.e. an instance of ASTRealVector or a List[...] with elements of type org.matheclipse.core.expression.Num.
        Specified by:
        isRealVector in interface IExpr
        Returns:
      • isRule

        public boolean isRule()
        Test if this expression is of the form Rule[<arg1>, <arg2>].
        Specified by:
        isRule in interface IExpr
        Returns:
      • isRuleAST

        public boolean isRuleAST()
        Test if this expression is of the form Rule[<arg1>, <arg2>] or RuleDelayed[<arg1>, <arg2>].
        Specified by:
        isRuleAST in interface IExpr
        Returns:
      • isRuleDelayed

        public boolean isRuleDelayed()
        Test if this expression is of the form RuleDelayed[<arg1>, <arg2>].
        Specified by:
        isRuleDelayed in interface IExpr
        Returns:
      • isSame

        public boolean isSame​(IExpr expression)
        Test if this expression equals the given expression. If the compared expressions are of the same numeric type, they are equal to Config.DOUBLE_TOLERANCE.
        Specified by:
        isSame in interface IExpr
        Returns:
      • isSame

        public boolean isSame​(IExpr expression,
                              double epsilon)
        Test if this expression equals the given expression. If the compared expressions are of the same numeric type, they are equal to a given EPSILON
        Specified by:
        isSame in interface IExpr
        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 as head
        Parameters:
        head - object to compare with element at location 0
        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 as head and if the size of the list equals length.
        Parameters:
        head - object to compare with element at location 0
        length -
        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 as head and if the size of the list is between minLength and maxLength .
        Parameters:
        head - object to compare with element at location 0
        minLength - minimum length of list elements.
        maxLength - maximum length of list elements.
        Returns:
      • isSequence

        public final boolean isSequence()
        Test if this expression is a sequence (i.e. an AST with head Sequence)
        Specified by:
        isSequence in interface IExpr
        Returns:
      • isSin

        public final boolean isSin()
        Test if this expression is the function Sin[<arg>]
        Specified by:
        isSin in interface IExpr
        Returns:
      • isSinh

        public final boolean isSinh()
        Test if this expression is the function Sinh[<arg>]
        Specified by:
        isSinh in interface IExpr
        Returns:
      • isSlot

        public final boolean isSlot()
        Test if this expression is the function Slot[<integer-value>] (i.e. #1, #2, #3,....)
        Specified by:
        isSlot in interface IExpr
        Returns:
      • intSlot

        public final IInteger intSlot()
        If this is a slot return the slot number, otherwise return F.CN1 (value -1)
        Specified by:
        intSlot in interface IExpr
        Returns:
      • isSlotSequence

        public final boolean isSlotSequence()
        Test if this expression is the function SlotSequence[<integer-value>]
        Specified by:
        isSlotSequence in interface IExpr
        Returns:
      • isSpan

        public final int[] isSpan​(int size)
        Test if this expression is the function Span[...] with 2 or 3 arguments.
        Specified by:
        isSpan in interface IExpr
        Parameters:
        size - the size of an AST for which Span[] should be applied.
        Returns:
        null if this is no Span[...] expression.
      • isSubscript

        public final boolean isSubscript()
        Test if this expression is the function Subscript[var, <integer-value>]. var has to be a variable.
        Specified by:
        isSubscript in interface IExpr
        Returns:
      • isTan

        public final boolean isTan()
        Test if this expression is the function Tan[<arg>]
        Specified by:
        isTan in interface IExpr
        Returns:
      • isTanh

        public final boolean isTanh()
        Test if this expression is the function Tanh[<arg>]
        Specified by:
        isTanh in interface IExpr
        Returns:
      • isTimes

        public boolean isTimes()
        Test if this expression is the multiplication function Times[<arg1>, <arg2>, ...] with at least 2 arguments.
        Specified by:
        isTimes in interface IAST
        Specified by:
        isTimes in interface IExpr
        Returns:
      • isTimes2

        public boolean isTimes2()
        Test if this expression is the S.Times function Times[<arg1>, <arg2>] with exactly 2 arguments.
        Specified by:
        isTimes2 in interface IExpr
        Returns:
      • isTimes3

        public boolean isTimes3()
        Test if this expression is the S.Times function Times[<arg1>, <arg2>, <arg3>] with exactly 3 arguments.
        Specified by:
        isTimes3 in interface IExpr
        Returns:
      • isTrigFunction

        public boolean isTrigFunction()
        Test if this expression is a trigonometric function.

        Note: ArcTan(x,y) can have 2 arguments and is considered as a trigonometric function. All other detected function types have 1 argument.

        Specified by:
        isTrigFunction in interface IExpr
        Returns:
      • isHyperbolicFunction

        public boolean isHyperbolicFunction()
        Test if this expression is a hyperbolic function.

        Note: All detected function types have 1 argument.

        Specified by:
        isHyperbolicFunction in interface IExpr
        Returns:
      • isPatternMatchingFunction

        public final boolean isPatternMatchingFunction()
        Description copied from interface: IAST
        Test if this expression is a special pattern-matching function (i.e. Alternatives, Except,...)
        Specified by:
        isPatternMatchingFunction in interface IAST
        Specified by:
        isPatternMatchingFunction in interface IExpr
        Returns:
      • isUnevaluated

        public final boolean isUnevaluated()
        Test if this expression is the function Unevaluated[<arg>]
        Specified by:
        isUnevaluated in interface IExpr
        Returns:
      • isUnit

        public boolean isUnit()
        Specified by:
        isUnit in interface IExpr
        Specified by:
        isUnit in interface edu.jas.structure.MonoidElem<IExpr>
      • isValue

        public final boolean isValue()
        Returns true, if this symbol or ast expression is bound to a value (i.e. the evaluation returns an assigned value).
        Specified by:
        isValue in interface IExpr
        Returns:
      • isVariable

        public final boolean isVariable​(boolean polynomialQTest)

        Test if this expression is a variable which doesn't has attribute ISymbol.CONSTANT.

        If polynomialQTest==true this method tests, as if function S.PolynomialQ for the polynomials variable was called, where especially IAST function expressions other than sums, products, and integer powers can be used as polynomial variables.

        Specified by:
        isVariable in interface IExpr
        Parameters:
        polynomialQTest - do a more relaxed variable test for S.PolynomialQ
        Returns:
        See Also:
        IExpr.isConstantAttribute(), IExpr.isSymbol()
      • isVector

        public int isVector()
        Test if this expression is a vector and return the length of the vector. This expression is only a vector, if the expression is a ASTRealVector or a List(...) and no element is itself a List(...) or a SparseArray(...) of dimension 1;
        Specified by:
        isVector in interface IExpr
        Returns:
        -1 if the expression is no vector or size()-1 of this vector AST.
      • isNumericAST

        public boolean isNumericAST()
        Test if this expression is an IAST and contains at least one numeric argument.
        Specified by:
        isNumericAST in interface IExpr
        Returns:
      • isWith

        public final boolean isWith()
        Test if this expression is the With function With[<arg1>, <arg2>]
        Specified by:
        isWith in interface IExpr
        Returns:
      • isPossibleZero

        public boolean isPossibleZero​(boolean fastTest)
        Test if this expression equals 0 in symbolic or numeric mode. For the numeric test multiple random numbers with a Chop() function test are used.
        Specified by:
        isPossibleZero in interface IExpr
        Parameters:
        fastTest - checks only numerical; no symbolic tests are tried.
        Returns:
      • iterator

        public final Iterator<IExpr> iterator()
        Returns an iterator over the elements in this IAST starting with offset 1.
        Specified by:
        iterator in interface IAST
        Specified by:
        iterator in interface Iterable<IExpr>
        Returns:
        an iterator over this IASTs argument values from 1..(size-1).
      • last

        public IExpr last()
        Get the last element of the AST list (i.e. get(size()-1). Return F.NIL if this object isn't an AST or has 0 arguments (i.e. only a header element)
        Specified by:
        last in interface IExpr
        Returns:
        the last argument of the function represented by this AST or F.NIL
        See Also:
        IExpr.head()
      • lastIndexOf

        public final int lastIndexOf​(IExpr object)
        Specified by:
        lastIndexOf in interface IAST
      • leafCount

        public final long leafCount()
        Count the number of indivisible subexpressions (atoms/leaves) of this expression.
        Specified by:
        leafCount in interface IExpr
        Returns:
      • leafCountSimplify

        public long leafCountSimplify()
        Count the number of leaves of this expression; for integer numbers in exact integer, fractional and complex numbers count the digits of the integers. This function is used in Simplify as the default "complexity function". Note:: S.Indeterminate returns value Long.MAX_VALUE

        use IExpr.isZero() instead.

        Specified by:
        leafCountSimplify in interface IExpr
        Returns:
      • linear

        public IExpr[] linear​(IExpr variable)
        Description copied from interface: IExpr
        If this is a linear expression a + b * x return the addend a at index 0 and the multiplicant b at index 1
        Specified by:
        linear in interface IExpr
        Parameters:
        variable - the variable x to check for linearity
        Returns:
        null if this is not a linear expression
      • linearPower

        public IExpr[] linearPower​(IExpr variable)
        Description copied from interface: IExpr
        If this is an expression of the form a + b * x^n with n integer, return the addend at index 0 and the multiplicant at index 1 and the exponent n at index 2.
        Specified by:
        linearPower in interface IExpr
        Parameters:
        variable - the variable x in the formula
        Returns:
        null if this is not an expression of the form a+b*x^n
      • lower

        public IExpr lower()
        If this is a Interval[{lower, upper}] expression return the lower value. If this is a IReal expression return this.
        Specified by:
        lower in interface IExpr
        Returns:
        F.NIL if this expression is no interval and no signed number.
      • getArg

        public IExpr getArg​(int position,
                            IExpr defaultValue)
        Return this.get(position) if argSize() >= position, otherwise return defaultValue
        Specified by:
        getArg in interface IExpr
        Returns:
        this.get(position) if argSize() >= position, otherwise return defaultValue
      • makeList

        public IAST makeList()
        Return this if isList()==true, otherwise create a new list {this} from this (i.e. return F.List(this)).
        Specified by:
        makeList in interface IExpr
        Returns:
        this if isList()==true, otherwise return F.List(this) .
      • makeAST

        public IAST makeAST​(IExpr head)
        Description copied from interface: IExpr
        Return this if isAST(head)==true, otherwise create a new list {this} from this (i.e. return F.unaryAST1(head, this)).
        Specified by:
        makeAST in interface IExpr
        Returns:
        this if isAST(head)==true, otherwise return F.unaryAST1(head, this) .
      • map

        public IAST map​(Function<IExpr,​? extends IExpr> function)
        Maps the elements of this IAST with the unary functor. If the functor returns F.NIL the original element of this AST list is used.

        Example for mapping with Functors#replace1st(), where the first argument will be replaced by the current argument of this AST:
         plusAST.map(Functors.replace1st(F.D(null, dAST.arg2())));
         
        Specified by:
        map in interface IAST
        Parameters:
        function - a unary function
        Returns:
      • map

        public IAST map​(Function<IExpr,​? extends IExpr> function,
                        int startOffset)
        Maps the elements of this IAST with the unary functor. If the functor returns F.NIL the original element of this AST list is used.

        Example for mapping with Functors#replace1st(), where the first argument will be replaced by the current argument of this AST:
         plusAST.map(Functors.replace1st(F.D(null, dAST.arg2())));
         
        Specified by:
        map in interface IAST
        Parameters:
        function - a unary function
        startOffset - the startOffset from there the functor should be used.
        Returns:
      • mapLeaf

        public IAST mapLeaf​(IExpr testHead,
                            Function<IExpr,​IExpr> function,
                            int startOffset)
        Maps the leafs (relative to testHead) of this IAST with the unary functor. If the function returns F.NIL the original leaf of the result list is used.
        Specified by:
        mapLeaf in interface IAST
        Parameters:
        testHead - if the levels head equals testHead apply mapLeaf on this list element
        function - functor a unary function
        startOffset - the startOffset from there the functor should be used.
        Returns:
      • mapReverse

        public IAST mapReverse​(Function<IExpr,​IExpr> function)
        Description copied from interface: IAST
        Maps the elements of this IAST in the reversed order with the unary functor. If the functor returns F.NIL the original element of this AST list is set at the reversed position.
        Specified by:
        mapReverse in interface IAST
        Parameters:
        function - a unary function
        Returns:
        the reversed list mapped with the function
      • map

        public final IAST map​(IASTAppendable resultAST,
                              IAST secondAST,
                              BiFunction<IExpr,​IExpr,​IExpr> function)
        Maps the elements of this IAST with the elements of the secondAST.
        Specified by:
        map in interface IAST
        function - a binary function
        Returns:
        the given resultAST.
      • map

        public IAST map​(IASTMutable clonedResultAST,
                        Function<IExpr,​IExpr> function)
        Maps the elements of this IAST with the unary functor. If the function returns F.NIL the original element of the result list is used.
        Specified by:
        map in interface IAST
        Parameters:
        clonedResultAST - a list which is cloned from this list or greater or equal in size of this list.
        function - a unary function
        Returns:
      • map

        public final IAST map​(IExpr head,
                              Function<IExpr,​IExpr> function)
        Maps the elements of this IAST with the unary functor. If the function returns null the original element of the result list is used.
        Specified by:
        map in interface IAST
        Parameters:
        head - the new head element of the result list
        function - a unary function
        Returns:
      • mapLeft

        public IAST mapLeft​(IASTAppendable list,
                            BiFunction<IExpr,​IExpr,​IExpr> binaryFunction,
                            IExpr leftArg)
        Append the mapped ranges elements directly to the given list
        Specified by:
        mapLeft in interface IAST
        binaryFunction - binary function
        leftArg - left argument of the binary functions apply() method.
        Returns:
        F.NIL if binaryFunction returns F.NIL
      • mapMatrixColumns

        public IExpr mapMatrixColumns​(int[] dim,
                                      Function<IExpr,​IExpr> f)
        This method assumes that this is a list of list in matrix form. It combines the column values in a list as argument for the given function. Example a matrix {{x1, y1,...}, {x2, y2, ...}, ...} will be converted to {f.apply({x1, x2,...}), f.apply({y1, y2, ...}), ...}
        Specified by:
        mapMatrixColumns in interface IAST
        Specified by:
        mapMatrixColumns in interface IExpr
        Parameters:
        dim - the dimension of the matrix
        f - a unary function
        Returns:
      • mapRight

        public IAST mapRight​(IASTAppendable list,
                             BiFunction<IExpr,​IExpr,​IExpr> binaryFunction,
                             IExpr rightArg)
        Append the mapped ranges elements directly to the given list
        Specified by:
        mapRight in interface IAST
        binaryFunction - a binary function
        rightArg - right argument of the binary functions apply() method.
        Returns:
        F.NIL if binaryFunction returns F.NIL
      • mapThread

        public IASTMutable mapThread​(IAST replacement,
                                     int position)

        If this is an IAST:

        Maps the elements of this IAST on the first level of arguments with the code replacement.setAtCopy(position, this), there replacement is an IAST at which the argument at the given position will be replaced by the currently mapped element. This can be used to create an effect as if "the position-th argument of an IAST object would be Listable".

        If this is an IExpr:

        Return replacement.setAtCopy(position, this)

        Example for mapping, where the argument at the given position will be replaced by the current argument of this AST:

         plusAST.mapThread(F.D(F.Slot1, F.x), 1);
         
        Specified by:
        mapThread in interface IAST
        Specified by:
        mapThread in interface IExpr
        Parameters:
        replacement - an IAST there the argument at the given position is replaced by the currently mapped argument of this IAST.
        position - the position in replacement which should be replaced by the corresponding argument of this IAST
        Returns:
        See Also:
        IAST.map(Function, int)
      • mapThreadEvaled

        public final IASTMutable mapThreadEvaled​(EvalEngine engine,
                                                 IAST replacement,
                                                 int position)
        Maps the elements of this IAST on the first level of arguments with the evaluated unary functor Functors.replaceArg(replacement, position), there replacement is an IAST at which the argument at the given position will be replaced by the currently mapped element. This can be used to create an effect as if "the position -th argument of an IAST object would be Listable".

        Example for mapping with Functors#replaceArg(), where the argument at the given position will be replaced by the current argument of this AST:

         plusAST.mapThreadEvaled(engine, F.D(F.Slot1, F.x), 1);
         
        Specified by:
        mapThreadEvaled in interface IAST
        replacement - an IAST there the argument at the given position is replaced by the currently mapped argument of this IAST.
        position - the position in replacement which should be replaced by the corresponding argument of this IAST
        Returns:
        See Also:
        IAST.map(Function, int)
      • mapThread

        public final IASTMutable mapThread​(Function<IExpr,​IExpr> function)
        Maps the elements of this IAST on the first level of arguments with the unary function.
        Specified by:
        mapThread in interface IAST
        Parameters:
        function - a unary function which maps each argument
        Returns:
      • mapThread

        public final IASTMutable mapThread​(IAST that,
                                           BiFunction<IExpr,​IExpr,​IExpr> function)
        Maps the elements of this IAST and of that IAST on the first level of arguments with the binary function. The size of the result is the minimum size of this and that.
        Specified by:
        mapThread in interface IAST
        function - a unary function which maps each argument of this IAST and that
        Returns:
        the size of the result is the minimum size of this and that.
      • mapThreadEvaled

        public IASTAppendable mapThreadEvaled​(EvalEngine engine,
                                              IASTAppendable appendAST,
                                              IAST replacement,
                                              int position)
        Maps the elements of this IAST with the unary functor Functors.replaceArg(replacement, position), there replacement is an IAST at which the argument at the given position will be replaced by the currently mapped element and appends the element to appendAST.
        Specified by:
        mapThreadEvaled in interface IAST
        Parameters:
        engine - TODO
        replacement - an IAST there the argument at the given position is replaced by the currently mapped argument of this IAST.
        Returns:
        appendAST
        See Also:
        IAST.map(Function, int)
      • negative

        public final IExpr negative()
        Additional negative method, which works like opposite to fulfill groovy's method signature
        Specified by:
        negative in interface IExpr
        Returns:
        See Also:
        IExpr.opposite()
      • normal

        public IExpr normal​(boolean nilIfUnevaluated)
        Converts a special expression (like a series, association, dataset, sparse array, ...) into a standard normalized expression.
         >> Normal(SeriesData(x, 0, {1, 0, -1, -4, -17, -88, -549}, -1, 6, 1))
         1/x-x-4*x^2-17*x^3-88*x^4-549*x^5
         
        Specified by:
        normal in interface IExpr
        Parameters:
        nilIfUnevaluated - if true return F.NIL, if no evaluation is necessary, otherwise this.
        Returns:
        the standard expression for special expression or F.NIL otherwise
      • oneIdentity

        public IExpr oneIdentity​(IExpr defaultValue)
        Return the argument at index 1, if the argSize() == 1. Or return the complete ast if the argSize() > 1 If the argSize() == 0 return defaultValue (useful for ASTs with attribute OneIdentity for example for Plus[] you can call getOneIdentity(F.C0) or for Times[]) you can call getOneIdentity(F.C1).
        Specified by:
        oneIdentity in interface IAST
        Parameters:
        defaultValue - default value, if size() < 2.
        Returns:
      • opposite

        public IExpr opposite()
        Returns an IExpr whose value is (-1) * this. Calculates F.eval(F.Times(F.CN1, this)) in the common case and uses a specialized implementation for derived number classes.
        Specified by:
        opposite in interface IExpr
        Returns:
        See Also:
        IExpr.negative()
      • optional

        public IExpr optional()
        Description copied from interface: IExpr
        The F.NIL#optional() method always returns that. All other objects which implement this method returns that if that!=null or this if that==null
        Specified by:
        optional in interface IExpr
        Returns:
        that if that!=null or this in all other cases.
        See Also:
        NILPointer#optional(IExpr)
      • orElse

        public IAST orElse​(IAST other)
        Description copied from interface: IAST
        Return this if this unequals F.NIL , otherwise return other.
        Specified by:
        orElse in interface IAST
        Returns:
        this if this unequals F.NIL, otherwise return other.
        See Also:
        Optional.orElse(Object)
      • partition

        public final IAST partition​(ISymbol operator,
                                    Predicate<? super IExpr> predicate,
                                    IExpr init1,
                                    IExpr init2,
                                    ISymbol combiner,
                                    ISymbol action)
        Select all elements by applying the predicate to each argument in this AST and append the arguments which satisfy the predicate to the 1st element of the resulting AST, or otherwise append it to the 2nd element of the resulting AST.

        See: Fateman - Partitioning of Algebraic Subexpressions in Computer Algebra Systems

        Specified by:
        partition in interface IExpr
        Parameters:
        operator - the if the head of this expression equals operator, otherwise return F.NIL.
        predicate - the predicate which filters each element in this AST
        init1 - the result for the 1st result element, if the predicate doesn't give true for any of the arguments in this AST.
        init2 - the result for the 2nd result element, if the predicate doesn't give false for any of the arguments in this AST.
        combiner - the 1st and 2md results element head
        Returns:
        F.NIL if partitioning wasn't possible
      • partitionPlus

        public final IAST partitionPlus​(Predicate<? super IExpr> predicate,
                                        IExpr initYes,
                                        IExpr initNo,
                                        ISymbol action)
        Description copied from interface: IExpr
        Select all elements by applying the predicate to each argument in this Plus(...) expression and append the arguments which satisfy the predicate to the 1st element of the resulting AST, or otherwise append it to the 2nd element of the resulting AST.

        See: Fateman - Partitioning of Algebraic Subexpressions in Computer Algebra Systems

        Specified by:
        partitionPlus in interface IExpr
        Parameters:
        predicate - the predicate which filters each element in this AST
        initYes - the result for the 1st result element, if the predicate doesn't give true for any of the arguments in this AST.
        initNo - the result for the 2nd result element, if the predicate doesn't give false for any of the arguments in this AST.
        Returns:
        F.NIL if partitioning wasn't possible
      • partitionTimes

        public final IAST partitionTimes​(Predicate<? super IExpr> predicate,
                                         IExpr initYes,
                                         IExpr initNo,
                                         ISymbol action)
        Description copied from interface: IExpr
        Select all elements by applying the predicate to each argument in this Times(...) expression and append the arguments which satisfy the predicate to the 1st element of the resulting AST, or otherwise append it to the 2nd element of the resulting AST.

        See: Fateman - Partitioning of Algebraic Subexpressions in Computer Algebra Systems

        Specified by:
        partitionTimes in interface IExpr
        Parameters:
        predicate - the predicate which filters each element in this AST
        initYes - the result for the 1st result element, if the predicate doesn't give true for any of the arguments in this AST.
        initNo - the result for the 2nd result element, if the predicate doesn't give false for any of the arguments in this AST.
        Returns:
        F.NIL if partitioning wasn't possible
      • patternHashCode

        public final int patternHashCode()
        Calculate a special hash value to find a matching rule in a hash table
        Specified by:
        patternHashCode in interface IAST
        Returns:
      • prependClone

        public final IASTAppendable prependClone​(IExpr expr)
        Prepend an expression to this list.
        Specified by:
        prependClone in interface IAST
        Returns:
        this after prepending the given expression.
      • putProperty

        public Object putProperty​(IAST.PROPERTY key,
                                  Object value)
        Associates the specified value with the specified property in the associated EnumMap<PROPERTY, Object> map. If the map previously contained a mapping for this key, the old value is replaced.
        Parameters:
        key -
        value -
        Returns:
        See Also:
        getProperty(PROPERTY)
      • remove

        public IASTAppendable remove​(Predicate<? super IExpr> predicate)
        Removes all objects which satisfy the given predicate.
        Specified by:
        remove in interface IAST
        Returns:
        F.NIL if no element could be removed
      • removeAtClone

        public final IASTAppendable removeAtClone​(int position)
        Create a shallow copy of this IAST instance (the elements themselves are not copied) and remove the element at the given position.
        Specified by:
        removeAtClone in interface IAST
        Returns:
        a clone with removed element at the given position.
      • splice

        public IAST splice​(int index,
                           int howMany,
                           IExpr... items)
        The splice() method adds/removes items to/from an AST copy, and returns the copy.
        Specified by:
        splice in interface IAST
        Parameters:
        index - An integer that specifies at what position to add/remove items.
        howMany - The number of items to be removed. If set to 0, no items will be removed
        items - Optional. The new item(s) to be added to the AST copy
        Returns:
        an IAST with removed element at the given position.
      • removeAtCopy

        public IASTMutable removeAtCopy​(int position)
        Create a shallow copy of this IAST instance (the elements themselves are not copied) and remove the element at the given position.
        Specified by:
        removeAtCopy in interface IAST
        Returns:
        an IAST with removed element at the given position.
      • removePositionsAtCopy

        public IASTAppendable removePositionsAtCopy​(int[] removedPositions,
                                                    int untilIndex)
        Create a shallow copy of this IAST instance (the elements themselves are not copied) and remove the elements defined in the given removedPositionsArray up to untilIndex (exclusive).
        Specified by:
        removePositionsAtCopy in interface IAST
        untilIndex - up to this position (exclusive) the elements will be removed from the copy
        Returns:
        an IAST with removed element at the given position.
      • rewrite

        public IExpr rewrite​(int functionID)
        Specified by:
        rewrite in interface IExpr
      • rotateLeft

        public IAST rotateLeft​(IASTAppendable resultList,
                               int n)
        Rotate the ranges elements to the left by n places and append the resulting elements to the list
        Specified by:
        rotateLeft in interface IAST
        Parameters:
        resultList -
        n -
        Returns:
        the given list
      • rotateRight

        public IAST rotateRight​(IASTAppendable resultList,
                                int n)
        Rotate the ranges elements to the right by n places and append the resulting elements to the list
        Specified by:
        rotateRight in interface IAST
        Parameters:
        resultList -
        n -
        Returns:
        the given list
      • setAtClone

        public IASTAppendable setAtClone​(int position,
                                         IExpr expr)
        Create a shallow copy of this IAST instance (the elements themselves are not copied) and set the expr at the given position.
        Specified by:
        setAtClone in interface IAST
        Returns:
        a clone with element set to expr at the given position.
      • setEvalFlags

        public final void setEvalFlags​(int i)
        Set the evaluation flags for this list (i.e. replace all existing flags).
        Specified by:
        setEvalFlags in interface IAST
      • signum

        @Deprecated
        public final int signum()
        Deprecated.
        Signum functionality is used in JAS toString() method, don't use it as math signum function.
        Specified by:
        signum in interface edu.jas.structure.AbelianGroupElem<IExpr>
        Specified by:
        signum in interface IExpr
      • sortInplace

        public void sortInplace​(Comparator<IExpr> comparator)
        Description copied from interface: IASTMutable
        Sort this in place using function comparator#compare(a, b). Example: suppose the Symbol f has the attribute ISymbol.ORDERLESS f(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 interface IASTMutable
        Parameters:
        comparator - the comparator used for sorting inplace.
      • stream

        public Stream<IExpr> stream()
        Description copied from interface: IAST
        Returns a sequential Stream which starts at index 1of the specified array as its source.
        Specified by:
        stream in interface IAST
        Returns:
        a Stream for the internal array range
      • stream

        public Stream<IExpr> stream​(int startInclusive,
                                    int endExclusive)
        Description copied from interface: IAST
        Returns a sequential Stream with the specified range of the specified array as its source.
        Specified by:
        stream in interface IAST
        Parameters:
        startInclusive - the first index to cover, inclusive
        endExclusive - index immediately past the last index to cover
        Returns:
        a Stream for the internal array range
      • timesDistributed

        public final IExpr timesDistributed​(IExpr that)
        Description copied from interface: IExpr
        Returns an IExpr whose value is (this * that). Calculates F.eval(F.Times(this, that)) in the common case and uses a specialized implementation for derived number classes.
        Specified by:
        timesDistributed in interface IExpr
        Parameters:
        that - the multiplier expression
        Returns:
        (this * that)
      • toDoubleMatrix

        public double[][] toDoubleMatrix()
        Convert this object into a double[][] matrix.
        Specified by:
        toDoubleMatrix in interface IExpr
        Returns:
        null if this object can not be converted into a double[] matrix
      • toBooleanVector

        public boolean[] toBooleanVector()
        Description copied from interface: IExpr
        Convert this IAST to a boolean vector. The elements of this IAST can be True and False.
        Specified by:
        toBooleanVector in interface IExpr
        Returns:
      • toBooleValueVector

        public boolean[] toBooleValueVector()
        Description copied from interface: IExpr
        Convert this IAST to a boolean vector. The elements of this IAST can be 1 (for true) and 0 (for false).
        Specified by:
        toBooleValueVector in interface IExpr
        Returns:
      • toBooleanMatrix

        public boolean[][] toBooleanMatrix()
        Specified by:
        toBooleanMatrix in interface IExpr
      • toByteMatrix

        public byte[][] toByteMatrix()
        Description copied from interface: IExpr
        Convert this object into a byte[][] matrix.
        Specified by:
        toByteMatrix in interface IExpr
        Returns:
        null if this object can not be converted into a byte[][] matrix
      • toIntMatrix

        public int[][] toIntMatrix()
        Description copied from interface: IExpr
        Convert this object into a byte[][] matrix.
        Specified by:
        toIntMatrix in interface IExpr
        Returns:
        null if this object can not be converted into a byte[][] matrix
      • toDoubleMatrixIgnore

        public double[][] toDoubleMatrixIgnore()
        Convert this object into a double[] matrix, if a row is not convertible to double vector ignore the row.
        Specified by:
        toDoubleMatrixIgnore in interface IExpr
        Returns:
        null if this object can not be converted into a double[] matrix
      • toDoubleVector

        public double[] toDoubleVector()
        Convert this object into a double[] vector.
        Specified by:
        toDoubleVector in interface IExpr
        Returns:
        null if this object can not be converted into a double[] vector
      • toDoubleVectorIgnore

        public double[] toDoubleVectorIgnore()
        Convert this object into a double[] vector, if an argument is not convertible to double ignore the value.
        Specified by:
        toDoubleVectorIgnore in interface IExpr
        Returns:
        null if this object can not be converted into a double[] vector
      • toComplexVector

        public org.hipparchus.complex.Complex[] toComplexVector()
        Convert this object into a Complex[] vector.
        Specified by:
        toComplexVector in interface IExpr
        Returns:
        null if this object can not be converted into a Complex[] vector
      • toComplexMatrix

        public org.hipparchus.complex.Complex[][] toComplexMatrix()
        Specified by:
        toComplexMatrix in interface IExpr
      • toIntVector

        public int[] toIntVector()
        Convert this object into a int[] vector.
        Specified by:
        toIntVector in interface IExpr
        Returns:
        null if the conversion is not possible
      • topHead

        public ISymbol topHead()
        Returns the ISymbol of the IAST. If the head itself is a IAST it will recursively call head().
        Specified by:
        topHead in interface IAST
        Specified by:
        topHead in interface IExpr
        Returns:
        the 'highest level' head of the expression.
      • toRealMatrixIgnore

        public org.hipparchus.linear.RealMatrix toRealMatrixIgnore()
        Convert this object into a RealMatrix.
        Specified by:
        toRealMatrixIgnore in interface IExpr
        Returns:
        null if this object can not be converted into a RealMatrix
      • upper

        public IExpr upper()
        If this is a Interval({lower, upper}) expression return the upper value. If this is a IReal expression return this.
        Specified by:
        upper in interface IExpr
        Returns:
        F.NIL if this expression is no interval and no signed number.
      • variables2Slots

        public final IExpr variables2Slots​(Map<IExpr,​IExpr> map,
                                           Collection<IExpr> variableCollector)
        Convert the variables (i.e. expressions of type ISymbol which aren't constants) in this expression into Slot[] s.
        Specified by:
        variables2Slots in interface IExpr
        Parameters:
        map - for every given symbol argument return the associated unique slot from this map
        variableCollector - collects the variables which are used in the replacement process
        Returns:
        F.NIL if no variable symbol was found.
      • extractConditionalExpression

        public IExpr extractConditionalExpression​(boolean isUnaryConditionalExpression)
        Extract ConditionalExpression from the arguments of this expression. See ConditionalExpression
        Specified by:
        extractConditionalExpression in interface IAST
        Parameters:
        isUnaryConditionalExpression - if true this is of the form head( ConditionalExpression(expr, condition) )
        Returns: