Exemplo n.º 1
0
        private void BtnFindNearPrime_Click(object sender, EventArgs e)
        {
            this.LastExec_IsPrime = false;

            IntTools.Normalize(this.IsPrimeInputValue);
            string str = this.IsPrimeInputValue.Text;

            if (IntTools.IsULongString(str) == false)
            {
                MessageBox.Show(
                    "0 ~ " + ulong.MaxValue + " の整数を入力して下さい。",
                    "判定できません",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );

                this.PostExec_IsPrime();
                return;
            }
            this.NennotameMkPrimeDat();

            WorkDir workDir = new WorkDir();
            string  outFile = workDir.MakePath();

            this.ProcMan.Start(Gnd.I.Prime64File, "//MOLP " + StringTools.OUT_PFX + " //O \"" + outFile + "\" " + this.CmdPartOptUMRTM() + "/LH " + str);

            using (BusyDlg f = new BusyDlg())
            {
                f.SetInterval(delegate
                {
                    return(this.ProcMan.IsEnd() == false);
                });

                f.ShowDialog();
            }
            string[] lines = File.ReadAllLines(outFile);
            lines = StringTools.Prime64StdoutFilter(lines);
            string str_l = lines[0];
            string str_h = lines[1];

            if (str_l == "0")
            {
                str_l = "(なし)";
            }

            if (str_h == "0")
            {
                str_h = Gnd.I.PRIME_MIN_OVER_UL;
            }

            this.IsPrimeOutput.Text = "入力値:\r\n" + str + "\r\n入力値より小さい最大の素数:\r\n" + str_l + "\r\n入力値より大きい最小の素数:\r\n" + str_h;
            //this.IsPrimeOutput.Text = "n=\r\n" + str + "\r\nnより小さい最大の素数=\r\n" + str_l + "\r\nnより大きい最小の素数=\r\n" + str_h;
            //this.IsPrimeOutput.Text = str + "\r\n" + str_l + "\r\n" + str_h + "\r\n\r\n# 上から「入力値, 入力値より小さい最大の素数, 入力値より大きい最小の素数」です。";
            //this.IsPrimeOutput.Text = str_l + "\r\n" + str_h + "\r\n\r\n# 上から「 " + str + " より小さい最大の素数」「 " + str + " より大きい最小の素数」です。素数が見つからない場合は 0 を表示します。";

            workDir.Destroy();
            workDir = null;

            this.PostExec_IsPrime();
        }
Exemplo n.º 2
0
        private void Start()
        {
            this.CancelEvName  = StringTools.MakeUUID();
            this.ReportEvName  = StringTools.MakeUUID();
            this.ReportMtxName = StringTools.MakeUUID();
            this.ReportDir     = new WorkDir();
            this.ReportFile    = this.ReportDir.MakePath() + ".txt";

            this.CancelEv  = new EventWaitHandle(false, EventResetMode.AutoReset, this.CancelEvName);
            this.ReportEv  = new EventWaitHandle(false, EventResetMode.AutoReset, this.ReportEvName);
            this.ReportMtx = new Mutex(false, this.ReportMtxName);

            string command = this.CountMode ? "/C2" : "/R2";

            if (this.DivMode)
            {
                command += " /D";
            }

            this.ProcMan = new ProcessMan();
            this.ProcMan.Start(
                Gnd.I.Prime64File,
                Gnd.I.MainWin.CmdPartOptUMRTM() +
                command + " " +
                this.Minval + " " +
                this.Maxval + " " +
                "\"" + this.OutFile + "\" " +
                this.CancelEvName + " " +
                this.ReportEvName + " " +
                this.ReportMtxName + " " +
                "\"" + this.ReportFile + "\""
                );
        }
Exemplo n.º 3
0
        private void Start()
        {
            this.CancelEvName  = StringTools.MakeUUID();
            this.ReportEvName  = StringTools.MakeUUID();
            this.ReportMtxName = StringTools.MakeUUID();
            this.ReportDir     = new WorkDir();
            this.ReportFile    = this.ReportDir.MakePath() + ".txt";

            this.CancelEv  = new EventWaitHandle(false, EventResetMode.AutoReset, this.CancelEvName);
            this.ReportEv  = new EventWaitHandle(false, EventResetMode.AutoReset, this.ReportEvName);
            this.ReportMtx = new Mutex(false, this.ReportMtxName);

            this.ProcMan = new ProcessMan();
            this.ProcMan.Start(
                Gnd.I.Prime64File,
                Gnd.I.MainWin.CmdPartOptUMRTM() +
                "/US2 " +
                this.L + " " +
                this.T + " " +
                this.R + " " +
                this.B + " " +
                this.PrimeColor + " " +
                this.NotPrimeColor + " " +
                this.CenterColor + " " +
                "\"" + this.OutFile + "\" " +
                this.CancelEvName + " " +
                this.ReportEvName + " " +
                this.ReportMtxName + " " +
                "\"" + this.ReportFile + "\""
                );
        }
