public override GuideResultSet GetResult(params int[] inParams) { if (inParams.Length != 1) { return(null); } GuideResultSet ret = this.BaseSet.Copy() as GuideResultSet; GuideResult gr = ret.NewTable("MA"); GuideResult bt = ret.Tables[0] as GuideResult; List <double> lines = bt.getColumnData(); int N = inParams[0]; double firstVal = 0; double sum = 0; for (int i = 0; i < lines.Count; i++) { if (i <= N) { gr.Fill(i, lines[i]); sum += lines[i]; firstVal = lines[0]; continue; } sum = sum - firstVal + lines[i]; gr.Fill(i, sum / N); firstVal = lines[i - N]; } return(ret); }
public GuideResult Fill(Dictionary <string, double> _data) { GuideResult gr = new GuideResult(); if (_data == null) { return(gr); } Dictionary <string, double> data = _data.ToDictionary(p => p.Key, p => p.Value); //gr.TableName = "Base"; gr.Columns.Add("Id", typeof(Int64)); gr.Columns.Add("Expect", typeof(Int64)); gr.Columns.Add("val", typeof(double)); Int64 i = 0; foreach (string key in data.Keys) { i++; DataRow dr = gr.NewRow(); dr["Id"] = i; dr["Expect"] = Int64.Parse(key); dr["val"] = data[key]; gr.Rows.Add(dr); } this.Tables.Add(gr); return(gr); }
public GuideResult NewTable(string TableName) { GuideResult ret = new GuideResult(TableName); ret.Columns.Add("Id", typeof(Int64)); ret.Columns.Add("Expect", typeof(Int64)); ret.Columns.Add("val", typeof(double)); if (!this.Tables.Contains(TableName)) { this.Tables.Add(ret); } for (int i = 0; i < this.Tables[0].Rows.Count; i++) { DataRow dr = this.Tables[TableName].NewRow(); dr["Id"] = this.Tables[0].Rows[i]["Id"]; dr["Expect"] = this.Tables[0].Rows[i]["Expect"]; this.Tables[TableName].Rows.Add(dr); } return(ret); }