Пример #1
0
        public DataSerie1D Aggregate(int countStep)
        {
            DataSerie1D result_ds = null;

            if (countStep < 1)
            {
                return(null);
            }
            if (Equals(mData, null))
            {
                return(null);
            }
            if (Count < 1)
            {
                return(null);
            }

            result_ds = new DataSerie1D();
            int    count = Count;
            double summ  = 0;

            if (count <= countStep)
            {
                for (int i = 0; i < count; i++)
                {
                    summ += mData[i].X_Value;
                }
                result_ds.Add("1", summ);
            }
            else
            {
                summ = 0;
                int rest        = 0;
                int aggregCount = 1;

                for (int i = 0; i < count; i++)
                {
                    summ += mData[i].X_Value;

                    aggregCount = Math.DivRem((i + 1), countStep, out rest);

                    if (rest == 0)
                    {
                        result_ds.Add(aggregCount.ToString(), summ);
                        summ = 0;
                    }
                }

                summ        = 0;
                aggregCount = Math.DivRem(count, countStep, out rest);

                for (int i = (count - rest); i < count; i++)
                {
                    summ += mData[i].X_Value;
                }

                result_ds.Add((aggregCount + 1).ToString(), summ);
            }
            return(result_ds);
        }
Пример #2
0
        private static double[][] Convert(DataSerie1D ds1)
        {
            int iCount = ds1.Data.Count;

            double[][] result = new double[iCount][];

            for (int i = 0; i < iCount; i++)
            {
                result[i] = new double[] { ds1.Data[i].X_Value };
            }

            return(result);
        }
Пример #3
0
        public DataSerie1D ConvertToDS1()
        {
            if (object.Equals(mData, null))
            {
                return(null);
            }
            DataSerie1D ds1 = new DataSerie1D();

            foreach (DataItemTD itm in this.Data)
            {
                ds1.Add(itm.Title, itm.List[0]);
            }
            return(ds1);
        }
Пример #4
0
        public static DataSerie1D Convert(double[] source)
        {
            if (Equals(source, null))
            {
                return(null);
            }
            DataSerie1D result = new DataSerie1D();
            int         iCount = source.GetLength(0);

            if (iCount > 0)
            {
                for (int i = 0; i < iCount; i++)
                {
                    result.Add(i.ToString(), source[i]);
                }
            }
            return(result);
        }