[GRASS-dev] r.mapcalc addition

Glynn Clements glynn at gclements.plus.com
Mon Oct 23 20:54:45 EDT 2006


Joel Pitt wrote:

> > I consider this to be the wrong approach. At a minimum, setting the
> > seed should be decoupled from the generation of random numbers;
> > there's no reason to have what is essentially another copy of
> > f_rand().
> >
> > Also, it's debatable whether an r.mapcalc function is the correct
> > mechanism for setting an operating parameter. An environment variable
> > might be more suitable.
> >
> > Finally, even if f_erand() was the correct interface, having it call
> > f_rand() once the seed has been set is preferable to including a clone
> > of f_rand() in the body of f_erand().
> 
> Okay, that seems reasonable. I went the way I did because as far as I'm aware
> there was no existing system in mapcalc for options e.g. -seed=2342
> and at the time I altered it I was still getting to grips with GRASS.
> It is probably for the same reason, that I didn't consider environment
> variables too.
> 
> If I alter f_rand() to check an environment variable (GRASS_SEED or
> something similar), would that be suitable for inclusion?

That's one option, although putting it at the top-level (at the
beginning of execute() in evalute.c) is more robust. If another
function which uses the PRNG is added later, you probably want the
seed to affect everything which uses the PRNG regardless of the
evaluation order.

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




More information about the grass-dev mailing list