Beispiel #1
0
        private void Tab3btnAutoCorr_Click(object sender, EventArgs e)
        {
            try
            {
                Tab3dtGrid.Rows.Clear();
                Tab3dtGrid.Columns.Clear();
                Tab3dtGrid.DataSource = null;
                Tab3dtGrid.Columns.Add("shift", "Shift Count (Tau)");
                Tab3dtGrid.Columns.Add("autocorr", "Autocorrelation Value C(Tau)");
                int      distinctpoints;
                double[] autcor = LFSRTools.AllAutoCorrelationValues(Tab3txtBinSeq.Text, out distinctpoints);

                for (int i = 0; i < autcor.Length; i++)
                {
                    Tab3dtGrid.Rows.Add(i, autcor[i]);
                }

                Tab3dtGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);

                Tab3lblTotalRun.Text = "Number of Distinct Values = " + distinctpoints;
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }
Beispiel #2
0
        private void Tab2btnFindPeriodLC_Click(object sender, EventArgs e)
        {
            Tab2txtResult.Clear();
            Application.DoEvents();
            Tab2txtResult.AppendText("Starting to compute first 50000 stream output.\r\n");

            for (int i = 0; i < 50000; i++)
            {
                L1.Clock();
                L2.Clock();
                L3.Clock();
                L4.Clock();
                NonlinCombOutput += NonLinearCombiner(L1.StreamOutput, L2.StreamOutput, L3.StreamOutput, L4.StreamOutput).Value.ToString();
            }

            Tab2txtResult.AppendText("Stream has been generated.\r\nStarting to compute period.\r\n");
            Application.DoEvents();

            int period = LFSRTools.FindStreamPeriodExtended(NonlinCombOutput, 3 + 4 + 5 + 7);

            Tab2txtResult.AppendText("\r\nPeriod is " + period + ".\r\n");

            int LCbound = NonLinearCombinerStar(L1.FeedbackPolynomial.Degree, L2.FeedbackPolynomial.Degree, L3.FeedbackPolynomial.Degree, L4.FeedbackPolynomial.Degree);

            Tab2txtResult.AppendText("\r\nLC is bounded by " + LCbound + ".");
        }
        protected void btnRunBM_Click(object sender, EventArgs e)
        {
            FiniteField F = null;
            int         p = int.Parse(txtSize.Text.Trim());

            if (MathTools.IsPrime(p))
            {
                F = new FiniteField(p);
            }
            else
            {
                Response.Clear();
                Response.Write("Please write a prime number!");
                Response.End();
            }

            // Clean The Mess
            string seq = txtSeq.Text, newseq = "";

            for (int i = 0; i < seq.Length; i++)
            {
                int  t    = 0;
                bool dene = int.TryParse(seq[i].ToString(), out t);
                if (dene)
                {
                    if (t < F.Characteristic)
                    {
                        newseq += seq[i];
                    }
                }
            }

            if (newseq.Length == 0)
            {
                Response.Clear();
                Response.Write("Please enter the sequence.");
                Response.End();
            }

            txtSeq.Text = newseq;
            Polynomial poly = Polynomial.Parse(F, newseq, false);
            Polynomial c;
            int        LC = LFSRTools.BerlekampMassey(poly, out c);

            lblResult.Text = "Sequence Length = " + newseq.Length + "<br/>" +
                             "Linear Complexity = " + LC + "<br/>" +
                             "Connection Polynomial = " + c.ToString();
        }
Beispiel #4
0
        private void btnRunBM_Click(object sender, EventArgs e)
        {
            CleanTheMess();

            if (txtSeq.Text.Length == 0)
            {
                MessageBox.Show("Please enter the sequence.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtSeq.Focus();
                return;
            }

            Polynomial p = Polynomial.Parse(F, txtSeq.Text, false);
            Polynomial c;
            int        LC = LFSRTools.BerlekampMassey(p, out c);

            txtResult.Text = "Sequence Length = " + txtSeq.Text.Length + "\r\n" +
                             "Linear Complexity = " + LC + "\r\n" +
                             "Connection Polynomial = " + c.ToString();
        }
Beispiel #5
0
        private void Tab3btnFindRuns_Click(object sender, EventArgs e)
        {
            try
            {
                BindingList <Runs> list;
                int numOfRuns = LFSRTools.NumberOfRuns(Tab3txtBinSeq.Text, out list);
                Tab3dtGrid.Rows.Clear();
                Tab3dtGrid.Columns.Clear();
                Tab3dtGrid.DataSource = list;
                Tab3dtGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
                Tab3lblTotalRun.Text = "Total Number of Runs = " + numOfRuns;
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }

            //MessageBox.Show(LFSRTools.NumberOfRuns(Tab3txtBinSeq.Text).ToString());
        }