예제 #1
0
    private static void r8vec_sct_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    R8VEC_SCT_TEST tests R8VEC_SCT.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    27 February 2010
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const double ahi = 5.0;
        const double alo = 0.0;
        int          i;
        const int    n = 256;

        Console.WriteLine("");
        Console.WriteLine("R8VEC_SCTTEST");
        Console.WriteLine("  R8VEC_SCT does a forward or backward slow cosine transform.");
        Console.WriteLine("");
        Console.WriteLine("  The number of data items is N = " + n + "");
        //
        //  Set the data values.
        //
        int seed = 123456789;

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

        typeMethods.r8vec_print_part(n, c, 10, "  The original data:");
        //
        //  Compute the coefficients.
        //
        double[] d = Slow.r8vec_sct(n, c);

        typeMethods.r8vec_print_part(n, d, 10, "  The cosine coefficients:");
        //
        //  Now compute inverse transform of coefficients.  Should get back the
        //  original data.
        //
        double[] e = Slow.r8vec_sct(n, d);

        for (i = 0; i < n; i++)
        {
            e[i] /= 2 * n;
        }

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