[GRASSLIST:7396] Addition to mapcalc

Joel Peter William Pitt joel.pitt at gmail.com
Thu Jun 30 22:58:56 EDT 2005


Hi All,

I'm progressing well with my spread simulation in GRASS.

I thought I'd share a quick hack to mapcalc that might be useful.
Mapcalc allows for random number generation using rand(lo,hi) however
there is no way to specify the seed for this generator. I needed one
that I could control the state over for replication of results and
multiple simulation runs.

I called the function erand(a,b,c) where a, b, and c are unsigned
short integers representing the state as in "man erand48". These
initialise the generator for the first cell processed and thereafter
are used as state storage for the generator. It only generates doubles
at the moment.

changes to make to files in r.mapcalc directory:

func_prototype.h:
extern func_t f_erand	;

function.c:
{"erand",	c_int123,	f_erand		},

and add the file xerand.c (attached) to the Makefile.

I make no guarantees about it's behaviour, since I don't have the time
to investigate the typing system that mapcalc uses.

Cheers,
Joel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xerand.c
Type: text/x-csrc
Size: 2033 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20050630/c0cadd9c/xerand.bin


More information about the grass-user mailing list