#2272: Improve consistency in random generator usage
-------------------------+--------------------------------------------------
Reporter: neteler | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-releasebranch70
Keywords: random | Platform: Unspecified
Cpu: Unspecified |
-------------------------+--------------------------------------------------
The usage of drand48()/srand48() should be consolitated,
perhaps using G_math_rand() which is provided in
lib/gmath/rand1.c:
{{{
# incomplete search
find . -name '*.c' | xargs grep -l rand48
./raster/r.mapcalc/xrand.c
./raster/r.mapcalc/evaluate.c
./raster/r.random/creat_rand.c
./lib/gmath/rand1.c
./lib/vector/rtree/rect.c
./vector/v.qcount/findquads.c
./vector/v.random/main.c
./vector/v.kcv/main.c
grep rand48 */*/*.c | grep -v flag
lib/gmath/rand1.c: srand48(-seed);
lib/gmath/rand1.c: return (float)drand48();
raster/r.mapcalc/evaluate.c: srand48(seed_value);
raster/r.mapcalc/xrand.c:#define drand48()
((double)rand()/((double)RAND_MAX + 1))
raster/r.mapcalc/xrand.c:#define mrand48() ((long)rand())
raster/r.mapcalc/xrand.c: unsigned long x = (unsigned
long)mrand48();
raster/r.mapcalc/xrand.c: double x = drand48();
raster/r.mapcalc/xrand.c: double x = drand48();
raster/r.random/creat_rand.c:#define lrand48() (((long) rand() ^ ((long)
rand() << 16)) & 0x7FFFFFFF)
raster/r.random/creat_rand.c:#define srand48(sv) (srand((unsigned)(sv)))
raster/r.random/creat_rand.c: return lrand48();
raster/r.random/creat_rand.c: srand48((long)time((time_t *) 0));
vector/v.kcv/main.c: rng = drand48;
vector/v.kcv/main.c: srand48((long)getpid());
vector/v.qcount/findquads.c: #define R_INIT srand48
vector/v.qcount/findquads.c: #define RANDOM(lo,hi) (drand48()/R_MAX*(hi-
lo)+lo)
vector/v.random/main.c:double drand48()
vector/v.random/main.c:#define srand48(sv) (srand((unsigned)(sv)))
vector/v.random/main.c: struct Flag *rand, *drand48, *z, *notopo;
vector/v.random/main.c: rng = drand48;
vector/v.random/main.c: srand48((long)seed);
vector/v.random/main.c: srand48((long)getpid());
}}}
See also r53234 etc.
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2272>
GRASS GIS <http://grass.osgeo.org>