Ejemplo n.º 1
0
        public MathFunc(string str, string v = null, bool simplify = true, bool precompile = false)
        {
            List <MathFunc> mathFuncs = new MathExprConverter().Convert(str);
            MathFunc        first     = mathFuncs.FirstOrDefault();

            LeftNode  = first.LeftNode;
            RightNode = first.RightNode;
            Root      = RightNode;

            if (string.IsNullOrEmpty(v))
            {
                ConstToVars();
            }
            else
            {
                Variable = new VarNode(v);
                ConstToVar(Root);
            }

            FindParamsAndUnknownFuncs(Root);

            Root.Sort();
            if (simplify)
            {
                Root = Simplify(Root);
            }
            if (precompile)
            {
                Root = Precompile(null, Root);
            }
        }
Ejemplo n.º 2
0
        public static void InitDerivatives(string str)
        {
            List <MathFunc> mathFuncs = new MathExprConverter().Convert(str);

            Derivatives = new Dictionary <string, MathFunc>();

            foreach (var statement in mathFuncs)
            {
                string funcNodeName = statement.LeftNode.Children[0].Name;
                Derivatives.Add(funcNodeName, statement);
            }
        }
Ejemplo n.º 3
0
        public static void InitRools(string str)
        {
            List <MathFunc> mathFuncs = new MathExprConverter().Convert(str);

            Simplications = new List <MathFunc>();
            Permutations  = new List <MathFunc>();

            foreach (MathFunc statement in mathFuncs)
            {
                if (statement.RightNode.NodeCount < statement.LeftNode.NodeCount)
                {
                    Simplications.Add(statement);
                }
                else
                {
                    Permutations.Add(statement);
                }
            }
        }