[GRASS5] r.random broken

Michael Barton michael.barton at asu.edu
Sat Jun 4 03:18:03 EDT 2005


Glynn,

Thanks for identifying the cause of the behavior I observed.

This is weird. Why is this module programmed to work incorrectly on Apple
and Cygwin systems??? Can it be corrected?

Michael


On 6/4/05 12:10 AM, "Glynn Clements" <glynn at gclements.plus.com> wrote:

> 
> 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.

____________________
C. Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
PO Box 872402
Arizona State University
Tempe, AZ  85287-2402
USA

Phone: 480-965-6262
Fax: 480-965-7671
www: <www.public.asu.edu/~cmbarton>




More information about the grass-dev mailing list