Ejemplo n.º 1
0
        /// <summary>
        /// Gets Base X
        /// </summary>
        /// <param name="size">size of X</param>
        /// <returns>arithmetic function</returns>
        public IArithmetic GetBaseX(int size)
        {
            Base X = new Base(10, size);
            // creates a polynome for X
            GrobnerPolynome p = new GrobnerPolynome(X.Dimension - 1);
            IArithmetic     a = p.PolynomeAsBase("n", "B");

            return(a);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets Base Y
        /// </summary>
        /// <param name="y">y value</param>
        /// <returns>arithmetic function</returns>
        public IArithmetic GetBaseY(double y)
        {
            Base Y = new Base(10, Base.ConvertToReadable(y, 10));
            // creates a polynome for X
            GrobnerPolynome p = new GrobnerPolynome(Y.Dimension - 1);
            IArithmetic     a = p.PolynomeAsBase("p", "X");

            // gestion variables
            Dictionary <string, IArithmetic> variables = new Dictionary <string, IArithmetic>();

            Arithmetic.EventAddVariable += new EventHandler <KeyValuePair <string, IArithmetic> >((o, e) =>
            {
                if (e.Value != null)
                {
                    if (variables.ContainsKey(e.Key))
                    {
                        variables[e.Key] = e.Value;
                    }
                    else
                    {
                        variables.Add(e.Key, e.Value);
                    }
                }
                else
                {
                    if (variables.ContainsKey(e.Key))
                    {
                        variables.Remove(e.Key);
                    }
                }
            });
            Arithmetic.EventGetVariable = new Func <string, IArithmetic>((s) =>
            {
                if (variables.ContainsKey(s))
                {
                    return(variables[s]);
                }
                else
                {
                    return(null);
                }
            });


            for (int index = Y.Dimension - 1; index >= 0; --index)
            {
                a.Let("p_" + index.ToString(), Y.Vector.ElementAt(index));
            }
            a.Let("X", this.GetBaseX(3));

            return(a.Converting());
        }