Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion RNGs: A Super KISS
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
user923005  
View profile  
 More options Nov 3 2009, 8:36 pm
Newsgroups: sci.math, comp.lang.c, sci.crypt, comp.lang.c++
From: user923005 <dcor...@connx.com>
Date: Tue, 3 Nov 2009 12:36:15 -0800 (PST)
Local: Tues, Nov 3 2009 8:36 pm
Subject: Re: RNGs: A Super KISS
On Nov 3, 12:23 pm, user923005 <dcor...@connx.com> wrote:
I copied and pasted from the wrong file.  Here is the correct code
[snip]
class SuperKiss {

private:
    unsigned long  Q[41790];
    unsigned long  indx;
    unsigned long  carry;
    unsigned long  xcng;
    unsigned long  xs;

    int refill ()
    {
        int i;
        unsigned long long t;
        for (i = 0; i < 41790; i++)
        {
            t = 7010176LL * Q[i] + carry;
            carry = (t >> 32);
            Q[i] = ~(t);
        }
        indx = 1;
        return (Q[0]);
    }

public:
    // Constructor:
    SuperKiss()
    {
        indx  = 41790;
        carry = 362436;
        xcng  = 1236789;
        xs    = 521288629;
        unsigned i;
        for (i = 0; i < 41790; i++)
            Q[i] = (xcng = 69609 * xcng + 123) +
                   (xs ^= xs << 13, xs ^= (unsigned) xs >> 17, xs ^=
xs >> 5);
    }

    // Collect next random number:
    unsigned long SKRand() {
        return (indx < 41790 ? Q[indx++] : refill ()) +
               (xcng = 69609 * xcng + 123) +
               (xs ^= xs << 13, xs ^= (unsigned) xs >> 17, xs ^= xs >>
5);
    }

};

int
main ()
{
    unsigned long i;
    int x=0;
    SuperKiss sk;
    for (i = 0; i < 1000000000; i++)
        x = sk.SKRand();
    std::cout << "   x = " << x << std::endl << "Does x=-872412446?"
<< std::endl;
    return 0;
}


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google