private static double Function_if(TreeNodeCollection Arguments, ArgumentsMap ArgsMap) { CheckArguments(Arguments, "if", 3); double condition = TreeNodeCalculator.Calculate(Arguments[0], ArgsMap); if (condition == 1) { return(TreeNodeCalculator.Calculate(Arguments[1], ArgsMap)); } return(TreeNodeCalculator.Calculate(Arguments[2], ArgsMap)); }
public double Calculate(params Argument[] Arguments) { ArgumentsMap arguments = new ArgumentsMap(); if (Arguments != null) { for (int i = 0; i < Arguments.Length; ++i) { Argument arg = Arguments[i]; arguments[arg.Name] = arg.Value; } } return(TreeNodeCalculator.Calculate(node, arguments)); }
private static double Function_abs(TreeNodeCollection Arguments, ArgumentsMap ArgsMap) { CheckArguments(Arguments, "abs", 1); return(Math.Abs(TreeNodeCalculator.Calculate(Arguments[0], ArgsMap))); }
private static double Function_log(TreeNodeCollection Arguments, ArgumentsMap ArgsMap) { CheckArguments(Arguments, "log", 1); return(Math.Log10(TreeNodeCalculator.Calculate(Arguments[0], ArgsMap))); }
private static double Function_random(TreeNodeCollection Arguments, ArgumentsMap ArgsMap) { CheckArguments(Arguments, "random", 2); return(TreeNodeCalculator.Calculate(Arguments[0], ArgsMap) + rnd.NextDouble() * (TreeNodeCalculator.Calculate(Arguments[1], ArgsMap) - TreeNodeCalculator.Calculate(Arguments[0], ArgsMap))); }
private static double Function_min(TreeNodeCollection Arguments, ArgumentsMap ArgsMap) { CheckArguments(Arguments, "min", 2); return(Math.Min(TreeNodeCalculator.Calculate(Arguments[0], ArgsMap), TreeNodeCalculator.Calculate(Arguments[1], ArgsMap))); }