private void ChangeFeedback(SeqGen sg) { bool isChangePeriod = _seqGen.Period != sg.Period; _seqGen = new SeqGen(sg); ChangeFeedback(isChangePeriod, true); }
public PrecisionSearchPeak(SeqGen gen, int minDisc, int nPer, double tEnv, double dnl, int q) //q>1 { _gen = gen; N = _gen.Period * minDisc * nPer; _minDisc = minDisc; OnePer = _gen.Period * minDisc; _q = q; //exp = 1 - Math.Exp(-1.0 / tEnv); _exp = 1; if (Math.Sign(tEnv) != 0) { T emul = 1; T x = -1 / (T)tEnv; T oldExp = 0; for (int i = 1; oldExp != _exp; i++) { oldExp = _exp; emul *= x / i; _exp += emul; } _exp = 1 - _exp; } _aq = 1; if (q != 1) { _aq = q * ((T)Math.Pow(q, 1.0 / (q - 1))) / (q - 1) * (T)dnl; } Mls = new int[OnePer]; ResponseE = new T[N]; ResponseNL = new T[N]; CorrelationE = new T[N + OnePer]; CorrelationNL = new T[N + OnePer]; }
public bool SetNewGen(SeqGen gen) { if (gen.Period != _gen.Period) { return(false); } _gen = gen; return(true); }
public SeqGen(SeqGen sg) { _feedback = sg.Feedback; IsValid = sg.IsValid; IsResize = sg.IsResize; Period = sg.Period; Nbits = sg.Nbits; MaxFeedbackCount = sg.MaxFeedbackCount; Reset(); }
public SearchPeak(SeqGen gen, int minDisc, int nPer, double tEnv, double dnl, int q, bool isFastMode = false) { _gen = gen; _isFastMode = isFastMode; if (isFastMode) { minDisc = nPer = 1; } N = _gen.Period * minDisc * nPer; ArrSz = ((N + 1) / 2) * 2; _minDisc = minDisc; OnePer = _gen.Period * minDisc; _q = q; _exp = 1; if (Math.Sign(tEnv) != 0) { _exp = 1 - Math.Exp(-1.0 / tEnv); } _aq = q * Math.Pow(q, 1.0 / (q - 1)) / (q - 1) * dnl; Mls = new T[ArrSz]; if (!isFastMode) { Array.Clear(Mls, 0, Mls.Length); ResponseE = new T[ArrSz]; CorrelationE = new T[ArrSz]; CorrelationNL = new T[ArrSz]; } ResponseNL = new T[ArrSz]; real = new fftw_complexarray(ArrSz / 2); complex = new fftw_complexarray(N / 2 + 1); forward = fftw_plan.dft_r2c_1d(N, real, complex, fftw_flags.Estimate | fftw_flags.DestroyInput); backward = fftw_plan.dft_c2r_1d(N, complex, real, fftw_direction.Backward, fftw_flags.Estimate); }
public SeqGenValidator(SeqGen sg) : base(sg) { AllocMemory(); }
private void btnFindAllCorPeak_Click(object sender, EventArgs e) { if (!_allFbList.Any()) { return; } _allCorPeakList = new List <int>(_allFbList.Count); var sg = new SeqGen(_seqGen); if (numCorStart.Value > numCorEnd.Value) { var t = numCorStart.Value; numCorStart.Value = numCorEnd.Value; numCorEnd.Value = t; } int start = (int)numCorStart.Value - 1; int end = (int)numCorEnd.Value - 1; Stopwatch sw = new Stopwatch(); if (cmbCorrelationMethod.SelectedIndex != 2) { if (MessageBox.Show("Данная операция отключена", "", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Information) != DialogResult.Ignore) { return; } if (cmbCorrelationMethod.SelectedIndex == 0) { var sp = new SearchPeak( sg, 1, 1, double.Parse(txtTimeConstant.Text.Replace(',', '.'), new CultureInfo("en-US")), double.Parse(txtDnl.Text.Replace(',', '.'), new CultureInfo("en-US")), cmbPowNl.SelectedIndex + 2, true ); sw.Start(); foreach (var fb in _allFbList) { sg.Feedback = fb; sp.Calculate(); var i = 0; var oldMv = double.MinValue; var res = 0; var fSt = (start + DiscreteInMinPulse - 1) / DiscreteInMinPulse + 1; var fE = end / DiscreteInMinPulse; foreach (var val in sp.ResponseNL) { if (fSt <= i && i <= fE && val > oldMv) //Добавить диапазон { oldMv = val; res = i; } i++; } res *= DiscreteInMinPulse; res -= DiscreteInMinPulse - 1; res = Math.Max(res, start); res = Math.Min(res, end); _allCorPeakList.Add(res); } } else { return; } } else { var ct = sg.Period * 1L * DiscreteInMinPulse; ct *= ct * _allFbList.Count * (int)numCorrelationPeriods.Value; if (LongTimeMessageNo(ct)) { return; } var sp = new PrecisionSearchPeak( sg, DiscreteInMinPulse, (int)numCorrelationPeriods.Value, double.Parse(txtTimeConstant.Text.Replace(',', '.'), new CultureInfo("en-US")), double.Parse(txtDnl.Text.Replace(',', '.'), new CultureInfo("en-US")), cmbPowNl.SelectedIndex + 2 ); sw.Start(); foreach (var fb in _allFbList) { sg.Feedback = fb; sp.Calculate(); var i = 0; var oldMv = double.MinValue; var res = 0; foreach (var val in sp.CorrelationNL.Skip(sp.OnePer).Take(sp.OnePer)) { if (start <= i && i <= end && (double)val > oldMv) //Добавить диапазон { oldMv = (double)val; res = i; } i++; } _allCorPeakList.Add(res); } } sw.Stop(); lblTime.Text = sw.ElapsedMilliseconds.ToString(); UpdateFeedbacksList(); }