コード例 #1
0
    private static void Main()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    MAIN is the main program for SHEPARD_INTERP_2D_TEST.
    //
    //  Discussion:
    //
    //    SHEPARD_INTERP_2D_TEST tests the SHEPARD_INTERP_2D library.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    15 October 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double[] p_test =
        {
            1.0, 2.0, 4.0, 8.0
        }

        ;
        const int p_test_num = 4;
        int       prob;

        Console.WriteLine("");
        Console.WriteLine("SHEPARD_INTERP_2D_TEST:");
        Console.WriteLine("  Test the SHEPARD_INTERP_2D library.");
        Console.WriteLine("  The R8LIB library is needed.");
        Console.WriteLine("  This test also needs the TEST_INTERP_2D library.");

        int prob_num = Data_2D.f00_num();
        int g        = 1;

        for (prob = 1; prob <= prob_num; prob++)
        {
            int j;
            for (j = 0; j < p_test_num; j++)
            {
                double p = p_test[j];
                test01(prob, g, p);
            }
        }

        Console.WriteLine("");
        Console.WriteLine("SHEPARD_INTERP_2D_TEST:");
        Console.WriteLine("  Normal end of execution.");
        Console.WriteLine("");
    }
コード例 #2
0
    private static void Main()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    MAIN is the main program for PWL_INTERP_2D_TEST.
    //
    //  Discussion:
    //
    //    PWL_INTERP_2D_TEST tests the PWL_INTERP_2D library.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    15 October 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int[]     n_test     = { 2, 3, 4, 5, 9 };
        const int n_test_num = 5;
        int       prob;

        Console.WriteLine("");
        Console.WriteLine("PWL_INTERP_2D_TEST:");
        Console.WriteLine("  Test the PWL_INTERP_2D library.");
        Console.WriteLine("  The R8LIB library is needed.");
        Console.WriteLine("  The test needs the TEST_INTERP_2D library.");

        int prob_num = Data_2D.f00_num();

        //
        //  Numerical tests.
        //
        for (prob = 1; prob <= prob_num; prob++)
        {
            int i;
            for (i = 0; i < n_test_num; i++)
            {
                int n = n_test[i];
                test01(prob, n);
            }
        }

        //
        //  Terminate.
        //
        Console.WriteLine("");
        Console.WriteLine("PWL_INTERP_2D_TEST:");
        Console.WriteLine("  Normal end of execution.");
        Console.WriteLine("");
    }
コード例 #3
0
    private static void Main()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    MAIN is the main program for VANDERMONDE_INTERP_1D_TEST.
    //
    //  Discussion:
    //
    //    VANDERMONDE_INTERP_2D_TEST tests the VANDERMONDE_INTERP_2D library.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    07 October 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int[]     m_test     = { 1, 2, 3, 4, 8 };
        const int m_test_num = 5;
        int       prob;

        Console.WriteLine("");
        Console.WriteLine("VANDERMONDE_INTERP_2D_TEST:");
        Console.WriteLine("  Test the VANDERMONDE_INTERP_2D library.");
        Console.WriteLine("  The QR_SOLVE library is needed.");
        Console.WriteLine("  The R8LIB library is needed.");
        Console.WriteLine("  This test needs the TEST_INTERP_2D library.");

        int prob_num = Data_2D.f00_num();

        for (prob = 1; prob <= prob_num; prob++)
        {
            int j;
            for (j = 0; j < m_test_num; j++)
            {
                int m = m_test[j];
                test01(prob, m);
            }
        }

        //
        //  Terminate.
        //
        Console.WriteLine("");
        Console.WriteLine("VANDERMONDE_INTERP_2D_TEST:");
        Console.WriteLine("  Normal end of execution.");
        Console.WriteLine("");
    }
