Documentation of 'org.matheclipse.parser.client.eval.DoubleEvaluator' Java class
DoubleEvaluator
org.matheclipse.parser.client.eval

Class DoubleEvaluator

  • Direct Known Subclasses:
    EvalDouble


    public class DoubleEvaluator
    extends java.lang.Object
    Evaluate math expressions to double numbers.
    • Field Detail

      • EPSILON

        public static double EPSILON
    • Constructor Detail

      • DoubleEvaluator

        public DoubleEvaluator()
      • DoubleEvaluator

        public DoubleEvaluator(boolean relaxedSyntax)
      • DoubleEvaluator

        public DoubleEvaluator(ASTNode node,
                               boolean relaxedSyntax)
    • Method Detail

      • getCallbackFunction

        public IDoubleCallbackFunction getCallbackFunction()
        A callback function for unknown function names.
        Returns:
        the callback function
      • setCallbackFunction

        public void setCallbackFunction(IDoubleCallbackFunction callbackFunction)
        Set a callback function for unknown function names.
        Parameters:
        callbackFunction - the callback function to set
      • parse

        public ASTNode parse(java.lang.String expression)
        Parse the given expression String and store the resulting ASTNode in this DoubleEvaluator
        Parameters:
        expression -
        Returns:
        Throws:
        SyntaxError
      • parseNode

        public static ASTNode parseNode(java.lang.String expression,
                                        boolean relaxedSyntax)
        Parse the given expression String and return the resulting ASTNode
        Parameters:
        expression -
        Returns:
        Throws:
        SyntaxError
      • evaluate

        public double evaluate(java.lang.String expression)
        Parse the given expression String and evaluate it to a double value
        Parameters:
        expression -
        Returns:
        Throws:
        SyntaxError
      • evaluate

        public double evaluate()
        Reevaluate the expression (possibly after a new Variable assignment)
        Parameters:
        Expression -
        Returns:
        Throws:
        SyntaxError
      • evaluateNode

        public double evaluateNode(ASTNode node)
        Evaluate an already parsed in abstract syntax tree node into a double number value.
        Parameters:
        node - abstract syntax tree node
        Returns:
        the evaluated double number
        Throws:
        ArithmeticMathException - if the node cannot be evaluated.
      • evaluateFunction

        public double evaluateFunction(FunctionNode functionNode)
        Evaluate an already parsed in FunctionNode into a souble number value.
        Parameters:
        functionNode -
        Returns:
        Throws:
        ArithmeticMathException - if the functionNode cannot be evaluated.
      • isSymbol

        public boolean isSymbol(SymbolNode symbol1,
                                java.lang.String symbol2Name)
        Check if the given symbol is a SymbolNode and test if the names are equal.
        Parameters:
        symbol1 -
        symbol2Name -
        Returns:
      • isSymbol

        public boolean isSymbol(SymbolNode symbol1,
                                SymbolNode symbol2)
        Check if the given symbol is a SymbolNode and test if the names are equal.
        Parameters:
        symbol1 -
        symbol2 -
        Returns:
      • derivative

        public ASTNode derivative(ASTNode node,
                                  java.lang.String var)
        Parameters:
        node -
        var -
        Returns:
      • derivative

        public ASTNode derivative(ASTNode node,
                                  SymbolNode var)
        TODO: add more derivation rules
        Parameters:
        node -
        var -
        Returns:
      • evaluateNodeLogical

        public boolean evaluateNodeLogical(ASTNode node)
      • evaluateFunctionLogical

        public boolean evaluateFunctionLogical(FunctionNode functionNode)
      • optimizeFunction

        public ASTNode optimizeFunction(FunctionNode functionNode)
        Optimize an already parsed in functionNode into an ASTNode.
        Parameters:
        functionNode -
        Returns:
      • defineVariable

        public void defineVariable(java.lang.String variableName,
                                   double value)
        Define a value for a given variable name.
        Parameters:
        variableName -
        value -
      • defineVariable

        public void defineVariable(java.lang.String variableName,
                                   IDoubleValue value)
        Define a value for a given variable name.
        Parameters:
        variableName -
        value -
      • defineVariable

        public void defineVariable(java.lang.String variableName)
        Define a value for a given variable name.
        Parameters:
        variableName -
        value -
      • getVariable

        public IDoubleValue getVariable(java.lang.String variableName)
        Returns the double variable value to which the specified variableName is mapped, or null if this map contains no mapping for the variableName.
        Parameters:
        variableName -
        Returns:
      • defineVariable

        public void defineVariable(java.lang.String variableName,
                                   BooleanVariable value)
        Define a boolean value for a given variable name.
        Parameters:
        variableName -
        value -
      • clearVariables

        public void clearVariables()
        Clear all defined variables for this evaluator.
      • getVariables

        public void getVariables(java.lang.String expression,
                                 java.util.Set<java.lang.String> result)
        Get the variable names from the given expression.
        Parameters:
        expression -
        result - a set which contains the variable names
      • getVariables

        public static void getVariables(ASTNode node,
                                        java.util.Set<java.lang.String> result)
        Get the variable names from the given AST node.
        Parameters:
        node - an already parsed AST node
        result - a set which contains the variable names

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.