コード例 #1
0
        /// <summary>
        /// Calculate function value
        /// given each values with each name of terms
        /// to evaluate
        /// </summary>
        /// <param name="values">values to set each terms</param>
        /// <returns>a double value as the calculation result</returns>
        protected double Calculate(IEnumerable <double> values)
        {
            int index = 0;

            foreach (string u in this.nameTerms)
            {
                if (index < values.Count())
                {
                    this.function.Let(u, values.ElementAt(index));
                    ++index;
                }
                else
                {
                    break;
                }
            }
            Interfaces.IArithmetic fd = this.function.Compute();
            if (fd is NumericValue)
            {
                return(Convert.ToDouble(fd));
            }
            else
            {
                // un ou plusieurs termes n'ont pas de valeur
                throw new KeyNotFoundException();
            }
        }
コード例 #2
0
        /// <summary>
        /// Add a new coordinate into this system
        /// </summary>
        /// <param name="f">function</param>
        /// <param name="nameTerms">terms identified by name and ordered as same to coords</param>
        /// <param name="coords">coordinate</param>
        public void Add(Arithmetic f, IEnumerable <string> nameTerms, params double[] coords)
        {
            int index = 0;

            foreach (string u in nameTerms)
            {
                if (index < coords.Count())
                {
                    f.Let(u, coords.ElementAt(index));
                    ++index;
                }
                else
                {
                    break;
                }
            }
            Interfaces.IArithmetic fd = f.Compute();
            if (f is NumericValue)
            {
                List <double> c = new List <double>(coords);
                c.Add(Convert.ToDouble(f));
                Coordinates src = new Coordinates(c);
                src = this.move.Floor(src);
                this.Add(src);
            }
            else
            {
                // un ou plusieurs termes n'ont pas de valeur
                throw new KeyNotFoundException();
            }
        }
コード例 #3
0
 /// <summary>
 /// Test if a is a double value
 /// </summary>
 /// <param name="a">arithmetic class</param>
 /// <returns>true if it is a double</returns>
 public static bool IsDouble(this Interfaces.IArithmetic a)
 {
     return(a is NumericValue);
 }