コード例 #4
0
    private static void Main()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    MAIN is the main program for RBF_INTERP_2D_TEST.
    //
    //  Discussion:
    //
    //    RBF_INTERP_2D_TEST tests the RBF_INTERP_2D library.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    06 October 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int prob;

        Console.WriteLine("");
        Console.WriteLine("RBF_INTERP_2D_TEST:");
        Console.WriteLine("  Test the RBF_INTERP_2D library.");
        Console.WriteLine("  The R8LIB library is required.");
        Console.WriteLine("  This test also needs the TEST_INTERP_2D library.");

        int       prob_num = Data_2D.f00_num();
        const int g        = 1;

        for (prob = 1; prob <= prob_num; prob++)
        {
            test01(prob, g, RadialBasisFunctions.phi1, "phi1");
            test01(prob, g, RadialBasisFunctions.phi2, "phi2");
            test01(prob, g, RadialBasisFunctions.phi3, "phi3");
            test01(prob, g, RadialBasisFunctions.phi4, "phi4");
        }

        //
        //  Terminate.
        //
        Console.WriteLine("");
        Console.WriteLine("RBF_INTERP_2D_TEST:");
        Console.WriteLine("  Normal end of execution.");
        Console.WriteLine("");
    }
コード例 #5
0
    private static void Main()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    MAIN is the main program for PWL_INTERP_2D_SCATTERED_TEST.
    //
    //  Discussion:
    //
    //    PWL_INTERP_2D_SCATTERED_TEST tests the PWL_INTERP_2D_SCATTERED library.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    25 October 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int prob;

        Console.WriteLine("");
        Console.WriteLine("PWL_INTERP_2D_SCATTERED_TEST:");
        Console.WriteLine("  Test the PWL_INTERP_2D_SCATTERED library.");
        Console.WriteLine("  The R8LIB library is needed.");
        Console.WriteLine("  This test also needs the TEST_INTERP_2D library.");

        test01();
        test02();
        //
        //  Numerical tests.
        //
        int prob_num = Data_2D.f00_num();

        for (prob = 1; prob <= prob_num; prob++)
        {
            test03(prob);
        }

        Console.WriteLine("");
        Console.WriteLine("PWL_INTERP_2D_SCATTERED_TEST:");
        Console.WriteLine("  Normal end of execution.");
        Console.WriteLine("");
    }
コード例 #6
0
    private static void test01(int prob, int grd, int m)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    VANDERMONDE_APPROX_2D_TEST01 tests VANDERMONDE_APPROX_2D_MATRIX.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    11 October 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, int PROB, the problem number.
    //
    //    Input, int GRD, the grid number.
    //    (Can't use GRID as the name because that's also a plotting function.)
    //
    //    Input, int M, the total polynomial degree.
    //
    {
        Console.WriteLine("");
        Console.WriteLine("TEST01:");
        Console.WriteLine("  Approximate data from TEST_INTERP_2D problem #" + prob + "");
        Console.WriteLine("  Use grid from TEST_INTERP_2D with index #" + grd + "");
        Console.WriteLine("  Using polynomial approximant of total degree " + m + "");

        int nd = Data_2D.g00_size(grd);

        Console.WriteLine("  Number of data points = " + nd + "");

        double[] xd = new double[nd];
        double[] yd = new double[nd];
        Data_2D.g00_xy(grd, nd, ref xd, ref yd);

        double[] zd = new double[nd];
        Data_2D.f00_f0(prob, nd, xd, yd, ref zd);

        switch (nd)
        {
        case < 10:
            typeMethods.r8vec3_print(nd, xd, yd, zd, "  X, Y, Z data:");
            break;
        }

        //
        //  Compute the Vandermonde matrix.
        //
        int tm = typeMethods.triangle_num(m + 1);

        double[] a = VandermondeMatrix.vandermonde_approx_2d_matrix(nd, m, tm, xd, yd);
        //
        //  Solve linear system.
        //
        double[] c = QRSolve.qr_solve(nd, tm, a, zd);
        //
        //  #1:  Does approximant match function at data points?
        //
        int ni = nd;

        double[] xi = typeMethods.r8vec_copy_new(ni, xd);
        double[] yi = typeMethods.r8vec_copy_new(ni, yd);
        double[] zi = Polynomial.r8poly_values_2d(m, c, ni, xi, yi);

        double app_error = typeMethods.r8vec_norm_affine(ni, zi, zd) / ni;

        Console.WriteLine("");
        Console.WriteLine("  L2 data approximation error = " + app_error + "");
    }
