random number generators

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • urkel
    New Member
    • Jul 2007
    • 5

    #1

    random number generators

    Hello everybody,
    I have these errors on C program that may be because of random number definition. I use an SSH to compile C like in Linux. May be you have idea whether the errors are due to the random number generators in my program do not match those available from libraries in the SSH. My C program uses these libraries
    [code=c]
    #include<stdio. h>
    #include<stdlib .h>
    #include<math.h >
    #include<assert .h>
    #include<fftw3. h>

    // These are the definitions of random number generators being used,

    static unsigned long long int x = 1;
    double drand64(void) ............... ............... ............... ..........line 1781
    {
    x = 636413622384679 3005ll * x + (long long int) 1;
    return (double) x * 5.4210108624275 218e-20;
    }
    void srand64(int seed).......... ............... ............... ............... line 1787
    {
    assert(sizeof(l ong long int) == 8);
    x = seed;
    }

    // The calling functions

    srand48(time(NU LL));
    srand64(time(NU LL));.......... ..............l ine 778

    r1 = drand48();
    r2 = drand64();..... ............... ............lin e 783

    /* . . . */
    [/code]
    When I compile using icc, there are several warnings on random number generators

    GlobalRevows.c( 192): warning #181: argument is incompatible with corresponding format string conversion
    sizeof(real), (double) h, MAX, MAX_pass);
    ^
    GlobalRevows.c( 778): warning #266: function declared implicitly
    srand64(time(NU LL));
    ^
    GlobalRevows.c( 783): warning #266: function declared implicitly
    r2 = drand64();
    ^
    GlobalRevows.c( 791): warning #266: function declared implicitly
    r2 = drand64();
    ^
    GlobalRevows.c( 800): warning #177: label "Next_T" was declared but never referenced
    Next_T:
    ^
    GlobalRevows.c( 1780): warning #159: declaration is incompatible with previous "drand64" (declared at line 783)
    double drand64(void)
    ^
    GlobalRevows.c( 1786): warning #159: declaration is incompatible with previous "srand64" (declared at line 778)
    void srand64(int seed)
    ^
    GlobalRevows.c( 1792): error: variable "x" has already been initialized
    static unsigned long long int x = 1;
    ^
    GlobalRevows.c( 1800): warning #147: declaration is incompatible with "void srand48(long)" (declared at line 522 of "/usr/include/stdlib.h")
    void srand48(int seed)
    ^
    Compiling with gcc gives errors something like this;

    GlobalRevows1.c :1781: error: conflicting types for 'drand64'
    GlobalRevows1.c :783: error: previous implicit declaration of 'drand64' was here
    GlobalRevows1.c :1787: error: conflicting types for 'srand64'
    GlobalRevows1.c :778: error: previous implicit declaration of 'srand64' was here
    I have tried many alternative ways but none works. Any suggestion would be appreciated.

    regards,
    Last edited by sicarie; Aug 9 '07, 12:59 PM. Reason: Code tags are to the right when you start/reply to a post. Please use them.
Working...