예제 #1
0
    private static void r8vec_sst_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    R8VEC_SST_TEST tests R8VEC_SST.
    //
    //  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_SST_TEST");
        Console.WriteLine("  R8VEC_SST does a forward or backward slow sine 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_sst(n, c);

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

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

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