public void ReplaceWith(MathOperation l, MathOperation val, MathOperation r) { Value = val ; Left = new ExpressionTree(l); Right = new ExpressionTree(r); }
public void ReplaceWith(Number n) { Value = n; Right = null; Left = null; FunctionParameters = null; }
public void ReplaceWith(ExpressionTree tree) { Value = tree.Value; Right = tree.Right; Left = tree.Left; FunctionParameters = tree.FunctionParameters; }
public ExpressionTree(MathOperation l, MathOperation val, MathOperation r) { Value = val; Left = new ExpressionTree(l); Right = new ExpressionTree(r); }
private void UpdateExpressionTree() { m_ExpressionTree = new ExpressionTree(m_ExpressionStack.Pop()); m_ExpressionTree.BuildBinaryTree(m_ExpressionStack); m_ExpressionStack.ResetTop(); }
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 + ")'"); }