static void convert_o0o1(ref w128_t w)
 {
     w.u64_0 |= 1;
     w.u64_1 |= 1;
     w.d0    -= 1.0;
     w.d1    -= 1.0;
 }
Beispiel #2
0
 public dsfmt_t()
 {
     status = new w128_t[192];
     for (int i = 0; i < status.Length; i++)
     {
         status[i] = new w128_t();
     }
 }
        /**
         * This function generates double precision floating point
         * pseudorandom numbers which distribute in the range (0, 1) to the
         * specified array[] by one call. This function is the same as
         * fill_array_close1_open2() except the distribution range.
         *
         * @param dsfmt dsfmt state vector.
         * @param array an array where pseudorandom numbers are filled
         * by this function.
         * @param size the number of pseudorandom numbers to be generated.
         * see also \sa fill_array_close1_open2()
         */
        public void dsfmt_fill_array_open_open(double[] array, int size)
        {
            assert(size % 2 == 0);
            assert(size >= DSFMT_N64);
            var buf = new w128_t[size / 2];

            gen_rand_array_o0o1(buf, buf.Length);
            copy64(buf, array);
        }
Beispiel #4
0
 static void dsfmt_fill_array_open_open(ref dsfmt_t dsfmt, double[] array, int size)
 {
     w128_t [] warray = new w128_t [size / 2];
     for (int i = 0; i < warray.Length; i++)
     {
         warray[i] = new w128_t();
     }
     gen_rand_array_o0o1(ref dsfmt, ref warray, size / 2);
     for (int i = 0; i < size; i++)
     {
         array [i] = get_double(warray, i);
     }
 }
        static void do_recursion(ref w128_t r, ref w128_t a, ref w128_t b, ref w128_t lung)
        {
            uint64_t t0, t1, L0, L1;

            t0         = a.u64_0;
            t1         = a.u64_1;
            L0         = lung.u64_0;
            L1         = lung.u64_1;
            lung.u64_0 = (t0 << DSFMT_SL1) ^ (L1 >> 32) ^ (L1 << 32) ^ b.u64_0;
            lung.u64_1 = (t1 << DSFMT_SL1) ^ (L0 >> 32) ^ (L0 << 32) ^ b.u64_1;
            r.u64_0    = (lung.u64_0 >> DSFMT_SR) ^ (lung.u64_0 & DSFMT_MSK1) ^ t0;
            r.u64_1    = (lung.u64_1 >> DSFMT_SR) ^ (lung.u64_1 & DSFMT_MSK2) ^ t1;
        }
Beispiel #6
0
    static void gen_rand_array_o0o1(ref dsfmt_t dsfmt, ref w128_t[] array, int size)
    {
        int i;
        int j;

        w128_t[] lung = new w128_t[1];
        lung [0] = new w128_t();
        if (verbose)
        {
            Console.WriteLine("gen_rand_array_o0o1");
        }
        put_ulong(lung, 0, get_ulong(dsfmt.status, ((19937 - 128) / 104 + 1) * 2));
        put_ulong(lung, 1, get_ulong(dsfmt.status, ((19937 - 128) / 104 + 1) * 2 + 1));
        do_recursion(ref array, 0, ref dsfmt.status, 0, ref dsfmt.status, 117, ref lung);
        for (i = 1; i < ((19937 - 128) / 104 + 1) - 117; i++)
        {
            do_recursion(ref array, i, ref dsfmt.status, i, ref dsfmt.status, i + 117, ref lung);
        }

        for ( ; i < ((19937 - 128) / 104 + 1); i++)
        {
            do_recursion(ref array, i, ref dsfmt.status, i, ref array, i + 117 - ((19937 - 128) / 104 + 1), ref lung);
        }

        for ( ; i < size - ((19937 - 128) / 104 + 1); i++)
        {
            do_recursion(ref array, i, ref array, i - ((19937 - 128) / 104 + 1), ref array, i + 117 - ((19937 - 128) / 104 + 1), ref lung);
            convert_o0o1(ref array, (i - ((19937 - 128) / 104 + 1)));
        }

        for (j = 0; j < 2 * ((19937 - 128) / 104 + 1) - size; j++)
        {
            put_ulong(dsfmt.status, j * 2, get_ulong(array, (j + size - ((19937 - 128) / 104 + 1)) * 2));
            put_ulong(dsfmt.status, j * 2 + 1, get_ulong(array, (j + size - ((19937 - 128) / 104 + 1)) * 2 + 1));
        }

        for ( ; i < size; i++, j++)
        {
            do_recursion(ref array, i, ref array, i - ((19937 - 128) / 104 + 1), ref array, i + 117 - ((19937 - 128) / 104 + 1), ref lung);
            put_ulong(dsfmt.status, j * 2, get_ulong(array, i * 2));
            put_ulong(dsfmt.status, j * 2 + 1, get_ulong(array, i * 2 + 1));
            convert_o0o1(ref array, (i - ((19937 - 128) / 104 + 1)));
        }

        for (i = size - ((19937 - 128) / 104 + 1); i < size; i++)
        {
            convert_o0o1(ref array, i);
        }
        put_ulong(dsfmt.status, ((19937 - 128) / 104 + 1) * 2, get_ulong(lung, 0));
        put_ulong(dsfmt.status, ((19937 - 128) / 104 + 1) * 2 + 1, get_ulong(lung, 1));
    }
 static void convert_o0c1(ref w128_t w)
 {
     w.d0 = 2.0 - w.d0;
     w.d1 = 2.0 - w.d1;
 }
 static void convert_c0o1(ref w128_t w)
 {
     w.d0 -= 1.0;
     w.d1 -= 1.0;
 }