コード例 #1
0
 void InitMainDifferenceTable(int nrows, int ncolumns, ref DirichletTask task, ref DirichletTask task2)
 {
     for (int i = 1; i < nrows - 1; i++)
     {
         for (int j = 2; j < ncolumns; j++)
         {
             int ii = Convert.ToInt32(dataGridView1.Columns[j].Name);
             int jj = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value);
             dataGridView1.Rows[i].Cells[j].Value = Math.Abs(task2.GetValue(2 * ii, 2 * jj) - task.GetValue(ii, jj));
         }
     }
 }
コード例 #2
0
 void InitVTable(int nrows, int ncolumns, ref DirichletTask task)
 {
     for (int i = 1; i < nrows - 1; i++)
     {
         for (int j = 2; j < ncolumns; j++)
         {
             int ii = Convert.ToInt32(dataGridView1.Columns[j].Name);
             int jj = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value);
             dataGridView1.Rows[i].Cells[j].Value = task.GetValue(ii, jj);
         }
     }
 }
コード例 #3
0
        double CalculateMainError(ref DirichletTask task, ref DirichletTask task2, ref int iTotalEps, ref int jTotalEps)
        {
            double maxError = -1e100;

            for (int i = 1, j = 1; i < n && j < m; task.GetNextInnerXYIndex(ref i, ref j))
            {
                double currError = Math.Abs(task2.GetValue(2 * i, 2 * j) - task.GetValue(i, j));
                if (currError > maxError)
                {
                    maxError  = currError;
                    iTotalEps = i; jTotalEps = j;
                }
            }
            return(maxError);
        }
コード例 #4
0
        private void МетодСопряженногоГрадиентаToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InitMethodParameters();
            istest      = true;
            isrectangle = true;
            task        = new TestTaskRectangle(a, b, c, d, n, m, eps, nmax, initApprx);
            task.ConjugateGradientMethod();

            int    iTotalEps = -1, jTotalEps = -1;
            double maxError = CalculateTestError(ref task, ref iTotalEps, ref jTotalEps);

            double xTotalEps = a + iTotalEps * (b - a) / n;
            double yTotalEps = c + jTotalEps * (d - c) / m;
            double rmax      = task.RMax();
            double r2        = task.R2();

            WriteResults(istest, maxError, iTotalEps, jTotalEps, xTotalEps, yTotalEps, task.epsMax, task.countSteps, rmax, r2);
        }
コード例 #5
0
        private void МетодВерхнейРелаксацииToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InitMethodParameters();

            istest      = true;
            isrectangle = true;
            task        = new TestTaskRectangle(a, b, c, d, n, m, eps, nmax, initApprx, w);
            task.OverRelaxationMethod();

            int    iTotalEps = -1, jTotalEps = -1;
            double maxError = CalculateTestError(ref task, ref iTotalEps, ref jTotalEps);

            double xTotalEps = a + iTotalEps * (b - a) / n;
            double yTotalEps = c + jTotalEps * (d - c) / m;
            double rmax      = task.RMax();
            double r2        = task.R2();

            WriteResults(istest, maxError, iTotalEps, jTotalEps, xTotalEps, yTotalEps, task.epsMax, task.countSteps, rmax, r2);
            str_w.Text = task.w.ToString();
        }
コード例 #6
0
        private void ТестоваяЗадачаНаНепрямоугольнойОбластиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InitMethodParameters();
            istest      = true;
            isrectangle = false;
            task        = new TestTaskRectangleWithHole(a, b, c, d, n, m, eps, nmax, initApprx);

            task.ConjugateGradientMethod();

            int nrows    = m + 2;
            int ncolumns = n + 3;

            int    iTotalEps = -1, jTotalEps = -1;
            double maxError = CalculateTestError(ref task, ref iTotalEps, ref jTotalEps);

            double xTotalEps = a + iTotalEps * (b - a) / n;
            double yTotalEps = c + jTotalEps * (d - c) / m;
            double rmax      = task.RMax();
            double r2        = task.R2();

            WriteResults(istest, maxError, iTotalEps, jTotalEps, xTotalEps, yTotalEps, task.epsMax, task.countSteps, rmax, r2);
        }
コード例 #7
0
        private void методСопряженныхГрадиентовToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InitMethodParameters();

            istest      = false;
            isrectangle = true;
            task        = new MainTaskRectangle(a, b, c, d, n, m, eps, nmax, initApprx, w);
            task2       = new MainTaskRectangle(a, b, c, d, 2 * n, 2 * m, eps, nmax, initApprx, w);
            task.ConjugateGradientMethod();
            task2.ConjugateGradientMethod();

            int    iTotalEps = -1, jTotalEps = -1;
            double maxError = CalculateMainError(ref task, ref task2, ref iTotalEps, ref jTotalEps);

            double xTotalEps = a + iTotalEps * (b - a) / n;
            double yTotalEps = c + jTotalEps * (d - c) / m;
            double rmax      = task.RMax();
            double rmax2     = task2.RMax();
            double r2        = task.R2();
            double r22       = task2.R2();

            WriteResults(istest, maxError, iTotalEps, jTotalEps, xTotalEps, yTotalEps, task.epsMax, task.countSteps, rmax, r2, rmax2, r22);
            str_w.Text = task.w.ToString();
        }
コード例 #8
0
        private void МетодМинимальныхНевязокToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            InitMethodParameters();

            istest      = false;
            isrectangle = true;
            task        = new MainTaskRectangle(a, b, c, d, n, m, eps, nmax, initApprx);
            task2       = new MainTaskRectangle(a, b, c, d, 2 * n, 2 * m, eps, nmax, initApprx);
            task.MinimumResidualsMethod();
            task2.MinimumResidualsMethod();

            int    iTotalEps = -1, jTotalEps = -1;
            double maxError = CalculateMainError(ref task, ref task2, ref iTotalEps, ref jTotalEps);

            double xTotalEps = a + iTotalEps * (b - a) / n;
            double yTotalEps = c + jTotalEps * (d - c) / m;
            double rmax      = task.RMax();
            double rmax2     = task2.RMax();
            double r2        = task.R2();
            double r22       = task2.R2();

            WriteResults(istest, maxError, iTotalEps, jTotalEps, xTotalEps, yTotalEps, task.epsMax, task.countSteps, rmax, r2, rmax2, r22);
            str_w.Text = task.w.ToString();
        }