コード例 #7
0
    private static void Main()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    MAIN is the main program for LAGRANGE_INTERP_2D_TEST.
    //
    //  Discussion:
    //
    //    LAGRANGE_INTERP_2D_TEST tests the LAGRANGE_INTERP_2D library.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    13 September 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int[] m_test =
        {
            1, 2, 3, 4, 8
        }

        ;
        int m_test_num = 5;
        int prob;

        Console.WriteLine("");
        Console.WriteLine("LAGRANGE_INTERP_2D_TEST:");
        Console.WriteLine("  Test the LAGRANGE_INTERP_2D library.");
        Console.WriteLine("  The R8LIB library is needed.");
        Console.WriteLine("  This test also needs the TEST_INTERP_2D library.");

        int prob_num = Data_2D.f00_num();

        //
        //  Numerical tests.
        //
        for (prob = 1; prob <= prob_num; prob++)
        {
            int i;
            for (i = 0; i < m_test_num; i++)
            {
                int m = m_test[i];
                test01(prob, m);
            }
        }

        //
        //  Terminate.
        //
        Console.WriteLine("");
        Console.WriteLine("LAGRANGE_INTERP_2D_TEST:");
        Console.WriteLine("  Normal end of execution.");
        Console.WriteLine("");
    }
コード例 #8
0
    private static void test01(int prob, int m)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LAGRANGE_INTERP_2D_TEST01 tests LAGRANGE_INTERP_2D.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    13 September 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, int PROB, the problem number.
    //
    //    Input, int M, the polynomial degree in each dimension.
    //
    {
        int i;
        int j;

        Console.WriteLine("");
        Console.WriteLine("LAGRANGE_INTERP_2D_TEST01:");
        Console.WriteLine("  Interpolate data from TEST_INTERP_2D problem #" + prob + "");
        Console.WriteLine("  Using polynomial interpolant of product degree " + m + " x " + m + "");

        int nd = (m + 1) * (m + 1);

        Console.WriteLine("  Number of data points = " + nd + "");

        double[] xd_1d = typeMethods.r8vec_cheby_extreme_new(m + 1, 0.0, 1.0);
        double[] yd_1d = typeMethods.r8vec_cheby_extreme_new(m + 1, 0.0, 1.0);

        double[] xd = new double[(m + 1) * (m + 1)];
        double[] yd = new double[(m + 1) * (m + 1)];
        double[] zd = new double[(m + 1) * (m + 1)];

        int ij = 0;

        for (j = 0; j < m + 1; j++)
        {
            for (i = 0; i < m + 1; i++)
            {
                xd[ij] = xd_1d[i];
                yd[ij] = yd_1d[j];
                ij    += 1;
            }
        }

        Data_2D.f00_f0(prob, nd, xd, yd, ref zd);

        switch (nd)
        {
        case <= 20:
            typeMethods.r8vec3_print(nd, xd, yd, zd, "  X, Y, Z data:");
            break;
        }

        //
        //  #1:  Does interpolant match function at data points?
        //
        int ni = nd;

        double[] xi = new double[ni];
        double[] yi = new double[ni];

        for (i = 0; i < ni; i++)
        {
            xi[i] = xd[i];
            yi[i] = yd[i];
        }

        double[] zi = Lagrange2D.lagrange_interp_2d(m, m, xd_1d, yd_1d, zd, ni, xi, yi);

        switch (ni)
        {
        case <= 20:
            typeMethods.r8vec3_print(ni, xi, yi, zi, "  X, Y, Z interpolation:");
            break;
        }

        double int_error = typeMethods.r8vec_norm_affine(ni, zi, zd) / ni;

        Console.WriteLine("");
        Console.WriteLine("  RMS data interpolation error = " + int_error + "");

        switch (nd)
        {
        //
        //  #2:  Does interpolant approximate data at midpoints?
        //
        case > 1:
        {
            double[] xi_1d = new double[m];
            double[] yi_1d = new double[m];

            for (i = 0; i < m; i++)
            {
                xi_1d[i] = 0.5 * (xd_1d[i] + xd_1d[i + 1]);
            }

            for (i = 0; i < m; i++)
            {
                yi_1d[i] = 0.5 * (yd_1d[i] + yd_1d[i + 1]);
            }

            ni = m * m;

            xi = new double[ni];
            yi = new double[ni];
            double[] zdm = new double[ni];

            ij = 0;
            for (j = 0; j < m; j++)
            {
                for (i = 0; i < m; i++)
                {
                    xi[ij] = xi_1d[i];
                    yi[ij] = yi_1d[j];
                    ij    += 1;
                }
            }

            Data_2D.f00_f0(prob, ni, xi, yi, ref zdm);

            zi = Lagrange2D.lagrange_interp_2d(m, m, xd_1d, yd_1d, zd, ni, xi, yi);

            double app_error = typeMethods.r8vec_norm_affine(ni, zi, zdm) / ni;

            Console.WriteLine("");
            Console.WriteLine("  RMS data approximation error = " + app_error + "");
            break;
        }
        }
    }