Exemplo n.º 4
0
        private void BtnIsPrime_Click(object sender, EventArgs e)
        {
            this.LastExec_IsPrime = true;

            IntTools.Normalize(this.IsPrimeInputValue);
            string str = this.IsPrimeInputValue.Text;

            if (IntTools.IsULongString(str) == false)
            {
                MessageBox.Show(
                    "0 ~ " + ulong.MaxValue + " の整数を入力して下さい。",
                    "判定できません",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );

                this.PostExec_IsPrime();
                return;
            }
            this.NennotameMkPrimeDat();

            WorkDir workDir = new WorkDir();
            string  outFile = workDir.MakePath();

            this.ProcMan.Start(Gnd.I.Prime64File, "//MOLP " + StringTools.OUT_PFX + " //O \"" + outFile + "\" " + this.CmdPartOptUMRTM() + "/P " + str);

            using (BusyDlg f = new BusyDlg())
            {
                f.SetInterval(delegate
                {
                    return(this.ProcMan.IsEnd() == false);
                });

                f.ShowDialog();
            }
            string[] lines = File.ReadAllLines(outFile);
            lines = StringTools.Prime64StdoutFilter(lines);
            string ans = lines[0];

            if (ans == "IS_PRIME")
            {
                this.IsPrimeOutput.Text = str + "\r\nこの値は 素数 です。";
            }
            else if (ans == "IS_NOT_PRIME")
            {
                this.IsPrimeOutput.Text = str + "\r\nこの値は 素数 ではありません。2未満の整数又は合成数です。";
            }
            else
            {
                this.IsPrimeOutput.Text = str + "\r\n(エラー)";
            }
            workDir.Destroy();
            workDir = null;

            this.PostExec_IsPrime();
        }
Exemplo n.º 5
0
        private void BtnFactorize_Click(object sender, EventArgs e)
        {
            IntTools.Normalize(this.FactorizeInputValue);
            string str = this.FactorizeInputValue.Text;

            if (IntTools.IsULongString(str) == false || ulong.Parse(str) < 1)
            {
                MessageBox.Show(
                    "1 ~ " + ulong.MaxValue + " の整数を入力して下さい。",
                    "素因数分解できません",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );

                this.PostExec_Factorize();
                return;
            }
            this.NennotameMkPrimeDat();

            WorkDir workDir = new WorkDir();
            string  outFile = workDir.MakePath();

            this.ProcMan.Start(Gnd.I.Prime64File, "//MOLP " + StringTools.OUT_PFX + " //O \"" + outFile + "\" " + this.CmdPartOptUMRTM() + "/F " + str);

            using (BusyDlg f = new BusyDlg())
            {
                f.SetInterval(delegate
                {
                    return(this.ProcMan.IsEnd() == false);
                });

                f.ShowDialog();
            }
            string[] lines = File.ReadAllLines(outFile);
            lines = StringTools.Prime64StdoutFilter(lines);

            if (this.CheckFactorizeBekijou.Checked)
            {
                lines = this.ToBekijou(lines);
            }

            if (this.Chk改行しない.Checked)
            {
                this.FactorizeOutput.Text = str + " = " + string.Join(" * ", lines);
            }
            else
            {
                this.FactorizeOutput.Text = str + " の 素因数 は ...\r\n" + string.Join("\r\n", lines);
            }

            workDir.Destroy();
            workDir = null;

            this.PostExec_Factorize();
        }
Exemplo n.º 6
0
 private void End()
 {
     this.CancelEv.Close();
     this.CancelEv = null;
     this.ReportEv.Close();
     this.ReportEv = null;
     this.ReportMtx.Close();
     this.ReportMtx = null;
     this.ReportDir.Destroy();
     this.ReportDir = null;
 }