COIN-OR::LEMON - Graph Library

Changeset 2229:4dbb6dd2dd4b in lemon-0.x for test


Ignore:
Timestamp:
10/02/06 18:11:00 (14 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2969
Message:

Mersenne Twister random number generator

The code is based on the official MT19937 implementation
It is fully rewritten:

http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html

todo: fixing copyright information

Location:
test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • test/graph_utils_test.h

    r1956 r2229  
    5151    typedef typename Graph::EdgeIt EdgeIt;
    5252    Graph graph;
    53     srand(time(0));
    5453    for (int i = 0; i < 10; ++i) {
    5554      graph.addNode();
     
    5857    typename DescriptorMap<Graph, Node>::InverseMap invNodes(nodes);
    5958    for (int i = 0; i < 100; ++i) {
    60       int src = (int)(rand() / (RAND_MAX + 1.0) * invNodes.size());
    61       int trg = (int)(rand() / (RAND_MAX + 1.0) * invNodes.size());
     59      int src = rnd.getInt(invNodes.size());
     60      int trg = rnd.getInt(invNodes.size());
    6261      graph.addEdge(invNodes[src], invNodes[trg]);
    6362    }
  • test/heap_test.h

    r1956 r2229  
    4646
    4747  for (int i = 0; i < n; ++i) {
    48     v[i] = rand() % 1000;
     48    v[i] = rnd.getInt(1000);
    4949    heap.push(i, v[i]);
    5050  }
     
    6666
    6767  for (int i = 0; i < n; ++i) {
    68     v[i] = rand() % 1000;
     68    v[i] = rnd.getInt(1000);
    6969    heap.push(i, v[i]);
    7070  }
    7171  for (int i = 0; i < n; ++i) {
    72     v[i] += rand() % 1000;
     72    v[i] += rnd.getInt(1000);
    7373    heap.increase(i, v[i]);
    7474  }
  • test/test_tools.h

    r2198 r2229  
    2828#include <lemon/concept_check.h>
    2929#include <lemon/concept/graph.h>
     30
     31#include <lemon/random.h>
    3032
    3133using namespace lemon;
     
    177179}
    178180
    179 int _urandom_init() {
    180   int seed = time(0);
    181   srand(seed);
    182   return seed;
    183 }
    184 
    185181int urandom(int n) {
    186   static int seed = _urandom_init();
    187   ignore_unused_variable_warning(seed);
    188   return (int)(rand() / (1.0 + RAND_MAX) * n);
     182  return rnd.getInt(n);
    189183}
    190184
Note: See TracChangeset for help on using the changeset viewer.