GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
rand1.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <grass/gis.h>
3 #include <grass/gmath.h>
4 
5 
6 /*!
7  * \fn float G_math_rand (int seed)
8  *
9  * \brief Random Number Generator (Uniform)
10  *
11  * Random number generator (Uniform Derivatives 0.0 -> 1.0)
12  *
13  * \param[in] seed
14  * \return float
15  */
16 
17 float G_math_rand(void)
18 {
19  return G_drand48();
20 }
21 
22 /*!
23  * \brief Seed the pseudo-random number generator
24  *
25  * \param seedval 32-bit integer used to seed the PRNG
26  */
27 
28 void G_math_srand(int seed)
29 {
30  G_srand48(seed);
31 }
32 
33 /*!
34  * \brief Seed the pseudo-random number generator from the time and PID
35  *
36  * \return generated seed value passed to G_srand48()
37  */
38 
40 {
41  return (int) G_srand48_auto();
42 }
void G_math_srand(int seed)
Seed the pseudo-random number generator.
Definition: rand1.c:28
double G_drand48(void)
Generate a floating-point value in the range [0,1)
Definition: lrand48.c:158
long G_srand48_auto(void)
Seed the pseudo-random number generator from the time and PID.
Definition: lrand48.c:71
float G_math_rand(void)
Definition: rand1.c:17
void G_srand48(long)
Seed the pseudo-random number generator.
Definition: lrand48.c:53
int G_math_srand_auto(void)
Seed the pseudo-random number generator from the time and PID.
Definition: rand1.c:39