c++randomstatic-librariesprng

WELL PRNG not working?(maybe)


I am trying to use a specific implementation of the WELL PRNG, supposedly better than the original. link to the code

However I am having some trobles with it. No matter how I seed it, it just outputs the same numbers. I think that I am probably just using it wrong, but have not been able to figure out my mistake. Unfortunately the source of the PRNG is completely opaque to me.

My code:

#include <iostream>
#include <WELL44497a_new.h>

void pause()
{
    std::string dummy;
    std::cout << "Press enter to continue...";
    std::getline(std::cin, dummy);
}

int main(int argc, char** argv) {
    using std::cout;
    using std::cin;
    using std::endl;
    cout<<"Hello"<<endl;
    pause();
    unsigned int rngseed;
    cout<<"Input RNG seed:";
    cin>>rngseed;
    cout<<"The RNG seed is:";
    cout<<rngseed<<endl;
    pause();
    InitWELLRNG44497(&rngseed);
    int i=1;
    for (i;i<100;i++){
        unsigned long rngtest=WELLRNG44497();
        cout<<rngtest<<endl;
    }
    pause();
    return 0;
}

Solution

  • Based on the comment squeamish-ossifrage I have revised the code. The following code appears to work:

    ...
    cin>>rngseed;
    cout<<"The RNG seed is:";
    cout<<rngseed<<endl;
    pause();
    unsigned int rngseed_arr[1391];
    int i=0;
    for (i;i<1391;i++){
        rngseed_arr[i]=rngseed+i;
    }
    InitWELLRNG44497(rngseed_arr);
    i=1;
    ...