Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:42:02

0001 /* GLIB - Library of useful routines for C programming
0002  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-or-later
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 /*
0021  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
0022  * file for a list of people on the GLib Team.  See the ChangeLog
0023  * files for a list of changes.  These files are distributed with
0024  * GLib at ftp://ftp.gtk.org/pub/gtk/.
0025  */
0026 
0027 #ifndef __G_RAND_H__
0028 #define __G_RAND_H__
0029 
0030 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
0031 #error "Only <glib.h> can be included directly."
0032 #endif
0033 
0034 #include <glib/gtypes.h>
0035 
0036 G_BEGIN_DECLS
0037 
0038 typedef struct _GRand           GRand;
0039 
0040 /* GRand - a good and fast random number generator: Mersenne Twister
0041  * see http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html for more info.
0042  * The range functions return a value in the interval [begin, end).
0043  * int          -> [0..2^32-1]
0044  * int_range    -> [begin..end-1]
0045  * double       -> [0..1)
0046  * double_range -> [begin..end)
0047  */
0048 
0049 GLIB_AVAILABLE_IN_ALL
0050 GRand*  g_rand_new_with_seed  (guint32  seed);
0051 GLIB_AVAILABLE_IN_ALL
0052 GRand*  g_rand_new_with_seed_array (const guint32 *seed,
0053                     guint seed_length);
0054 GLIB_AVAILABLE_IN_ALL
0055 GRand*  g_rand_new            (void);
0056 GLIB_AVAILABLE_IN_ALL
0057 void    g_rand_free           (GRand   *rand_);
0058 GLIB_AVAILABLE_IN_ALL
0059 GRand*  g_rand_copy           (GRand   *rand_);
0060 GLIB_AVAILABLE_IN_ALL
0061 void    g_rand_set_seed       (GRand   *rand_,
0062                    guint32  seed);
0063 GLIB_AVAILABLE_IN_ALL
0064 void    g_rand_set_seed_array (GRand   *rand_,
0065                    const guint32 *seed,
0066                    guint    seed_length);
0067 
0068 #define g_rand_boolean(rand_) ((g_rand_int (rand_) & (1 << 15)) != 0)
0069 
0070 GLIB_AVAILABLE_IN_ALL
0071 guint32 g_rand_int            (GRand   *rand_);
0072 GLIB_AVAILABLE_IN_ALL
0073 gint32  g_rand_int_range      (GRand   *rand_,
0074                    gint32   begin,
0075                    gint32   end);
0076 GLIB_AVAILABLE_IN_ALL
0077 gdouble g_rand_double         (GRand   *rand_);
0078 GLIB_AVAILABLE_IN_ALL
0079 gdouble g_rand_double_range   (GRand   *rand_,
0080                    gdouble  begin,
0081                    gdouble  end);
0082 GLIB_AVAILABLE_IN_ALL
0083 void    g_random_set_seed     (guint32  seed);
0084 
0085 #define g_random_boolean() ((g_random_int () & (1 << 15)) != 0)
0086 
0087 GLIB_AVAILABLE_IN_ALL
0088 guint32 g_random_int          (void);
0089 GLIB_AVAILABLE_IN_ALL
0090 gint32  g_random_int_range    (gint32   begin,
0091                    gint32   end);
0092 GLIB_AVAILABLE_IN_ALL
0093 gdouble g_random_double       (void);
0094 GLIB_AVAILABLE_IN_ALL
0095 gdouble g_random_double_range (gdouble  begin,
0096                    gdouble  end);
0097 
0098 
0099 G_END_DECLS
0100 
0101 #endif /* __G_RAND_H__ */