コード例 #1
0
 public void ReplaceWith(MathOperation l, MathOperation val, MathOperation r)
 {
     Value = val ;
     Left = new ExpressionTree(l);
     Right = new ExpressionTree(r);
 }
コード例 #2
0
        public void ReplaceWith(Number n)
        {
            Value = n;
            Right = null;
            Left = null;

            FunctionParameters = null;
        }
コード例 #3
0
        public void ReplaceWith(ExpressionTree tree)
        {
            Value = tree.Value;
            Right = tree.Right;
            Left = tree.Left;

            FunctionParameters = tree.FunctionParameters;
        }
コード例 #4
0
 public ExpressionTree(MathOperation l, MathOperation val, MathOperation r)
 {
     Value = val;
     Left = new ExpressionTree(l);
     Right = new ExpressionTree(r);
 }
コード例 #5
0
 private void UpdateExpressionTree()
 {
     m_ExpressionTree = new ExpressionTree(m_ExpressionStack.Pop());
     m_ExpressionTree.BuildBinaryTree(m_ExpressionStack);
     m_ExpressionStack.ResetTop();
 }
コード例 #6
0
        public MathExpression Derive(MathState state)
        {
            StaticStack<MathOperation> stack = m_ExpressionStack;
            StaticStack<MathOperation> derived = new StaticStack<MathOperation>();
            ExpressionTree tree = new ExpressionTree(stack);
            tree.DeriveToStack(derived, state);

            Dictionary<string, float> var = new Dictionary<string, float>(m_Variables);

            for (int i = 0; i < derived.Count; i++)
            {
                if (derived[i] is Variable)
                {
                    Variable v = (Variable)derived[i];
                    derived[i] = new Variable(v.ToString(), var);
                }

            }
            return new MathExpression(derived,var, "(" + OriginalExpression + ")'");
        }