Exemple #1
0
        private matp matRot(int n, int p, int q, double c, double s)
        {
            matp r = new matp(n);

            r.initmat();
            r.sm(p, p, c);
            r.sm(q, q, c);
            r.sm(q, p, -s);
            r.sm(p, q, s);

            return(r);
        }
Exemple #2
0
        private matp matRot(int n,int p, int q, double c, double s)
        {
            matp r = new matp(n);

            r.initmat();
            r.sm(p, p, c);
            r.sm(q, q, c);
            r.sm(q, p, -s);
            r.sm(p, q, s);

            return r;
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;

            eps             = Math.Pow(10, -Convert.ToInt32(tbeps.Text));
            opr.eps         = eps;
            button2.Enabled = false;
            button3.Enabled = false;
            button4.Enabled = false;

            A = new matp(tbA.Text);
            n = A.n;
            show("A was processed !");

            B     = calcB(A);
            Binit = B;
            tbB.Clear();
            for (int i = 0; i < n; i++)
            {
                tbB.AppendText(B[i].ToString() + Environment.NewLine);
            }
            show("B calculated (init) !");

            Qt = new matp(n);
            Qt.initmat();
            show("Q initiated !");

            double r0 = 0;
            double c, s;

            R = A;
            for (int r = 1; r < n; r++)
            {
                for (int i = r + 1; i <= n; i++)
                {
                    r0 = Math.Sqrt(R.gm(r, r) * R.gm(r, r) + R.gm(i, r) * R.gm(i, r));
                    if (Math.Abs(r0) < eps)
                    {
                        c = 1;
                        s = 0;
                    }
                    else
                    {
                        c = R.gm(r, r) / r0;
                        s = R.gm(i, r) / r0;
                    }

                    matp Ri = matRot(n, r, i, c, s);
                    R  = opr.mul(Ri, R);
                    B  = opr.mulsc(Ri, B);
                    Qt = opr.mul(Ri, Qt);
                }
            }

            show("R,B,Q calculated !");

            if (R.checksing() == false)
            {
                MessageBox.Show("Matrix singular !");
            }
            else
            {
                button3.Enabled = true;
                button4.Enabled = true;
            }

            tbR.Clear();
            tbR.AppendText(R.ToString());

            tbQ.Clear();
            tbQ.AppendText(Qt.transpose().ToString());

            tbBb.Clear();
            for (int i = 0; i < n; i++)
            {
                tbBb.AppendText(B[i].ToString() + Environment.NewLine);
            }
            show("B calculated (re) !");

            tgiv = DateTime.Now - dt;
        }
Exemple #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;

            eps = Math.Pow(10, -Convert.ToInt32(tbeps.Text));
            opr.eps = eps;
            button2.Enabled = false;
            button3.Enabled = false;
            button4.Enabled = false;

            A = new matp(tbA.Text);
            n=A.n;
            show("A was processed !");

            B = calcB(A);
            Binit = B;
            tbB.Clear();
            for (int i = 0; i < n; i++)
                tbB.AppendText(B[i].ToString() + Environment.NewLine);
            show("B calculated (init) !");

            Qt = new matp(n);
            Qt.initmat();
            show("Q initiated !");

            double r0 = 0;
            double c,s;

            R = A;
            for (int r = 1; r < n; r++)
                for (int i = r + 1; i <= n; i++)
                {
                    r0 = Math.Sqrt(R.gm(r, r) * R.gm(r, r) + R.gm(i, r) * R.gm(i, r));
                    if (Math.Abs(r0) < eps)
                    {
                        c = 1;
                        s = 0;
                    }
                    else
                    {
                        c = R.gm(r, r) / r0;
                        s = R.gm(i, r) / r0;
                    }

                    matp Ri = matRot(n, r, i, c, s);
                    R = opr.mul(Ri, R);
                    B = opr.mulsc(Ri, B);
                    Qt = opr.mul(Ri, Qt);
                }

            show("R,B,Q calculated !");

            if (R.checksing() == false)
                MessageBox.Show("Matrix singular !");
            else
            {
                button3.Enabled = true;
                button4.Enabled = true;
            }

            tbR.Clear();
            tbR.AppendText(R.ToString());

            tbQ.Clear();
            tbQ.AppendText(Qt.transpose().ToString());

            tbBb.Clear();
            for (int i = 0; i < n; i++)
                tbBb.AppendText(B[i].ToString() + Environment.NewLine);
            show("B calculated (re) !");

            tgiv = DateTime.Now - dt;

        }