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
(attachments)
xerand.c (1.99 KB)