GRASS 8 Programmer's Manual 8.6.0dev(2026)-88f4ac5790
Loading...
Searching...
No Matches
xrand.c File Reference
#include <stdlib.h>
#include <grass/config.h>
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/calc.h>
Include dependency graph for xrand.c:

Go to the source code of this file.

Functions

void calc_set_random_state (struct G_random_state *(*get_state)(void))
 Set the function which gives rand() the random number state.
 
int f_rand (int argc, const int *argt, void **args)
 Random value between two values, the upper one excluded.
 

Function Documentation

◆ calc_set_random_state()

void calc_set_random_state ( struct G_random_state *(*)(void)  get_state)

Set the function which gives rand() the random number state.

The function must return the state of the calling thread, which the tool places for the row being evaluated. Without a function, that is, with NULL, rand() draws from the generator shared by the whole program.

Parameters
get_statefunction returning the calling thread's state, or NULL

Definition at line 24 of file xrand.c.

◆ f_rand()

int f_rand ( int  argc,
const int *  argt,
void **  args 
)

Random value between two values, the upper one excluded.

Draws one value per column from the state given by the function set with calc_set_random_state(), or from the shared generator.

Definition at line 51 of file xrand.c.

References CELL_TYPE, columns, DCELL_TYPE, E_ARG_HI, E_ARG_LO, E_INV_TYPE, FCELL_TYPE, NULL, G_random_state::state, and x.