Пример #1
0
    private static void test06()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST06 tests the stereographic mapping.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    15 December 2013
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int m;

        Console.WriteLine("");
        Console.WriteLine("TEST06");
        Console.WriteLine("  Test the stereographic mapping:");
        Console.WriteLine("  HYPERSPHERE_STEREOGRAPH maps hypersphere points to the plane.");
        Console.WriteLine("  HYPERSPHERE_STEREOGRAPH_INVERSE inverts the mapping.");
        Console.WriteLine("");
        Console.WriteLine("  Pick a random X1 on the hypersphere.");
        Console.WriteLine("  Map it to a point X2 on the plane.");
        Console.WriteLine("  Map it back to a point X3 on the hypersphere.");
        Console.WriteLine("  Consider norm of difference.");
        Console.WriteLine("");
        Console.WriteLine("  M    || X1 - X3 ||");

        int seed = 123456789;

        typeMethods.r8vecNormalData data = new();

        const int n = 1;

        for (m = 2; m <= 5; m++)
        {
            Console.WriteLine("");
            int test;
            for (test = 1; test <= 5; test++)
            {
                double[] x1  = Hypersphere.hypersphere_01_surface_uniform(m, n, ref data, ref seed);
                double[] x2  = Hypersphere.hypersphere_stereograph(m, n, x1);
                double[] x3  = Hypersphere.hypersphere_stereograph_inverse(m, n, x2);
                double   err = typeMethods.r8mat_norm_fro_affine(m, n, x1, x3);
                Console.WriteLine("  " + m.ToString(CultureInfo.InvariantCulture).PadLeft(2)
                                  + "  " + err.ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
            }
        }
    }
Пример #2
0
    private static void test02()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST02 tests HYPERSPHERE_01_SURFACE_UNIFORM.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    15 December 2013
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int m;

        Console.WriteLine("");
        Console.WriteLine("TEST02");
        Console.WriteLine("  HYPERSPHERE_01_SURFACE_UNIFORM samples uniformly from the");
        Console.WriteLine("  surface of the unit hypersphere");

        int seed = 123456789;

        typeMethods.r8vecNormalData data = new();

        const int n = 1;

        for (m = 1; m <= 5; m++)
        {
            int test;
            for (test = 1; test <= 3; test++)
            {
                double[] x = Hypersphere.hypersphere_01_surface_uniform(m, n, ref data, ref seed);
                typeMethods.r8vec_transpose_print(m, x, "  Random hypersphere point:");
            }
        }
    }