示例#1
0
        /// <summary>
        /// Calculates synchronized selection
        /// </summary>
        /// <param name="selection">The etalon selection</param>
        /// <returns>Synchronized selection</returns>
        public IArgumentSelection SynchronizedSelection(IArgumentSelection selection)
        {
            if (!(selection is SeriesBase))
            {
                throw new Exception("Incompatible selections");
            }
            SeriesBase etalon = selection as SeriesBase;
            SeriesBase s      = new SeriesBase();

            for (int i = 0; i < etalon.PointsCount; i++)
            {
                double x = etalon[i, 0];
                double a = this[0, 0];
                if (x < a)
                {
                    s.AddXY(x, this[0, 1]);
                    continue;
                }
                double b = this[PointsCount - 1, 0];
                if (x > b)
                {
                    s.AddXY(x, this[PointsCount - 1, 1]);
                    continue;
                }
                s.AddXY(x, this[x][1]);
            }
            return(s);
        }
示例#2
0
 /// <summary>
 /// Adds seletion
 /// </summary>
 /// <param name="sel">Selection to add</param>
 public void AddSelection(IArgumentSelection sel)
 {
     if (selections.Count == 0)
     {
         selections.Add(sel);
         etalons.Add(sel);
         dim += sel.VectorDimension;
         return;
     }
     string[] variables = first.Variables;
     string[] var       = sel.Variables;
     if (var.Length != variables.Length)
     {
         throw new Exception("Illegal number of variables");
     }
     foreach (string s in var)
     {
         foreach (string s1 in variables)
         {
             if (s.Equals(s1))
             {
                 goto m1;
             }
         }
         throw new Exception("Illegal variables");
         m1 : continue;
     }
     dim += sel.VectorDimension;
     etalons.Add(sel);
     selections.Add(sel.SynchronizedSelection(selections[0] as IArgumentSelection));
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="selection">Selection</param>
        /// <param name="formula">Formula</param>
        public FormulaStructuredCalculator(IArgumentSelection selection, VectorFormulaConsumer formula)
        {
            this.formula    = formula;
            this.selection  = selection;
            vectorDimension = selection.VectorDimension;
            measurements    = formula;
            if (vectorDimension != measurements.Count)
            {
                throw new Exception("Illegal dimension");
            }
            variables = selection.Variables;
            IList <string> l = formula.AliasNames;

            parameters = new ArrayList();
            foreach (string n in l)
            {
                parameters.Add(n);
            }
            foreach (string str in variables)
            {
                if (!parameters.Contains(str))
                {
                    throw new Exception("Illegal variable");
                }
                parameters.Remove(str);
            }
            parameters.Sort();
        }
示例#4
0
 /// <summary>
 /// Access to n - th element
 /// </summary>
 public double?this[int n]
 {
     get
     {
         int m = n / dim;
         int k = n - dim * m;
         IArgumentSelection s = selections[k] as IArgumentSelection;
         return(s[m]);
     }
 }
示例#5
0
        /// <summary>
        /// Calculates synchronized selection
        /// </summary>
        /// <param name="selection">The etalon selection</param>
        /// <returns>Synchronized selection</returns>
        public IArgumentSelection SynchronizedSelection(IArgumentSelection selection)
        {
            ArgumentMultiSelection sel = new ArgumentMultiSelection();

            for (int i = 0; i < selections.Count; i++)
            {
                IArgumentSelection s = selections[i] as IArgumentSelection;
                sel.AddSelection(s.SynchronizedSelection(selection));
            }
            return(sel);
        }
示例#6
0
        /// <summary>
        /// Removes selection
        /// </summary>
        /// <param name="sel">Selection to remove</param>
        public void RemoveSelection(IArgumentSelection sel)
        {
            int n = etalons.IndexOf(sel);

            if (n >= 0)
            {
                etalons.RemoveAt(n);
                selections.RemoveAt(n);
                dim -= sel.VectorDimension;
            }
        }