Exemplo n.º 1
0
        double minee(double[,] a, double[,] b, int n, int m, NE ne, int n1, int m1)
        {
            double es = 0.0;
            int    x = 0, y = 0;

            for (int i = 1; i < n1; i++)
            {
                for (int j = 1; j < m; j++)
                {
                    if (es < Math.Abs(a[i, j] - b[i, j]))
                    {
                        es = Math.Abs(a[i, j] - b[i, j]);
                        x  = i;
                        y  = j;
                    }
                }
            }
            for (int i = n1; i < n; i++)
            {
                for (int j = 1; j < m1; j++)
                {
                    if (es < Math.Abs(a[i, j] - b[i, j]))
                    {
                        es = Math.Abs(a[i, j] - b[i, j]);
                        x  = i;
                        y  = j;
                    }
                }
            }
            ne.x = x;
            ne.y = y;
            return(es);
        }
Exemplo n.º 2
0
        double[,] zeidel(double[,] xx, double[,] b, int n, int m, double h, double k, NE ne)
        {
            int    s = 0;
            int    x = 0, y = 0;
            double es = 100;
            double h2 = 1.0 / (h * h);
            double k2 = 1.0 / (k * k);

            while ((s < ne.nn) && (es > ne.ee))
            {
                es = 0;
                for (int i = 1; i < n; i++)
                {
                    for (int j = 1; j < m; j++)
                    {
                        double vs   = xx[i, j];
                        double htmp = h2 * (xx[i - 1, j] + xx[i + 1, j]);
                        double ktmp = k2 * (xx[i, j - 1] + xx[i, j + 1]);

                        xx[i, j] = (-b[i, j] + htmp + ktmp) / (2 * (h2 + k2));

                        if (es < Math.Abs(xx[i, j] - vs))
                        {
                            es = Math.Abs(xx[i, j] - vs);
                            x  = i;
                            y  = j;
                        }
                    }
                }
                s++;
            }
            ne.nn = s;
            ne.ee = es;
            ne.x  = x;
            ne.y  = y;

            return(xx);
        }
Exemplo n.º 3
0
        double[,] min_discrepancy(double[,] xx, double[,] b, int n, int m, double h, double k, NE ne, int n1, int m1)
        {
            int    s  = 0;
            double es = 100;
            double h2 = 1.0 / (h * h);
            double k2 = 1.0 / (k * k);

            double[,] r   = new double[n + 1, m + 1];
            double[,] ar  = new double[n + 1, m + 1];
            double[,] vs  = new double[n + 1, m + 1];
            double[,] axx = new double[n + 1, m + 1];

            while ((s < ne.nn) && (es > ne.ee))
            {
                vs  = xx;
                axx = ax(xx, n, m, h2, k2, n1, m1);
                r   = discrepancy(axx, xx, b, n, m, h2, k2);
                ar  = ax(r, n, m, h2, k2);
                double tau = skalar(r, ar, n, m) / skalar(ar, ar, n, m);
                xx = divv(xx, mult(r, tau, n, m), n, m);
                es = minee(xx, vs, n, m, ne, n1, m1);
                s++;
            }

            ne.nn = s;
            ne.ee = es;

            return(xx);
        }