コード例 #1
0
ファイル: SubNode.cs プロジェクト: yangfan111/CsharpCode
        /// <summary>Subtracts the evaluation of the right side from the evaluation of the left side and returns the result.</summary>
        public override double Eval(VarMap v, FuncMap f)
        {
            double a = leftChild.Eval(v, f);
            double b = rightChild.Eval(v, f);

            return(a - b);
        }
コード例 #2
0
ファイル: PowNode.cs プロジェクト: yangfan111/CsharpCode
        /// <summary>Raises the evaluation of the left side to the power of the evaluation of the right side and returns the result.</summary>
        public override double Eval(VarMap v, FuncMap f)
        {
            double a = leftChild.Eval(v, f);
            double b = rightChild.Eval(v, f);

            return(MyMath.Pow(a, b));
        }
コード例 #3
0
        /// <summary>Returns the value associated with the variable name in the VarMap.</summary>
        public override double Eval(VarMap v, FuncMap f)
        {
            double val = v.GetValue(name);

            if (negate)
            {
                val = -val;
            }
            return(val);
        }
コード例 #4
0
ファイル: FuncNode.cs プロジェクト: yangfan111/CsharpCode
        /// <summary>Evaluates each of the children, storing the result in an internal double array.</summary>
        /// <remarks>
        /// Evaluates each of the children, storing the result in an internal double array.  The FuncMap is
        /// used to obtain a Function object based on the name of this FuncNode.  The function is passed
        /// the double array and returns a result.  If negate is true, the result is negated.  The result
        /// is then returned.  The numParam passed to the function is the number of children of this FuncNode.
        /// </remarks>
        public override double Eval(VarMap v, FuncMap f)
        {
            int numParam = bag.Size();

            for (int i = 0; i < numParam; i++)
            {
                of[i] = Child(i).Eval(v, f);
            }
            double result = f.GetFunction(name, numParam).Of(of, numParam);

            if (negate)
            {
                result = -result;
            }
            return(result);
        }
コード例 #5
0
 /// <summary>Returns the value.</summary>
 public override double Eval(VarMap v, FuncMap f)
 {
     return(val);
 }
コード例 #6
0
 /// <summary>Returns the result of evaluating the expression tree rooted at this node.</summary>
 public abstract double Eval(VarMap v, FuncMap f);