Exemplo n.º 1
0
        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
                                ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            int[]         cols = param.GetParam <int[]>("Columns").Value;
            HashSet <int> w    = ArrayUtils.ToHashSet(param.GetParam <int[]>("Calculate").Value);

            bool[]     include = new bool[SummaryStatisticsRows.procs.Length];
            double[][] rowws   = new double[SummaryStatisticsRows.procs.Length][];
            for (int i = 0; i < include.Length; i++)
            {
                include[i] = w.Contains(i);
                if (include[i])
                {
                    rowws[i] = new double[cols.Length];
                }
            }
            for (int i = 0; i < cols.Length; i++)
            {
                double[] vals = GetColumn(cols[i], mdata);
                for (int j = 0; j < include.Length; j++)
                {
                    if (include[j])
                    {
                        rowws[j][i] = SummaryStatisticsRows.procs[j].Item2(vals);
                    }
                }
            }
            List <double[]> ex    = new List <double[]>();
            List <string>   names = new List <string>();

            for (int i = 0; i < include.Length; i++)
            {
                if (include[i])
                {
                    ex.Add(rowws[i]);
                    names.Add(SummaryStatisticsRows.procs[i].Item1);
                }
            }
            float[,] exVals = GetExVals(ex);
            string[] colNames = GetColNames(mdata, cols);
            mdata.Name               = "Summary";
            mdata.ColumnNames        = new List <string>(names.ToArray());
            mdata.ColumnDescriptions = new List <string>(names.ToArray());
            mdata.Values.Set(exVals);
            mdata.SetAnnotationColumns(new List <string>(new[] { "Columns" }), new List <string[]>(new[] { colNames }),
                                       mdata.CategoryRowNames, TransformCategories(mdata, cols, mdata.ColumnCount), mdata.NumericRowNames,
                                       TransformNumeric(mdata.NumericRows, cols, mdata.ColumnCount), new List <string>(), new List <double[][]>());
            mdata.ClearAnnotationRows();
        }