コード例 #9
0
    private static void test01(int prob, int g,
                               Func <int, double[], double, double[], double[]> phi, string phi_name)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    RBF_INTERP_2D_TEST01 tests RBF_INTERP_2D.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    06 October 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, int PROB, the index of the problem.
    //
    //    Input, int G, the index of the grid.
    //
    //    Input, void PHI ( int n, double r[], double r0, double v[] ), the
    //    radial basis function.
    //
    //    Input, string PHI_NAME, the name of the radial basis function.
    //
    {
        const bool debug = false;
        int        i;

        Console.WriteLine("");
        Console.WriteLine("RBF_INTERP_2D_TEST01:");
        Console.WriteLine("  Interpolate data from TEST_INTERP_2D problem #" + prob + "");
        Console.WriteLine("  using grid #" + g + "");
        Console.WriteLine("  using radial basis function \"" + phi_name + "\".");

        int nd = Data_2D.g00_size(g);

        Console.WriteLine("  Number of data points = " + nd + "");

        double[] xd = new double[nd];
        double[] yd = new double[nd];
        Data_2D.g00_xy(g, nd, ref xd, ref yd);

        double[] zd = new double[nd];
        Data_2D.f00_f0(prob, nd, xd, yd, ref zd);

        switch (debug)
        {
        case true:
            typeMethods.r8vec3_print(nd, xd, yd, zd, "  X, Y, Z data:");
            break;
        }

        const int m = 2;

        double[] xyd = new double[2 * nd];

        for (i = 0; i < nd; i++)
        {
            xyd[0 + i * 2] = xd[i];
            xyd[1 + i * 2] = yd[i];
        }

        double xmax   = typeMethods.r8vec_max(nd, xd);
        double xmin   = typeMethods.r8vec_min(nd, xd);
        double ymax   = typeMethods.r8vec_max(nd, yd);
        double ymin   = typeMethods.r8vec_min(nd, yd);
        double volume = (xmax - xmin) * (ymax - ymin);

        const double e  = 1.0 / m;
        double       r0 = Math.Pow(volume / nd, e);

        Console.WriteLine("  Setting R0 = " + r0 + "");

        double[] w = RadialBasisFunctions.rbf_weight(m, nd, xyd, r0, phi, zd);
        //
        //  #1:  Does interpolant match function at interpolation points?
        //
        double[] xyi = typeMethods.r8mat_copy_new(2, nd, xyd);

        double[] zi = RadialBasisFunctions.rbf_interp(m, nd, xyd, r0, phi, w, nd, xyi);

        double int_error = typeMethods.r8vec_norm_affine(nd, zi, zd) / nd;

        Console.WriteLine("");
        Console.WriteLine("  L2 interpolation error averaged per interpolant node = "
                          + int_error + "");
    }
