コード例 #1
0
    private static void r8vec_swt_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    R8VEC_SWT_TEST tests R8VEC_SWTB and R8VEC_SWTF.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    27 June 2015
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int       i;
        const int n = 36;

        const double alo = 0.0;
        const double ahi = 5.0;

        Console.WriteLine("");
        Console.WriteLine("R8VEC_SWT_TEST");
        Console.WriteLine("  R8VEC_SWTF computes the forward slow wavelet transform.");
        Console.WriteLine("  R8VEC_SWTB computes the backward slow wavelet transform.");
        Console.WriteLine("");
        Console.WriteLine("  The number of data values, N = " + n + "");

        int seed = 123456789;

        double[] x = UniformRNG.r8vec_uniform_ab_new(n, alo, ahi, ref seed);

        typeMethods.r8vec_print_part(n, x, 10, "  The original data:");
        //
        //  Compute the slow wavelet transform of the data.
        //
        int np1h = (n + 1) / 2;

        double[] s = new double[np1h];
        double[] d = new double[np1h];

        Slow.r8vec_swtf(n, x, ref s, ref d);

        Console.WriteLine("");
        Console.WriteLine("     I          S(I)            D(I)");
        Console.WriteLine("");
        for (i = 0; i < np1h; i++)
        {
            Console.WriteLine("  " + i.ToString(CultureInfo.InvariantCulture).PadLeft(4)
                              + "  " + s[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + d[i].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }

        //
        //  Now try to retrieve the data from the coefficients.
        //

        x = Slow.r8vec_swtb(n, ref s, ref d);

        typeMethods.r8vec_print_part(n, x, 10, "  The retrieved data:");
    }