grass  7.8.6
About: GRASS (Geographic Resources Analysis Support System) is a raster- and vector-based GIS, image processing system, graphics production system and spatial modeling system.
  Fossies Dox: grass-7.8.6.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

lrand48.c File Reference

GIS Library - Pseudo-random number generation. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <grass/gis.h>
#include <grass/glocale.h>
#include <time.h>
#include <sys/types.h>
#include <unistd.h>
Include dependency graph for lrand48.c:

Go to the source code of this file.

Macros

#define LO(x)   ((x) & 0xFFFFU)
 
#define HI(x)   ((x) >> 16)
 

Typedefs

typedef unsigned short uint16
 
typedef unsigned int uint32
 
typedef signed int int32
 

Functions

void G_srand48 (long seedval)
 Seed the pseudo-random number generator. More...
 
long G_srand48_auto (void)
 Seed the pseudo-random number generator from the time and PID. More...
 
static void G__next (void)
 
long G_lrand48 (void)
 Generate an integer in the range [0, 2^31) More...
 
long G_mrand48 (void)
 Generate an integer in the range [-2^31, 2^31) More...
 
double G_drand48 (void)
 Generate a floating-point value in the range [0,1) More...
 

Variables

static uint16 x0
 
static uint16 x1
 
static uint16 x2
 
static const uint32 a0 = 0xE66D
 
static const uint32 a1 = 0xDEEC
 
static const uint32 a2 = 0x5
 
static const uint32 b0 = 0xB
 
static int seeded
 

Detailed Description

GIS Library - Pseudo-random number generation.

(C) 2014 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Glynn Clements

Definition in file lrand48.c.

Macro Definition Documentation

◆ HI

#define HI (   x)    ((x) >> 16)

Definition at line 45 of file lrand48.c.

◆ LO

#define LO (   x)    ((x) & 0xFFFFU)

Definition at line 44 of file lrand48.c.

Typedef Documentation

◆ int32

typedef signed int int32

Definition at line 33 of file lrand48.c.

◆ uint16

typedef unsigned short uint16

Definition at line 31 of file lrand48.c.

◆ uint32

typedef unsigned int uint32

Definition at line 32 of file lrand48.c.

Function Documentation

◆ G__next()

static void G__next ( void  )
static

Definition at line 100 of file lrand48.c.

References _, a0, a1, a2, b0, G_fatal_error(), HI, LO, seeded, x0, x1, and x2.

Referenced by G_drand48(), G_lrand48(), and G_mrand48().

◆ G_drand48()

double G_drand48 ( void  )

Generate a floating-point value in the range [0,1)

Returns
the generated value

Definition at line 157 of file lrand48.c.

References G__next(), r, x0, x1, and x2.

Referenced by f_rand(), and G_math_rand().

◆ G_lrand48()

long G_lrand48 ( void  )

Generate an integer in the range [0, 2^31)

Returns
the generated value

Definition at line 129 of file lrand48.c.

References G__next(), r, x1, and x2.

Referenced by Rast_make_random_colors().

◆ G_mrand48()

long G_mrand48 ( void  )

Generate an integer in the range [-2^31, 2^31)

Returns
the generated value

Definition at line 143 of file lrand48.c.

References G__next(), r, x1, and x2.

Referenced by f_rand().

◆ G_srand48()

void G_srand48 ( long  seedval)

Seed the pseudo-random number generator.

Parameters
seedval32-bit integer used to seed the PRNG

Definition at line 53 of file lrand48.c.

References HI, LO, seeded, x, x0, x1, and x2.

Referenced by G_math_srand(), and G_srand48_auto().

◆ G_srand48_auto()

long G_srand48_auto ( void  )

Seed the pseudo-random number generator from the time and PID.

A weak hash of the current time and PID is generated and used to seed the PRNG

Returns
generated seed value passed to G_srand48()

Definition at line 71 of file lrand48.c.

References _, G_fatal_error(), G_srand48(), getenv(), NULL, and t.

Referenced by G_math_srand_auto(), and Rast_make_random_colors().

Variable Documentation

◆ a0

const uint32 a0 = 0xE66D
static

◆ a1

◆ a2

◆ b0

const uint32 b0 = 0xB
static

Definition at line 40 of file lrand48.c.

Referenced by convolution_line(), G__next(), parallel_line(), PNG_draw_bitmap(), and write_rule().

◆ seeded

int seeded
static

Definition at line 42 of file lrand48.c.

Referenced by G__next(), and G_srand48().

◆ x0

◆ x1

uint16 x1
static

Definition at line 35 of file lrand48.c.

Referenced by AS_eqdrt(), boq_load(), Cairo_Box(), Cairo_raster(), Cdhc_enormp(), clip_path_plane(), cmp_q_x(), cmp_t_y(), COM_Box_abs(), connect_lines(), cross_seg(), cull_path_plane(), D_box_abs(), D_line_abs(), D_line_rel(), dig_distance2_point_to_line(), dist2(), dist_squared(), draw_arrow(), draw_line(), draw_line_dir(), edge(), edge2perimeter(), euclidify(), extend_lines(), fastline(), fill(), find_all_intersections(), find_azimuth(), find_cross(), find_extended_intersection(), G__next(), G_bresenham_line(), G_distance2_point_to_line(), G_distance_point_to_line_segment(), G_drand48(), G_ellipsoid_polygon_area(), G_lrand48(), G_mrand48(), G_planimetric_polygon_area(), G_plot_area(), G_plot_polygon(), G_srand48(), get_polygon_orientation(), GS_draw_line_onsurf(), GS_draw_nline_onsurf(), GS_get_distance_alongsurf(), gsd_coarse_surf_map(), gsd_norm_arrows(), gsd_surf_const(), gsd_surf_map(), gsd_surf_map_old(), GVL_slice_get_pos(), GVL_slice_set_pos(), HTML_Box(), I_rasterize(), IL_vector_input_data_2d(), line(), line_coefficients(), make_statistics(), mystats(), norm_vector(), plot_line(), PNG_Box(), png_draw_line(), PNG_raster(), PS_Box(), Rast3d_get_block(), Rast_abs_log_colors(), row_dotted_fill(), row_solid_fill(), segment_intersection_2d(), segment_intersection_2d_tol(), segments_x_ray(), segs_intersect(), slowline(), tps_base_func(), vect(), Vect_line_segment(), Vect_points_distance(), Vect_segment_intersection(), Vect_snap_line(), Vect_snap_lines_list_kdtree(), Vect_snap_lines_list_rtree(), and Vedit_bulk_labeling().

◆ x2