private bool Xsort() { InDataPoint tmpx1 = new InDataPoint(); InDataPoint tmpx2 = new InDataPoint(); if (DataPoint.Count <= 2) { return(false); } for (int i = 0; i < DataPoint.Count; i++) { tmpx1 = DataPoint[i]; for (int j = i; j < DataPoint.Count; j++) { tmpx2 = DataPoint[j]; if (tmpx1.X_Value > tmpx2.X_Value) { DataPoint[i] = tmpx2; DataPoint[j] = tmpx1; tmpx1 = DataPoint[i]; } } } MaxValue = DataPoint[DataPoint.Count - 1]; MinValue = DataPoint[0]; return(true); }
public MyMathXYData() { //X_Count = 0; //Y_Count = 0; MaxValue = new InDataPoint(); MinValue = new InDataPoint(); DataPoint = new List <InDataPoint>(); }
/// <summary> /// X轴线性滤波 /// </summary> public List <InDataPoint> XLinearFilter(int cnt) { if (cnt <= 0) { MessageBox.Show("输入参数有误"); return(default(List <InDataPoint>)); } if (DataPoint.Count == 0) { MessageBox.Show("输入数据有误"); return(default(List <InDataPoint>)); } if (this.Xsort() == false) { MessageBox.Show("输入数据有误"); return(default(List <InDataPoint>)); } List <InDataPoint> tmpdata = new List <InDataPoint>(); InDataPoint tmpx1 = new InDataPoint(); InDataPoint tmpx2 = new InDataPoint(); InDataPoint tmpx3 = MinValue; double ysub; double xsub = (double)(MaxValue.X_Value - MinValue.X_Value) / cnt; tmpdata.Add(MinValue); for (int i = 0; i < DataPoint.Count - 1;) { tmpx1 = DataPoint[i]; do { i++; }while (i < DataPoint.Count - 1 && (DataPoint[i].X_Value - tmpx1.X_Value) < xsub); tmpx2 = DataPoint[i]; ysub = (double)(tmpx2.Y_Value - tmpx1.Y_Value) * xsub / (tmpx2.X_Value - tmpx1.X_Value); while (tmpdata[tmpdata.Count - 1].X_Value <= tmpx2.X_Value) { tmpdata.Add(new InDataPoint(tmpx3.X_Value + xsub, tmpx3.Y_Value + ysub)); tmpx3 = tmpdata[tmpdata.Count - 1]; } } return(tmpdata); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { for (int i = 1; i <= (int)this.运行次数.Value; i++) { Thread.Sleep(5); this.receiveWaiter.WaitOne(); TPSAForeGenetic.bestindividual(); TPSAForeGenetic.clear(); TPSAForeGenetic.generation(); InDataPoint[] tmp = new InDataPoint[(int)this.世代数.Value]; TPSAForeGenetic.Result.DataPoint.CopyTo(tmp); this.myAGWave1.Data.DataPoint.AddRange(tmp); this.myAGWave1.MaxX = TPSAForeGenetic.Result.getMaxX() * 1.5; this.myAGWave1.MaxY = TPSAForeGenetic.Result.getMaxY() * 1.5; this.backgroundWorker1.ReportProgress(i, 0); TPSAForeGenetic.updata(); } }