コード例 #10
0
    private static void test01(int prob, int g, double p)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST01 tests SHEPARD_INTERP_2D.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    02 October 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, int PROB, the problem number.
    //
    //    Input, int G, the grid number.
    //
    //    Input, double P, the power used in the distance weighting.
    //
    {
        const bool debug = false;

        Console.WriteLine("");
        Console.WriteLine("TEST01:");
        Console.WriteLine("  Interpolate data from TEST_INTERP_2D problem #" + prob + "");
        Console.WriteLine("  using grid #" + g + "");
        Console.WriteLine("  using Shepard interpolation with P = " + p + "");

        int nd = Data_2D.g00_size(g);

        Console.WriteLine("  Number of data points = " + nd + "");

        double[] xd = new double[nd];
        double[] yd = new double[nd];
        Data_2D.g00_xy(g, nd, ref xd, ref yd);

        double[] zd = new double[nd];
        Data_2D.f00_f0(prob, nd, xd, yd, ref zd);

        switch (debug)
        {
        case true:
            typeMethods.r8vec3_print(nd, xd, yd, zd, "  X, Y, Z data:");
            break;
        }

        //
        //  #1:  Does interpolant match function at interpolation points?
        //
        int ni = nd;

        double[] xi = typeMethods.r8vec_copy_new(ni, xd);
        double[] yi = typeMethods.r8vec_copy_new(ni, yd);

        double[] zi = Shepard.shepard_interp_2d(nd, xd, yd, zd, p, ni, xi, yi);

        double int_error = typeMethods.r8vec_norm_affine(ni, zi, zd) / ni;

        Console.WriteLine("");
        Console.WriteLine("  L2 interpolation error averaged per interpolant node = " + int_error + "");
    }
