Beispiel #1
0
 /// <summary>
 /// Constructor for a move with multi-dimensional array
 /// </summary>
 /// <param name="move">move</param>
 public MovingVector(MovingCoordinates move)
 {
     if (move.Steps.Dimension > 1)
     {
         this.dim    = Convert.ToUInt32(move.Steps.Dimension);
         this.values = new List <double>();
         double start = move.Vector.From.Value;
         double end   = move.Vector.To.Value;
         double step  = move.Steps.Value;
         for (double v = start; v < end; v += step)
         {
             this.values.Add(v);
         }
         MovingCoordinates nextMove = new MovingCoordinates(move.Vector.Euclidian, move.Steps.Euclidian);
         this.position = new MovingVector(nextMove);
     }
     else
     {
         this.dim    = 1;
         this.values = new List <double>();
         double start = move.Vector.From.Value;
         double end   = move.Vector.To.Value;
         double step  = move.Steps.Value;
         for (double v = start; v < end; v += step)
         {
             this.values.Add(v);
         }
         this.position = null;
     }
 }
Beispiel #2
0
        /// <summary>
        /// Iterate all elements and play each values
        /// </summary>
        protected void Iteration()
        {
            this.result = new MovingVector(1);
            List <uint> indexes = new List <uint>(Convert.ToInt32(this.move.Dimension));

            try
            {
                while (true)
                {
                    IEnumerable <double> values = this.Iteration(indexes, 0, this.move);
                    // la première valeur est l'index de recherche
                    double y = values.ElementAt(0);
                    // les autres valeurs sont calculées avec l'équation
                    double z = this.Calculate(values.Skip(1));
                    if (z < y)
                    {
                        // continue to play
                        this.result.Add(z);
                    }
                    else
                    {
                        this.result.Add(y);
                    }
                }
            }
            catch (IndexOutOfRangeException)
            {
            }
        }
Beispiel #3
0
 /// <summary>
 /// Constructor with a moving vector
 /// and an arithmetic function
 /// </summary>
 /// <param name="m">move</param>
 /// <param name="f">function</param>
 public Line(MovingVector m, Arithmetic f)
 {
     this.move      = m;
     this.function  = f;
     this.terms     = f.UnknownTerms.Values.Cast <UnknownTerm>().ToList();
     this.nameTerms = new List <string>(Convert.ToInt32(this.move.Dimension));
     this.result    = new MovingVector(1);
 }
 /// <summary>
 /// Set function(x) and rec(f)
 /// </summary>
 /// <param name="f">arithmetic function</param>
 /// <param name="inv">inverted</param>
 public void SetFunction(Arithmetic f, params Arithmetic[] inv)
 {
     this.function = f.Clone() as Arithmetic;
     this.inverted = new Arithmetic[inv.Length];
     for (int index = 0; index < inv.Length; ++index)
     {
         this.inverted[index] = inv[index].Clone() as Arithmetic;
     }
     this.points = this.bounds.GenerateMove();
 }
Beispiel #5
0
        /// <summary>
        /// Iteration get each values for each term
        /// use the first term to reach it by the computation of the function
        /// </summary>
        /// <param name="indexes">list of indexes position</param>
        /// <param name="depth">depth value</param>
        /// <param name="m">vector</param>
        /// <returns>values</returns>
        protected IEnumerable <double> Iteration(List <uint> indexes, uint depth, MovingVector m)
        {
            int iDepth = Convert.ToInt32(depth);

            if (m.Dimension > 1)
            {
                List <double> res = this.Iteration(indexes, depth + 1, m.Euclidian).ToList();
                if (indexes[iDepth] < m.Values.Count())
                {
                    double val = m.Values.ElementAt(Convert.ToInt32(indexes[iDepth]));
                    res.Add(val);
                }
                else
                {
                    for (int d = iDepth; d < indexes.Count; ++d)
                    {
                        indexes[d] = 0;
                    }
                    // incremente le précédent index
                    ++indexes[iDepth - 1];
                }
                return(res);
            }
            else
            {
                List <double> res = new List <double>();
                if (indexes[iDepth] < m.Values.Count())
                {
                    double val = m.Values.ElementAt(Convert.ToInt32(indexes[iDepth]));
                    res.Add(val);
                }
                else
                {
                    if (iDepth == 0)
                    {
                        // fin du processus d'iteration car fin du premier index atteint
                        throw new IndexOutOfRangeException();
                    }
                    else
                    {
                        // recommence le processus au coup suivant
                        indexes[iDepth] = 0;
                        // incrémente le précédent index
                        ++indexes[iDepth - 1];
                    }
                }
                return(res);
            }
        }
Beispiel #6
0
 /// <summary>
 /// Constructor for a coordinates
 /// given its dimension
 /// </summary>
 /// <param name="dimension">dimension</param>
 public MovingVector(uint dimension)
 {
     if (dimension > 1)
     {
         this.dim      = dimension;
         this.values   = new List <double>();
         this.position = new MovingVector(dimension - 1);
     }
     else
     {
         this.dim      = dimension;
         this.values   = new List <double>();
         this.position = null;
     }
 }
Beispiel #7
0
 /// <summary>
 /// Constructor with each value at each dimension
 /// </summary>
 /// <param name="positions">values</param>
 public MovingVector(IEnumerable <double> positions)
 {
     if (positions.Count() > 1)
     {
         this.dim    = Convert.ToUInt32(positions.Count());
         this.values = new List <double>();
         this.values.Add(positions.ElementAt(0));
         this.position = new MovingVector(positions.Skip(1));
     }
     else
     {
         this.dim    = 1;
         this.values = new List <double>();
         this.values.Add(positions.ElementAt(0));
         this.position = null;
     }
 }
Beispiel #8
0
 /// <summary>
 /// Constructor with each value at each dimension
 /// </summary>
 /// <param name="positions">values</param>
 public MovingVector(params double[] positions)
 {
     if (positions.Count() > 1)
     {
         this.dim    = Convert.ToUInt32(positions.Count());
         this.values = new List <double>();
         this.values.Add(positions[0]);
         this.position = new MovingVector(positions.Skip(1));
     }
     else
     {
         this.dim    = 1;
         this.values = new List <double>();
         this.values.Add(positions[0]);
         this.position = null;
     }
 }