Exemplo n.º 1
0
    public static void niederreiter(ref NiederReiterData data, int dim_num, int base_, ref int seed, ref double[] r, int index = 0)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    NIEDERREITER returns an element of a Niederreiter sequence for base BASE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    11 September 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, int DIM_NUM, the spatial dimension.
    //
    //    Input, int BASE, the base to use for the Niederreiter sequence.
    //    The base should be a prime, or a power of a prime.
    //
    //    Input/output, int *SEED, a seed for the random number generator.
    //
    //    Output, double R[DIM_NUM], the element of the sequence.
    //
    {
        if (data.dim_num_save < 1 || dim_num != data.dim_num_save || seed <= 0)
        {
            const int skip = 1;

            inlo(dim_num, base_, skip);

            data.dim_num_save = dim_num;
        }

        golo(r, index);

        seed += 1;
    }
Exemplo n.º 2
0
    public static void niederreiter_generate(ref NiederReiterData data, int dim_num, int n, int base_, ref int seed,
                                             ref double[] r)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    NIEDERREITER_GENERATE generates a set of Niederreiter values.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    11 September 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, int DIM_NUM, the spatial dimension.
    //
    //    Input, int N, the number of points desired.
    //
    //    Input, int BASE, the base to use for the Niederreiter sequence.
    //    The base should be a prime, or a power of a prime.
    //
    //    Input/output, int *SEED, a seed for the random number generator.
    //
    //    Output, double R[DIM_NUM*N], the points.
    //
    {
        int j;

        for (j = 0; j < n; j++)
        {
            niederreiter(ref data, dim_num, base_, ref seed, ref r, index: +j * dim_num);
        }
    }