コード例 #11
0
    private static void test03(int prob)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST03 tests PWL_INTERP_2D_SCATTERED_VALUE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    25 October 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int       element_num = 0;
        int       i;
        int       j;
        const int ni = 25;

        double[] xi  = new double[25];
        double[] xyi = new double[2 * 25];
        double[] yi  = new double[25];

        const int g  = 2;
        int       nd = Data_2D.g00_size(g);

        Console.WriteLine("");
        Console.WriteLine("TEST03");
        Console.WriteLine("  PWL_INTERP_2D_SCATTERED_VALUE evaluates a");
        Console.WriteLine("  piecewise linear interpolant to scattered data.");
        Console.WriteLine("  Here, we use grid number " + g + "");
        Console.WriteLine("  with " + nd + " scattered points in the unit square");
        Console.WriteLine("  on problem " + prob + "");
        //
        //  Get the data points and evaluate the function there.
        //
        double[] xd = new double[nd];
        double[] yd = new double[nd];

        Data_2D.g00_xy(g, nd, ref xd, ref yd);

        double[] zd = new double[nd];
        Data_2D.f00_f0(prob, nd, xd, yd, ref zd);

        double[] xyd = new double[2 * nd];

        for (i = 0; i < nd; i++)
        {
            xyd[0 + i * 2] = xd[i];
            xyd[1 + i * 2] = yd[i];
        }

        //
        //  Set up the Delaunay triangulation.
        //
        int[] element_neighbor = new int[3 * 2 * nd];
        int[] triangle         = new int[3 * 2 * nd];

        Delauney.r8tris2(nd, ref xyd, ref element_num, ref triangle, ref element_neighbor);

        for (j = 0; j < element_num; j++)
        {
            for (i = 0; i < 3; i++)
            {
                switch (element_neighbor[i + j * 3])
                {
                case > 0:
                    element_neighbor[i + j * 3] -= 1;
                    break;
                }
            }
        }

        //
        //  Define the interpolation points.
        //
        int k = 0;

        for (i = 1; i <= 5; i++)
        {
            for (j = 1; j <= 5; j++)
            {
                xyi[0 + k * 2] = (2 * i - 1) / 10.0;
                xyi[1 + k * 2] = (2 * j - 1) / 10.0;
                k += 1;
            }
        }

        for (k = 0; k < ni; k++)
        {
            xi[k] = xyi[0 + k * 2];
            yi[k] = xyi[1 + k * 2];
        }

        double[] ze = new double[ni];
        Data_2D.f00_f0(prob, ni, xi, yi, ref ze);
        //
        //  Evaluate the interpolant.
        //
        double[] zi = Interp2D.pwl_interp_2d_scattered_value(nd, xyd, zd, element_num,
                                                             triangle, element_neighbor, ni, xyi);

        double rms = 0.0;

        for (k = 0; k < ni; k++)
        {
            rms += Math.Pow(zi[k] - ze[k], 2);
        }

        rms = Math.Sqrt(rms / ni);

        Console.WriteLine("");
        Console.WriteLine("  RMS error is " + rms + "");

        Console.WriteLine("");
        Console.WriteLine("     K      Xi(K)       Yi(K)       Zi(K)       Z(X,Y)");
        Console.WriteLine("");

        for (k = 0; k < ni; k++)
        {
            Console.WriteLine("  " + k.ToString().PadLeft(4)
                              + "  " + xyi[0 + k * 2].ToString(CultureInfo.InvariantCulture).PadLeft(10)
                              + "  " + xyi[1 + k * 2].ToString(CultureInfo.InvariantCulture).PadLeft(10)
                              + "  " + zi[k].ToString(CultureInfo.InvariantCulture).PadLeft(10)
                              + "  " + ze[k].ToString(CultureInfo.InvariantCulture).PadLeft(10) + "");
        }
    }
コード例 #12
0
    private static void test01(int prob, int m)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST01 tests VANDERMONDE_INTERP_2D_MATRIX.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    07 October 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, int PROB, the problem number.
    //
    //    Input, int M, the degree of interpolation.
    //
    {
        const bool debug = false;

        Console.WriteLine("");
        Console.WriteLine("TEST01:");
        Console.WriteLine("  Interpolate data from TEST_INTERP_2D problem #" + prob + "");
        Console.WriteLine("  Create an interpolant of total degree " + m + "");
        int tmp1 = typeMethods.triangle_num(m + 1);

        Console.WriteLine("  Number of data values needed is " + tmp1 + "");

        int seed = 123456789;

        double[] xd = UniformRNG.r8vec_uniform_01_new(tmp1, ref seed);
        double[] yd = UniformRNG.r8vec_uniform_01_new(tmp1, ref seed);
        double[] zd = new double[tmp1];
        Data_2D.f00_f0(prob, tmp1, xd, yd, ref zd);

        switch (debug)
        {
        case true:
            typeMethods.r8vec3_print(tmp1, xd, yd, zd, "  X, Y, Z data:");
            break;
        }

        //
        //  Compute the Vandermonde matrix.
        //
        double[] a = Vandermonde.vandermonde_interp_2d_matrix(tmp1, m, xd, yd);
        //
        //  Solve linear system.
        //
        double[] c = QRSolve.qr_solve(tmp1, tmp1, a, zd);
        //
        //  #1:  Does interpolant match function at data points?
        //
        int ni = tmp1;

        double[] xi = typeMethods.r8vec_copy_new(ni, xd);
        double[] yi = typeMethods.r8vec_copy_new(ni, yd);
        double[] zi = Polynomial.r8poly_values_2d(m, c, ni, xi, yi);

        double app_error = typeMethods.r8vec_norm_affine(ni, zi, zd) / ni;

        Console.WriteLine("");
        Console.WriteLine("  L2 data interpolation error = " + app_error + "");
    }