Exemple #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);
        }
Exemple #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());
        }
Exemple #3
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public MainWindow()
        {
            GrobnerPolynome g = new GrobnerPolynome(7);

            MessageBox.Show(g.PolynomeAsFunction.ToString());
            MessageBox.Show(g.GetBaseY(4242432).ToString());
            MessageBox.Show(g.GetBaseX(3).ToString());
            string res = string.Empty;

            foreach (uint s in g.TrianglePascal(10))
            {
                res += s.ToString() + " ";
            }
            MessageBox.Show(res);
            MessageBox.Show(g.BinomialLaw(3, "U", "v").ToString());
            res = string.Empty;
            foreach (IArithmetic a in g.PolynomeAsFunction.Select(("X").ToArithmetic()))
            {
                res += a.ToString() + " ";
            }
            MessageBox.Show(res);
            InitializeComponent();
        }