Ignore:
Timestamp:
Jan 20, 2014, 11:22:55 AM (13 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
0e51c9d
Parents:
dbf50f6
Message:

Setting KM seed in order to be able of reproduce classifications

Fix #1743

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@6132 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/contrib/kmlocal/KMrand.cpp

    rdbf50f6 rb3404fe  
    4444//      to initialise or reinitialise the sequence.
    4545//------------------------------------------------------------------------
    46 
    47 static double kmRan0()
    48 {
    49     int j;
     46void kmInitialice(int seed)
     47{
     48      int j;
    5049
    5150    static double y, maxran, v[98];     // The exact number 98 is unimportant
    52     static int iff = 0;
    53 
    54     // As a precaution against misuse, we will always initialize on the first
    55     // call, even if "kmIdum" is not set negative. Determine "maxran", the
    56     // next integer after the largest representable value of type int. We
    57     // assume this is a factor of 2 smaller than the corresponding value of
    58     // type unsigned int.
    59 
    60     if (kmIdum < 0 || iff == 0) {       // initialize
     51
     52        kmIdum = seed;
     53
    6154                /* compute maximum random number */
    6255#ifdef WIN32                            // Microsoft Visual C++
    … …  
    7164        maxran = (double) k;
    7265#endif
    73         iff = 1;
    74  
     66
    7567        srandom(kmIdum);
    76         kmIdum = 1;
    7768
    7869        for (j = 1; j <= 97; j++)       // exercise the system routine
    … …  
    8273            v[j] = random();
    8374        y = random();
    84      }
     75}
     76
     77
     78
     79static double kmRan0()
     80{
     81    int j;
     82
     83    static double y, maxran, v[98];     // The exact number 98 is unimportant
    8584
    8685    // This is where we start if not initializing. Use the previously saved
Note: See TracChangeset for help on using the changeset viewer.