[GRASS5] r.random broken

Glynn Clements glynn at gclements.plus.com
Sat Jun 4 03:10:08 EDT 2005


Michael Barton wrote:

> I just tried to use r.random to generate a set of random points across the
> Spearfish dem file‹to illustrate interpolation.
> 
> When I display the points, they are all clustered along the top (i.e.,
> north) edge. This happens with both raster and vector points, and when I run
> it against both elevation.dem and elevation.10m. It looks something is wrong
> with the algorithm to generate the y values.

r.random totally won't work if either __CYGWIN__ or __APPLE__ are
defined, due to the following in raster/r.random/creat_rand.c:

	#if defined(__CYGWIN__) || defined(__APPLE__)
	#define lrand48() rand()/32767.0
	#define srand48(sv) (srand((unsigned)(sv)))
	#else

lrand48() is supposed to return random numbers between 0 and 2^31. The
above lrand48() macro will end up returning values which are far too
small, so, the random test will return true too often, resulting in
the desired number of random cells being reached far too early.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list